comparison tests/test_classification.py @ 58:d118b6ca8370 branch-tests

some changes in classification with random train/test split
author Maria Panteli <m.x.panteli@gmail.com>
date Thu, 21 Sep 2017 15:24:18 +0100
parents e8084526f7e5
children f9513664fe42
comparison
equal deleted inserted replaced
57:dd86e49ae8bf 58:d118b6ca8370
17 X = np.random.randn(100, 3) 17 X = np.random.randn(100, 3)
18 # create 2 classes by shifting the entries of half the samples 18 # create 2 classes by shifting the entries of half the samples
19 X[-50:, :] = X[-50:, :] + 10 19 X[-50:, :] = X[-50:, :] + 10
20 Y = np.concatenate([np.repeat('a', 50), np.repeat('b', 50)]) 20 Y = np.concatenate([np.repeat('a', 50), np.repeat('b', 50)])
21 X_train, X_test, Y_train, Y_test = train_test_split(X, Y, train_size=0.6, random_state=1, stratify=Y) 21 X_train, X_test, Y_train, Y_test = train_test_split(X, Y, train_size=0.6, random_state=1, stratify=Y)
22 accuracy, predictions = classification.confusion_matrix(X_train, Y_train, X_test, Y_test) 22 accuracy, _ = classification.confusion_matrix(X_train, Y_train, X_test, Y_test)
23 # expect perfect accuracy for this 'easy' dataset 23 # expect perfect accuracy for this 'easy' dataset
24 assert accuracy == 1.0 24 assert accuracy == 1.0
25 25