コード例 #1
0
    def test_train_and_test_various_datasets(self, given_dataset):
        X_train_set, y_train_set, X_test, y_test, stats = MainTransformer.get_training_and_test_set(given_dataset,
                                                                                                    'Pollutant',
                                                                                                    'Uncertainty',
                                                                                                    size=0.5,
                                                                                                    normalize=True)

        gp = GaussianProcesses()
        gp.train(X_train_set, y_train_set, stats=stats)

        assert gp.stats['n_instances_trained'] == X_train_set.shape[0]
        assert gp.stats['dataset_stats'] == stats

        predictions = gp.predict(X_test, uncertainty=True)

        assert len(predictions) == X_test.shape[0]
コード例 #2
0
    def test_train_and_test(self, uncertainty):
        X_train_set, y_train_set, X_test, y_test, stats = MainTransformer.get_training_and_test_set(dataset_gp,
                                                                                                    'Pollutant',
                                                                                                    'Uncertainty',
                                                                                                    size=0.5,
                                                                                                    normalize=True)

        gp = GaussianProcesses()
        gp.train(X_train_set, y_train_set, stats=stats)

        assert gp.stats['n_instances_trained'] == X_train_set.shape[0]
        assert gp.stats['dataset_stats'] == stats

        predictions = gp.predict(X_test, uncertainty=uncertainty)

        assert len(predictions) == X_test.shape[0]

        if uncertainty:
            values_without_uncertainty = list(filter(lambda x: len(x) != 2, predictions))
            assert len(values_without_uncertainty) == 0

        if not isinstance(uncertainty, bool):
            assert len(list(filter(lambda x: not isinstance(x, tuple), predictions))) == X_test.shape[0]