Пример #1
0
    def validateModel(self, printToScreen=False):
        """ take the validation data and test it on the network at any given point.
        returns a single numeric error value which describes the goodness of the model"""
        if NoneType in (type(self.validationFeatures),
                        type(self.validationLabels), type(self.meta)):
            raise Exception("Specify validation features and labels")

        predictedOutput = list()
        for loopCounter, (rowIndex, row) in enumerate(
                self.validationFeatures.iterrows()):
            predictedOutput.append([item for item in self.predict(row)])
        predictedOutput = pd.DataFrame(
            np.array(predictedOutput),
            columns=[self.meta.categoricalLabelColumns])

        #convert predictions back into a human readable format
        predictedMatrix = DataCleaner.deNormalize(
            DataCleaner.categoricalToNominal(
                self.validationFeatures.join(predictedOutput), self.meta),
            self.meta)
        expectedMatrix = DataCleaner.deNormalize(
            DataCleaner.categoricalToNominal(
                self.validationFeatures.join(self.validationLabels),
                self.meta), self.meta)
        error = comparePrediction(predictedMatrix, expectedMatrix, self.meta,
                                  printToScreen)
        return error
Пример #2
0
    def validateModel(self, printToScreen=False):
        """ take the validation data and test it on the network at any given point.
        returns a single numeric error value which describes the goodness of the model"""
        if NoneType in (type(self.validationFeatures), type(self.validationLabels), type(self.meta)):
            raise Exception("Specify validation features and labels")

        predictedOutput = list()
        for loopCounter, (rowIndex, row) in enumerate(self.validationFeatures.iterrows()):
            predictedOutput.append([item for item in self.predict(row)])
        predictedOutput = pd.DataFrame(np.array(predictedOutput), columns=[self.meta.categoricalLabelColumns])

        #convert predictions back into a human readable format
        predictedMatrix  = DataCleaner.deNormalize(DataCleaner.categoricalToNominal(self.validationFeatures.join(predictedOutput), self.meta), self.meta)
        expectedMatrix   = DataCleaner.deNormalize(DataCleaner.categoricalToNominal(self.validationFeatures.join(self.validationLabels), self.meta), self.meta)
        error            = comparePrediction(predictedMatrix, expectedMatrix, self.meta, printToScreen)
        return error