diff 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
line wrap: on
line diff
--- a/tests/test_outliers.py	Wed Sep 13 12:09:55 2017 +0100
+++ b/tests/test_outliers.py	Wed Sep 13 12:53:57 2017 +0100
@@ -9,6 +9,8 @@
 
 import numpy as np
 import pandas as pd
+import pickle
+import os
 
 import scripts.outliers as outliers
 
@@ -29,4 +31,12 @@
 
 
 def test_get_outliers_df():
-    assert True
\ No newline at end of file
+    np.random.seed(1)
+    X = np.random.randn(100, 3)
+    # create outliers by shifting the entries of the last 5 samples
+    X[-5:, :] = X[-5:, :] + 10
+    Y = np.concatenate([np.repeat('a', 95), np.repeat('b', 5)])
+    df, threshold, MD = outliers.get_outliers_df(X, Y)
+    # expect that items from country 'b' are detected as outliers
+    assert np.array_equal(df['Outliers'].get_values(), np.array([0., 1.0]))
+