def test_transform(self): main_transformer = MainTransformer(config=config) result_weather = main_transformer.add_transformer( Transformers.WEATHER_TRANSFORMER) result_pollutant = main_transformer.add_transformer( Transformers.POLLUTANT_TRANSFORMER) weather_size = len(config['weather'].keys()) pollutant_size = len(config['pollutant'].keys()) main_transformer.transform() dataset = main_transformer.get_dataset() assert weather_size + pollutant_size == dataset.shape[1]
def test_train_and_test(self, uncertainty): global dataset data_transformer = MainTransformer(config=ConfigReader.CONFIG) data_transformer.add_transformer(Transformers.WEATHER_TRANSFORMER) data_transformer.add_transformer(Transformers.POLLUTANT_TRANSFORMER) data_transformer.transform() dataset = data_transformer.get_dataset() complete_dataset = dataset.dropna(inplace=False) MainTransformer.periodic_f(complete_dataset) X_train_set, y_train_set, X_test, y_test, stats = MainTransformer.get_training_and_test_set(dataset, 'Pollutant', 'Uncertainty', size=0.8, normalize=True) print(np.array(X_train_set)) print(y_train_set) # X_train_set, y_train_set, X_test, y_test, stats = MainTransformer.get_training_and_test_set(complete_dataset, # 'Pollutant', # 'Uncertainty', # size=0.8, # normalize=True) # # print(np.array(X_train_set)) # print(X_train_set) # print(y_train_set) gp = SparseGaussianProcesses() 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]