comparison tests/test_outliers.py @ 20:65b9330afdd8 branch-tests

return train/test sets in load_dataset
author Maria Panteli <m.x.panteli@gmail.com>
date Wed, 13 Sep 2017 12:53:57 +0100
parents ed109218dd4b
children e8084526f7e5
comparison
equal deleted inserted replaced
19:0bba6f63f4fd 20:65b9330afdd8
7 7
8 import pytest 8 import pytest
9 9
10 import numpy as np 10 import numpy as np
11 import pandas as pd 11 import pandas as pd
12 import pickle
13 import os
12 14
13 import scripts.outliers as outliers 15 import scripts.outliers as outliers
14 16
15 17
16 def test_country_outlier_df(): 18 def test_country_outlier_df():
27 outlier_counts_true = {'a':.5, 'b':1.} 29 outlier_counts_true = {'a':.5, 'b':1.}
28 assert np.array_equal(outlier_counts, outlier_counts_true) 30 assert np.array_equal(outlier_counts, outlier_counts_true)
29 31
30 32
31 def test_get_outliers_df(): 33 def test_get_outliers_df():
32 assert True 34 np.random.seed(1)
35 X = np.random.randn(100, 3)
36 # create outliers by shifting the entries of the last 5 samples
37 X[-5:, :] = X[-5:, :] + 10
38 Y = np.concatenate([np.repeat('a', 95), np.repeat('b', 5)])
39 df, threshold, MD = outliers.get_outliers_df(X, Y)
40 # expect that items from country 'b' are detected as outliers
41 assert np.array_equal(df['Outliers'].get_values(), np.array([0., 1.0]))
42