|
# from: python compare_classifiers_mnist.py gamma=3 C=1 digits=[] ntrain=50000 ntest=10000 tag="60k/gamma3-C1-50000-10000" |
|
# run: 20 Jul 2016 11:29 in ~bz/py/ml/sklearn/mnist Denis-iMac 10.8.3 |
|
|
|
-------------------------------------------------------------------------------- |
|
python compare_classifiers_mnist.py gamma=3 C=1 digits=[] ntrain=50000 ntest=10000 tag="60k/gamma3-C1-50000-10000" |
|
versions: sklearn 0.17.1 numpy 1.11.1 python 2.7.11 |
|
rows /= |row| (cos distance), -= mean |
|
|
|
params -- |
|
X (60000, 784) float32 min av max -0.0615 -5.92e-09 0.235 |
|
ntrain 50000 |
|
ntest 10000 |
|
digits [] |
|
y counts [5935 6729 5961 6131 5841 5423 5931 6214 5865 5970] |
|
knnear 3 |
|
C 1 |
|
gamma 3 |
|
nsplit 3 |
|
seed 0 |
|
run_date 2016-07-20 Jul 11:29 |
|
|
|
|
|
{ classify with KNN -- |
|
KNeighborsClassifier(algorithm='brute', leaf_size=30, metric='minkowski', |
|
metric_params=None, n_jobs=1, n_neighbors=3, p=2, |
|
weights='distance') |
|
|
|
KNN split 0 -- |
|
ytrain class sizes: [4897 5622 4985 5118 4849 4534 4957 5143 4895 5000] |
|
ytest class sizes: [1038 1107 976 1013 992 889 974 1071 970 970] |
|
0 sec train KNN |
|
12 sec test KNN: ypred == ytest 97.5 % |
|
|
|
Confusion matrix: 97.5 % correct = 9748 / 10000 KNN |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 1032 1 1 3 1 | 6 | 1038 |
|
1: 1101 4 2 | 6 | 1107 |
|
2: 10 2 947 2 1 6 6 2 | 29 | 976 |
|
3: 3 4 971 1 7 6 13 8 | 42 | 1013 |
|
4: 1 4 1 955 7 1 1 22 | 37 | 992 |
|
5: 4 1 4 1 860 10 1 6 2 | 29 | 889 |
|
6: 6 1 1 965 1 | 9 | 974 |
|
7: 5 6 5 1040 1 14 | 31 | 1071 |
|
8: 2 10 8 2 4 3 1 935 5 | 35 | 970 |
|
9: 3 1 7 7 1 6 3 942 | 28 | 970 |
|
-------------------------------------------------- |
|
26 26 16 22 16 14 24 23 31 54 | 252 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 22 7 9: 14 3 8: 13 2 0: 10 5 6: 10 KNN |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-KNN-split0.npz |
|
|
|
|
|
KNN split 1 -- |
|
ytrain class sizes: [4960 5627 4961 5108 4900 4523 4976 5126 4845 4974] |
|
ytest class sizes: [ 975 1102 1000 1023 941 900 955 1088 1020 996] |
|
0 sec train KNN |
|
11 sec test KNN: ypred == ytest 97.5 % |
|
|
|
Confusion matrix: 97.5 % correct = 9750 / 10000 KNN |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 971 2 2 | 4 | 975 |
|
1: 1097 2 2 1 | 5 | 1102 |
|
2: 3 1 978 2 3 7 4 2 | 22 | 1000 |
|
3: 1 1 4 986 7 1 6 13 4 | 37 | 1023 |
|
4: 1 8 905 4 3 20 | 36 | 941 |
|
5: 2 1 1 12 2 861 12 1 4 4 | 39 | 900 |
|
6: 4 2 2 945 2 | 10 | 955 |
|
7: 1 7 2 5 1060 1 12 | 28 | 1088 |
|
8: 2 7 1 7 2 7 8 4 978 4 | 42 | 1020 |
|
9: 2 5 8 1 2 6 3 969 | 27 | 996 |
|
-------------------------------------------------- |
|
14 31 10 28 17 17 32 28 27 46 | 250 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 20 3 8: 13 7 9: 12 5 6: 12 5 3: 12 KNN |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-KNN-split1.npz |
|
|
|
|
|
KNN split 2 -- |
|
ytrain class sizes: [4956 5545 5003 5130 4851 4505 4955 5151 4913 4991] |
|
ytest class sizes: [ 979 1184 958 1001 990 918 976 1063 952 979] |
|
0 sec train KNN |
|
11 sec test KNN: ypred == ytest 97.7 % |
|
|
|
Confusion matrix: 97.7 % correct = 9770 / 10000 KNN |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 977 1 1 | 2 | 979 |
|
1: 1178 1 1 1 1 2 | 6 | 1184 |
|
2: 5 4 938 2 1 2 4 1 1 | 20 | 958 |
|
3: 1 9 969 5 1 4 6 6 | 32 | 1001 |
|
4: 4 962 1 1 2 20 | 28 | 990 |
|
5: 6 1 6 2 885 9 4 5 | 33 | 918 |
|
6: 3 1 2 4 966 | 10 | 976 |
|
7: 2 8 2 2 1036 13 | 27 | 1063 |
|
8: 2 12 1 10 2 6 5 908 6 | 44 | 952 |
|
9: 2 2 4 5 1 1 9 4 951 | 28 | 979 |
|
-------------------------------------------------- |
|
20 32 15 22 15 18 20 21 15 52 | 230 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 20 7 9: 13 8 1: 12 8 3: 10 5 6: 9 KNN |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-KNN-split2.npz |
|
|
|
scores: KNN av 97.6 [97.5 97.5 97.7] train, test: [0 0 0] [12 11 11] sec |
|
} |
|
|
|
|
|
{ classify with rbf-SVM -- |
|
SVC(C=1, cache_size=2000, class_weight=None, coef0=0.0, |
|
decision_function_shape='ovr', degree=3, gamma=3, kernel='rbf', |
|
max_iter=-1, probability=False, random_state=0, shrinking=True, |
|
tol=0.001, verbose=False) |
|
|
|
rbf-SVM split 0 -- |
|
ytrain class sizes: [4897 5622 4985 5118 4849 4534 4957 5143 4895 5000] |
|
ytest class sizes: [1038 1107 976 1013 992 889 974 1071 970 970] |
|
510 sec train rbf-SVM |
|
113 sec test rbf-SVM: ypred == ytest 98.4 % |
|
|
|
Confusion matrix: 98.4 % correct = 9836 / 10000 rbf-SVM |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 1030 1 1 2 3 1 | 8 | 1038 |
|
1: 1094 6 4 1 1 1 | 13 | 1107 |
|
2: 3 959 1 3 5 4 1 | 17 | 976 |
|
3: 4 986 7 5 7 4 | 27 | 1013 |
|
4: 1 2 973 5 1 2 8 | 19 | 992 |
|
5: 2 1 4 871 6 1 2 2 | 18 | 889 |
|
6: 1 2 1 968 2 | 6 | 974 |
|
7: 2 6 1 5 1053 1 3 | 18 | 1071 |
|
8: 1 2 1 3 3 2 958 | 12 | 970 |
|
9: 2 1 2 5 7 2 6 1 944 | 26 | 970 |
|
-------------------------------------------------- |
|
9 4 23 17 17 14 16 21 23 20 | 164 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 8 3 5: 7 9 4: 7 3 8: 7 9 7: 6 rbf-SVM |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-rbf-SVM-split0.npz |
|
|
|
|
|
rbf-SVM split 1 -- |
|
ytrain class sizes: [4960 5627 4961 5108 4900 4523 4976 5126 4845 4974] |
|
ytest class sizes: [ 975 1102 1000 1023 941 900 955 1088 1020 996] |
|
505 sec train rbf-SVM |
|
113 sec test rbf-SVM: ypred == ytest 98.5 % |
|
|
|
Confusion matrix: 98.5 % correct = 9850 / 10000 rbf-SVM |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 971 1 2 1 | 4 | 975 |
|
1: 1089 4 4 3 1 1 | 13 | 1102 |
|
2: 2 991 1 1 4 1 | 9 | 1000 |
|
3: 7 998 3 7 5 3 | 25 | 1023 |
|
4: 3 1 930 2 5 | 11 | 941 |
|
5: 1 3 5 880 6 1 3 1 | 20 | 900 |
|
6: 5 1 1 4 942 2 | 13 | 955 |
|
7: 1 6 2 2 1072 5 | 16 | 1088 |
|
8: 3 1 2 1 5 1 3 1002 2 | 18 | 1020 |
|
9: 3 4 6 1 4 3 975 | 21 | 996 |
|
-------------------------------------------------- |
|
9 17 18 16 10 12 11 24 16 17 | 150 wrong predictions |
|
|
|
most confusable, true est: count -- 3 2: 7 3 7: 7 5 6: 6 9 4: 6 7 1: 6 rbf-SVM |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-rbf-SVM-split1.npz |
|
|
|
|
|
rbf-SVM split 2 -- |
|
ytrain class sizes: [4956 5545 5003 5130 4851 4505 4955 5151 4913 4991] |
|
ytest class sizes: [ 979 1184 958 1001 990 918 976 1063 952 979] |
|
506 sec train rbf-SVM |
|
113 sec test rbf-SVM: ypred == ytest 98.4 % |
|
|
|
Confusion matrix: 98.4 % correct = 9842 / 10000 rbf-SVM |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 974 2 1 1 1 | 5 | 979 |
|
1: 1176 1 1 1 4 1 | 8 | 1184 |
|
2: 3 1 946 2 2 4 | 12 | 958 |
|
3: 10 975 3 6 7 | 26 | 1001 |
|
4: 1 1 972 1 2 13 | 18 | 990 |
|
5: 3 2 4 1 903 4 1 | 15 | 918 |
|
6: 1 1 1 3 969 1 | 7 | 976 |
|
7: 1 3 3 1 2 1049 4 | 14 | 1063 |
|
8: 2 4 1 4 2 4 4 928 3 | 24 | 952 |
|
9: 3 2 1 4 8 1 1 7 2 950 | 29 | 979 |
|
-------------------------------------------------- |
|
13 11 22 16 17 14 9 23 12 21 | 158 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 13 3 2: 10 9 4: 8 9 7: 7 3 8: 7 rbf-SVM |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-rbf-SVM-split2.npz |
|
|
|
scores: rbf-SVM av 98.4 [98.4 98.5 98.4] train, test: [510 505 506] [113 113 113] sec |
|
dual_coef_ : (9, 14374) float64 min av max -1 1.76e-18 1 |
|
support_vectors_ : (14374, 784) float64 min av max -0.0615 -0.00033 0.235 |
|
} |
|
|
|
|
|
{ classify with poly2-SVM -- |
|
SVC(C=1, cache_size=2000, class_weight=None, coef0=0, |
|
decision_function_shape='ovr', degree=2, gamma=3, kernel='poly', |
|
max_iter=-1, probability=False, random_state=0, shrinking=True, |
|
tol=0.001, verbose=False) |
|
|
|
poly2-SVM split 0 -- |
|
ytrain class sizes: [4897 5622 4985 5118 4849 4534 4957 5143 4895 5000] |
|
ytest class sizes: [1038 1107 976 1013 992 889 974 1071 970 970] |
|
276 sec train poly2-SVM |
|
86 sec test poly2-SVM: ypred == ytest 98.4 % |
|
|
|
Confusion matrix: 98.4 % correct = 9838 / 10000 poly2-SVM |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 1029 1 1 3 3 1 | 9 | 1038 |
|
1: 1099 5 1 1 1 | 8 | 1107 |
|
2: 5 953 4 3 4 5 2 | 23 | 976 |
|
3: 1 1 995 5 1 2 5 3 | 18 | 1013 |
|
4: 1 1 971 6 2 2 9 | 21 | 992 |
|
5: 3 1 4 868 5 5 3 | 21 | 889 |
|
6: 2 1 968 3 | 6 | 974 |
|
7: 1 2 8 2 3 1048 1 6 | 23 | 1071 |
|
8: 1 2 1 1 1 2 962 | 8 | 970 |
|
9: 1 1 2 6 6 2 5 2 945 | 25 | 970 |
|
-------------------------------------------------- |
|
14 5 18 18 15 9 16 16 27 24 | 162 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 9 7 2: 8 7 9: 6 9 4: 6 9 3: 6 poly2-SVM |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-poly2-SVM-split0.npz |
|
|
|
|
|
poly2-SVM split 1 -- |
|
ytrain class sizes: [4960 5627 4961 5108 4900 4523 4976 5126 4845 4974] |
|
ytest class sizes: [ 975 1102 1000 1023 941 900 955 1088 1020 996] |
|
275 sec train poly2-SVM |
|
85 sec test poly2-SVM: ypred == ytest 98.5 % |
|
|
|
Confusion matrix: 98.5 % correct = 9845 / 10000 poly2-SVM |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 971 2 1 1 | 4 | 975 |
|
1: 1095 3 1 2 1 | 7 | 1102 |
|
2: 2 1 988 2 1 2 3 1 | 12 | 1000 |
|
3: 5 999 5 3 9 2 | 24 | 1023 |
|
4: 4 2 931 1 3 | 10 | 941 |
|
5: 1 2 11 1 874 5 1 2 3 | 26 | 900 |
|
6: 8 2 3 940 2 | 15 | 955 |
|
7: 1 5 4 2 1 1070 5 | 18 | 1088 |
|
8: 2 4 1 3 2 4 1002 2 | 18 | 1020 |
|
9: 2 2 4 4 1 6 2 975 | 21 | 996 |
|
-------------------------------------------------- |
|
14 18 16 24 7 12 10 19 18 17 | 155 wrong predictions |
|
|
|
most confusable, true est: count -- 5 3: 11 3 8: 9 6 0: 8 9 7: 6 5 6: 5 poly2-SVM |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-poly2-SVM-split1.npz |
|
|
|
|
|
poly2-SVM split 2 -- |
|
ytrain class sizes: [4956 5545 5003 5130 4851 4505 4955 5151 4913 4991] |
|
ytest class sizes: [ 979 1184 958 1001 990 918 976 1063 952 979] |
|
276 sec train poly2-SVM |
|
86 sec test poly2-SVM: ypred == ytest 98.4 % |
|
|
|
Confusion matrix: 98.4 % correct = 9841 / 10000 poly2-SVM |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 974 1 1 1 1 1 | 5 | 979 |
|
1: 1179 1 1 2 1 | 5 | 1184 |
|
2: 1 3 947 1 2 4 | 11 | 958 |
|
3: 7 978 9 2 5 | 23 | 1001 |
|
4: 1 3 973 1 12 | 17 | 990 |
|
5: 3 4 6 896 6 3 | 22 | 918 |
|
6: 1 1 3 968 3 | 8 | 976 |
|
7: 3 5 4 1 6 1041 3 | 22 | 1063 |
|
8: 1 3 1 5 1 3 3 932 3 | 20 | 952 |
|
9: 3 1 1 2 8 1 7 3 953 | 26 | 979 |
|
-------------------------------------------------- |
|
13 15 19 17 19 16 10 15 16 19 | 159 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 12 3 5: 9 9 4: 8 3 2: 7 9 7: 7 poly2-SVM |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-poly2-SVM-split2.npz |
|
|
|
scores: poly2-SVM av 98.4 [98.4 98.5 98.4] train, test: [276 275 276] [86 85 86] sec |
|
dual_coef_ : (9, 11092) float64 min av max -1 -2.56e-18 1 |
|
support_vectors_ : (11092, 784) float64 min av max -0.0615 2.82e-05 0.234 |
|
} |
|
|
|
|
|
{ classify with Random-Forest -- |
|
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini', |
|
max_depth=None, max_features='auto', max_leaf_nodes=None, |
|
min_samples_leaf=1, min_samples_split=2, |
|
min_weight_fraction_leaf=0.0, n_estimators=500, n_jobs=1, |
|
oob_score=False, random_state=0, verbose=0, warm_start=False) |
|
|
|
Random-Forest split 0 -- |
|
ytrain class sizes: [4897 5622 4985 5118 4849 4534 4957 5143 4895 5000] |
|
ytest class sizes: [1038 1107 976 1013 992 889 974 1071 970 970] |
|
283 sec train Random-Forest |
|
2 sec test Random-Forest: ypred == ytest 96.8 % |
|
|
|
Confusion matrix: 96.8 % correct = 9682 / 10000 Random-Forest |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 1020 2 1 1 4 1 8 1 | 18 | 1038 |
|
1: 1082 12 6 3 1 1 2 | 25 | 1107 |
|
2: 7 2 948 2 6 2 5 3 1 | 28 | 976 |
|
3: 2 10 969 1 9 6 10 6 | 44 | 1013 |
|
4: 2 2 961 6 1 4 16 | 31 | 992 |
|
5: 3 1 13 1 854 8 1 6 2 | 35 | 889 |
|
6: 3 4 3 961 3 | 13 | 974 |
|
7: 4 12 1 7 1025 2 20 | 46 | 1071 |
|
8: 2 2 1 2 3 4 5 3 937 11 | 33 | 970 |
|
9: 4 3 19 7 2 5 5 925 | 45 | 970 |
|
-------------------------------------------------- |
|
21 13 44 43 29 20 25 23 43 57 | 318 wrong predictions |
|
|
|
most confusable, true est: count -- 7 9: 20 9 3: 19 4 9: 16 5 3: 13 1 2: 12 Random-Forest |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-Random-Forest-split0.npz |
|
|
|
|
|
Random-Forest split 1 -- |
|
ytrain class sizes: [4960 5627 4961 5108 4900 4523 4976 5126 4845 4974] |
|
ytest class sizes: [ 975 1102 1000 1023 941 900 955 1088 1020 996] |
|
285 sec train Random-Forest |
|
2 sec test Random-Forest: ypred == ytest 97.0 % |
|
|
|
Confusion matrix: 97.0 % correct = 9701 / 10000 Random-Forest |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 968 1 4 2 | 7 | 975 |
|
1: 1085 6 5 2 1 1 1 1 | 17 | 1102 |
|
2: 3 2 978 2 3 3 4 3 2 | 22 | 1000 |
|
3: 1 2 9 976 1 11 1 9 10 3 | 47 | 1023 |
|
4: 2 2 1 917 1 2 2 14 | 24 | 941 |
|
5: 3 4 12 1 862 8 6 4 | 38 | 900 |
|
6: 6 3 1 9 933 3 | 22 | 955 |
|
7: 8 8 7 1052 1 12 | 36 | 1088 |
|
8: 1 5 3 7 6 6 3 978 11 | 42 | 1020 |
|
9: 4 2 12 13 1 2 6 4 952 | 44 | 996 |
|
-------------------------------------------------- |
|
20 25 30 39 34 28 20 25 32 46 | 299 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 14 9 4: 13 7 9: 12 9 3: 12 5 3: 12 Random-Forest |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-Random-Forest-split1.npz |
|
|
|
|
|
Random-Forest split 2 -- |
|
ytrain class sizes: [4956 5545 5003 5130 4851 4505 4955 5151 4913 4991] |
|
ytest class sizes: [ 979 1184 958 1001 990 918 976 1063 952 979] |
|
283 sec train Random-Forest |
|
2 sec test Random-Forest: ypred == ytest 97.1 % |
|
|
|
Confusion matrix: 97.1 % correct = 9711 / 10000 Random-Forest |
|
True classes down, estimated across | wrong | total class sizes |
|
-------------------------------------------------- |
|
0: 969 1 1 1 1 4 2 | 10 | 979 |
|
1: 1172 3 2 1 1 1 3 1 | 12 | 1184 |
|
2: 2 1 934 5 3 1 8 4 | 24 | 958 |
|
3: 2 14 957 1 8 2 8 5 4 | 44 | 1001 |
|
4: 1 1 1 957 2 1 1 3 23 | 33 | 990 |
|
5: 5 2 1 8 2 891 5 2 2 | 27 | 918 |
|
6: 2 1 1 1 6 964 1 | 12 | 976 |
|
7: 1 6 6 1 8 1022 4 15 | 41 | 1063 |
|
8: 4 8 3 10 4 3 7 909 4 | 43 | 952 |
|
9: 3 2 4 8 7 2 1 9 7 936 | 43 | 979 |
|
-------------------------------------------------- |
|
18 23 34 34 28 23 19 29 31 50 | 289 wrong predictions |
|
|
|
most confusable, true est: count -- 4 9: 23 7 9: 15 3 2: 14 8 3: 10 9 7: 9 Random-Forest |
|
|
|
|
|
saving to 60k/gamma3-C1-50000-10000-Random-Forest-split2.npz |
|
|
|
scores: Random-Forest av 97.0 [96.8 97 97.1] train, test: [283 285 283] [2 2 2] sec |
|
feature_importances_ : (784,) float64 min av max 0 0.00128 0.0123 |
|
} |
|
|
|
3839.10 real 3875.89 user 12.26 sys |