Example #1
0
    def evaluate(self, n_folds=10):
        matrices = []
        f1 = 0
        precision = 0
        recall = 0

        for train, test in self.__dp.split(n_folds,
                                           ActivityDataHeaders.START_TIME):
            self.fit(train)

            processed_dataset = self.process_dataset(test)

            predictions = self.__predict(processed_dataset)

            metric = Metrics(processed_dataset[ActivityDataHeaders.LABEL],
                             pd.DataFrame(predictions))

            f1 += metric.f1()
            precision += metric.precision()
            recall += metric.recall()
            matrices += [metric.confusion_matrix()]

        f1 /= n_folds
        precision /= n_folds
        recall /= n_folds
        matrices = np.array(matrices)

        return f1, precision, recall, matrices
Example #2
0
    def evaluate(self, n_folds=10):
        matrices = []
        f1 = 0
        precision = 0
        recall = 0

        for train, test in self.__dp.split(n_folds, ActivityDataHeaders.START_TIME):
            self.fit(train, to_save=False)

            batches = self.__create_batches(test)
            _, truth = self.__flat(batches)
            truth = self.__hot_encoder.inverse_transform(truth)
            truth = pd.DataFrame(truth)

            prediction = self.predict(test)

            metric = Metrics(truth, pd.DataFrame(prediction))

            f1 += metric.f1()
            precision += metric.precision()
            recall += metric.recall()
            matrices += [metric.confusion_matrix()]

        f1 /= n_folds
        precision /= n_folds
        recall /= n_folds
        matrices = np.array(matrices)

        return f1, precision, recall, matrices