diff --git a/__pycache__/run.cpython-37.pyc b/__pycache__/run.cpython-37.pyc index 404b618..1337d40 100644 Binary files a/__pycache__/run.cpython-37.pyc and b/__pycache__/run.cpython-37.pyc differ diff --git a/cachedir/joblib/run/randomSearch/c499eb613b7ddf35e621739083381f78/metadata.json b/cachedir/joblib/run/randomSearch/02f4b76834d076f3b2e8a3a6d6a6d0ad/metadata.json similarity index 69% rename from cachedir/joblib/run/randomSearch/c499eb613b7ddf35e621739083381f78/metadata.json rename to cachedir/joblib/run/randomSearch/02f4b76834d076f3b2e8a3a6d6a6d0ad/metadata.json index 6614fe8..3a4c4e6 100644 --- a/cachedir/joblib/run/randomSearch/c499eb613b7ddf35e621739083381f78/metadata.json +++ b/cachedir/joblib/run/randomSearch/02f4b76834d076f3b2e8a3a6d6a6d0ad/metadata.json @@ -1 +1 @@ -{"duration": 10.292684078216553, "input_args": {"XData": " Age Sex Cp Trestbps Chol Fbs Restecg Thalach Exang Oldpeak Slope Ca Thal\n0 63 1 3 145 233 1 0 150 0 2.3 0 0 1\n1 37 1 2 130 250 0 1 187 0 3.5 0 0 2\n2 41 0 1 130 204 0 0 172 0 1.4 2 0 2\n3 56 1 1 120 236 0 1 178 0 0.8 2 0 2\n4 57 0 0 120 354 0 1 163 1 0.6 2 0 2\n.. ... ... .. ... ... ... ... ... ... ... ... .. ...\n298 57 0 0 140 241 0 1 123 1 0.2 1 0 3\n299 45 1 3 110 264 0 1 132 0 1.2 1 0 3\n300 68 1 0 144 193 1 1 141 0 3.4 1 2 3\n301 57 1 0 130 131 0 1 115 1 1.2 1 1 3\n302 57 0 1 130 236 0 0 174 0 0.0 1 1 2\n\n[303 rows x 13 columns]", "yData": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]", "clf": "LogisticRegression(C=23, class_weight=None, dual=False, fit_intercept=True,\n intercept_scaling=1, l1_ratio=None, max_iter=150,\n multi_class='auto', n_jobs=None, penalty='l2',\n random_state=42, solver='newton-cg', tol=0.0001, verbose=0,\n warm_start=False)", "params": "{'C': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 'max_iter': [50, 100, 150, 200, 250, 300, 350, 400, 450], 'solver': ['lbfgs', 'newton-cg', 'sag', 'saga'], 'penalty': ['l2', 'none']}", "eachAlgor": "'LR'", "AlgorithmsIDsEnd": "100"}} \ No newline at end of file +{"duration": 25.273269653320312, "input_args": {"XData": " Age Sex Cp Trestbps Chol Fbs Restecg Thalach Exang Oldpeak Slope Ca Thal\n0 63 1 3 145 233 1 0 150 0 2.3 0 0 1\n1 37 1 2 130 250 0 1 187 0 3.5 0 0 2\n2 41 0 1 130 204 0 0 172 0 1.4 2 0 2\n3 56 1 1 120 236 0 1 178 0 0.8 2 0 2\n4 57 0 0 120 354 0 1 163 1 0.6 2 0 2\n.. ... ... .. ... ... ... ... ... ... ... ... .. ...\n298 57 0 0 140 241 0 1 123 1 0.2 1 0 3\n299 45 1 3 110 264 0 1 132 0 1.2 1 0 3\n300 68 1 0 144 193 1 1 141 0 3.4 1 2 3\n301 57 1 0 130 131 0 1 115 1 1.2 1 1 3\n302 57 0 1 130 236 0 0 174 0 0.0 1 1 2\n\n[303 rows x 13 columns]", "yData": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]", "clf": "LogisticRegression(C=21, class_weight=None, dual=False, fit_intercept=True,\n intercept_scaling=1, l1_ratio=None, max_iter=450,\n multi_class='auto', n_jobs=None, penalty='none',\n random_state=42, solver='sag', tol=0.0001, verbose=0,\n warm_start=False)", "params": "{'C': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 'max_iter': [50, 100, 150, 200, 250, 300, 350, 400, 450], 'solver': ['lbfgs', 'newton-cg', 'sag', 'saga'], 'penalty': ['l2', 'none']}", "eachAlgor": "'LR'", "AlgorithmsIDsEnd": "100"}} \ No newline at end of file diff --git a/cachedir/joblib/run/randomSearch/148b54fe8fe24ea2d46ff3daca90800b/metadata.json b/cachedir/joblib/run/randomSearch/37316eae58a8c74b9165423658201b28/metadata.json similarity index 94% rename from cachedir/joblib/run/randomSearch/148b54fe8fe24ea2d46ff3daca90800b/metadata.json rename to cachedir/joblib/run/randomSearch/37316eae58a8c74b9165423658201b28/metadata.json index a1d083a..afc5f8a 100644 --- a/cachedir/joblib/run/randomSearch/148b54fe8fe24ea2d46ff3daca90800b/metadata.json +++ b/cachedir/joblib/run/randomSearch/37316eae58a8c74b9165423658201b28/metadata.json @@ -1 +1 @@ -{"duration": 5.890570878982544, "input_args": {"XData": " Age Sex Cp Trestbps Chol Fbs Restecg Thalach Exang Oldpeak Slope Ca Thal\n0 63 1 3 145 233 1 0 150 0 2.3 0 0 1\n1 37 1 2 130 250 0 1 187 0 3.5 0 0 2\n2 41 0 1 130 204 0 0 172 0 1.4 2 0 2\n3 56 1 1 120 236 0 1 178 0 0.8 2 0 2\n4 57 0 0 120 354 0 1 163 1 0.6 2 0 2\n.. ... ... .. ... ... ... ... ... ... ... ... .. ...\n298 57 0 0 140 241 0 1 123 1 0.2 1 0 3\n299 45 1 3 110 264 0 1 132 0 1.2 1 0 3\n300 68 1 0 144 193 1 1 141 0 3.4 1 2 3\n301 57 1 0 130 131 0 1 115 1 1.2 1 1 3\n302 57 0 1 130 236 0 0 174 0 0.0 1 1 2\n\n[303 rows x 13 columns]", "yData": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]", "clf": "KNeighborsClassifier(algorithm='kd_tree', leaf_size=30, metric='chebyshev',\n metric_params=None, n_jobs=None, n_neighbors=89, p=2,\n weights='uniform')", "params": "{'n_neighbors': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 'metric': ['chebyshev', 'manhattan', 'euclidean', 'minkowski'], 'algorithm': ['brute', 'kd_tree', 'ball_tree'], 'weights': ['uniform', 'distance']}", "eachAlgor": "'KNN'", "AlgorithmsIDsEnd": "0"}} \ No newline at end of file +{"duration": 7.371565103530884, "input_args": {"XData": " Age Sex Cp Trestbps Chol Fbs Restecg Thalach Exang Oldpeak Slope Ca Thal\n0 63 1 3 145 233 1 0 150 0 2.3 0 0 1\n1 37 1 2 130 250 0 1 187 0 3.5 0 0 2\n2 41 0 1 130 204 0 0 172 0 1.4 2 0 2\n3 56 1 1 120 236 0 1 178 0 0.8 2 0 2\n4 57 0 0 120 354 0 1 163 1 0.6 2 0 2\n.. ... ... .. ... ... ... ... ... ... ... ... .. ...\n298 57 0 0 140 241 0 1 123 1 0.2 1 0 3\n299 45 1 3 110 264 0 1 132 0 1.2 1 0 3\n300 68 1 0 144 193 1 1 141 0 3.4 1 2 3\n301 57 1 0 130 131 0 1 115 1 1.2 1 1 3\n302 57 0 1 130 236 0 0 174 0 0.0 1 1 2\n\n[303 rows x 13 columns]", "yData": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]", "clf": "KNeighborsClassifier(algorithm='kd_tree', leaf_size=30, metric='chebyshev',\n metric_params=None, n_jobs=None, n_neighbors=17, p=2,\n weights='uniform')", "params": "{'n_neighbors': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 'metric': ['chebyshev', 'manhattan', 'euclidean', 'minkowski'], 'algorithm': ['brute', 'kd_tree', 'ball_tree'], 'weights': ['uniform', 'distance']}", "eachAlgor": "'KNN'", "AlgorithmsIDsEnd": "0"}} \ No newline at end of file diff --git a/cachedir/joblib/run/randomSearch/b4f7364f1930f16773596d5d85ded668/output.pkl b/cachedir/joblib/run/randomSearch/b4f7364f1930f16773596d5d85ded668/output.pkl index 9102bcb..962a877 100644 Binary files a/cachedir/joblib/run/randomSearch/b4f7364f1930f16773596d5d85ded668/output.pkl and b/cachedir/joblib/run/randomSearch/b4f7364f1930f16773596d5d85ded668/output.pkl differ diff --git a/cachedir/joblib/run/randomSearch/f7b8e3b85d52717cbc9c9dd04277903e/output.pkl b/cachedir/joblib/run/randomSearch/f7b8e3b85d52717cbc9c9dd04277903e/output.pkl index 63d3059..79881a1 100644 Binary files a/cachedir/joblib/run/randomSearch/f7b8e3b85d52717cbc9c9dd04277903e/output.pkl and b/cachedir/joblib/run/randomSearch/f7b8e3b85d52717cbc9c9dd04277903e/output.pkl differ diff --git a/cachedir/joblib/run/randomSearch/func_code.py b/cachedir/joblib/run/randomSearch/func_code.py index 1375b22..6d5febb 100644 --- a/cachedir/joblib/run/randomSearch/func_code.py +++ b/cachedir/joblib/run/randomSearch/func_code.py @@ -1,4 +1,4 @@ -# first line: 491 +# first line: 501 @memory.cache def randomSearch(XData, yData, clf, params, eachAlgor, AlgorithmsIDsEnd): @@ -64,7 +64,7 @@ def randomSearch(XData, yData, clf, params, eachAlgor, AlgorithmsIDsEnd): clf.fit(XData, yData) yPredict = clf.predict(XData) yPredict = np.nan_to_num(yPredict) - yPredictProb = clf.predict_proba(XData) + yPredictProb = cross_val_predict(clf, XData, yData, cv=crossValidation, method='predict_proba') yPredictProb = np.nan_to_num(yPredictProb) perModelProb.append(yPredictProb.tolist()) diff --git a/frontend/src/components/CrossoverMutationSpace.vue b/frontend/src/components/CrossoverMutationSpace.vue index 5ca1eae..bf809bc 100644 --- a/frontend/src/components/CrossoverMutationSpace.vue +++ b/frontend/src/components/CrossoverMutationSpace.vue @@ -71,7 +71,7 @@ export default { var classifiersInfoProcessing = [] for (let i = 0; i < modelId.length; i++) { - if (i < 10) { + if (i < 100) { classifiersInfoProcessing[i] = 'Model ID: ' + modelId[i] + '
Algorithm: k-nearest neighbor' + '
Parameters: ' + stringParameters[i] } else { diff --git a/frontend/src/components/HyperParameterSpace.vue b/frontend/src/components/HyperParameterSpace.vue index 5d76d0e..d63e766 100644 --- a/frontend/src/components/HyperParameterSpace.vue +++ b/frontend/src/components/HyperParameterSpace.vue @@ -288,6 +288,7 @@ export default { } } EventBus.$emit('RemainingPoints', pushModelsRemainingTemp) + EventBus.$emit('SendSelectedPointsUpdateIndicator', ClassifierIDsList) EventBus.$emit('SendSelectedPointsToServerEvent', ClassifierIDsList) } }) diff --git a/frontend/src/components/Main.vue b/frontend/src/components/Main.vue index 3a49c2c..4156ff3 100755 --- a/frontend/src/components/Main.vue +++ b/frontend/src/components/Main.vue @@ -237,9 +237,6 @@ export default Vue.extend({ OverAllLength: 0, OverSelLengthCM: 0, OverAllLengthCM: 0, - toggle1: 1, - toggle2: 1, - toggle3: 1, modelsUpdate: [], AlgorithmsUpdate: [], SelectedMetricsForModels: [], @@ -254,7 +251,8 @@ export default Vue.extend({ toggleDeepMain: 1, keyLoc: 0, keyData: true, - ClassifierIDsListRemaining: [] + ClassifierIDsListRemaining: [], + PredictSel: [] } }, methods: { @@ -357,7 +355,51 @@ export default Vue.extend({ }) }, SelectedPoints () { - this.OverSelLength = this.ClassifierIDsList.length + this.OverSelLength = this.ClassifierIDsList.length + this.SendSelectedIDs() + }, + SendSelectedIDs () { + const path = `http://127.0.0.1:5000/data/SendtoSeverSelIDs` + const postData = { + predictSelectionIDs: this.ClassifierIDsList + } + const axiosConfig = { + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token', + 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS' + } + } + axios.post(path, postData, axiosConfig) + .then(response => { + console.log('Sent the selected IDs to compute predictions!') + this.retrievePredictionsSel() + }) + .catch(error => { + console.log(error) + }) + }, + retrievePredictionsSel () { + const path = `http://localhost:5000/data/RetrievePredictions` + + const axiosConfig = { + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token', + 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, OPTIONS' + } + } + axios.get(path, axiosConfig) + .then(response => { + this.PredictSel = response.data.PredictSel + console.log('Server successfully sent the predictions!') + EventBus.$emit('SendSelectedPointsToServerEvent', this.PredictSel) + }) + .catch(error => { + console.log(error) + }) }, SendSelectedPointsToServer () { if (this.ClassifierIDsList === ''){ @@ -817,8 +859,8 @@ export default Vue.extend({ EventBus.$on('InitializeCrossoverMutation', this.sendPointsCrossMutat) EventBus.$on('ChangeKey', data => { this.keyNow = data }) - EventBus.$on('SendSelectedPointsToServerEvent', data => { this.ClassifierIDsList = data }) - EventBus.$on('SendSelectedPointsToServerEvent', this.SelectedPoints) + EventBus.$on('SendSelectedPointsUpdateIndicator', data => { this.ClassifierIDsList = data }) + EventBus.$on('SendSelectedPointsUpdateIndicator', this.SelectedPoints) EventBus.$on('sendToServerSelectedScatter', this.SendSelectedPointsToServer) EventBus.$on('SendSelectedDataPointsToServerEvent', data => { this.DataPointsSel = data }) diff --git a/frontend/src/components/Predictions.vue b/frontend/src/components/Predictions.vue index d86556b..248e02c 100644 --- a/frontend/src/components/Predictions.vue +++ b/frontend/src/components/Predictions.vue @@ -22,6 +22,8 @@ export default { GetResultsAll: [], GetResultsSelection: [], responsiveWidthHeight: [], + predictSelection: [], + StoreIndices: [], } }, methods: { @@ -42,8 +44,8 @@ export default { } return idxs; }; - // Clear Heatmap first - var svg = d3.select("#GridView"); + + var svg = d3.select("#containerAll"); svg.selectAll("*").remove(); var yValues = JSON.parse(this.GetResultsAll[6]) @@ -87,9 +89,9 @@ export default { dataLR.push({ id: element, value: LRPred[element][targetNames[i]] }) }); for (let j = 0; j < size - getIndices[targetNames[i]].length; j++) { - dataAver.push({ id: null, value: 0.0 }) - dataKNN.push({ id: null, value: 0.0 }) - dataLR.push({ id: null, value: 0.0 }) + dataAver.push({ id: null, value: 1.0 }) + dataKNN.push({ id: null, value: 1.0 }) + dataLR.push({ id: null, value: 1.0 }) } dataAverGetResults.push(dataAver) dataKNNResults.push(dataKNN) @@ -100,14 +102,15 @@ export default { dataLRResults.reverse() var classArray = [] - + this.StoreIndices = [] for (let i = 0; i < dataAverGetResults.length; i++) { - dataAverGetResults[i].sort((a, b) => (a.value > b.value) ? -1 : 1) + dataAverGetResults[i].sort((a, b) => (a.value > b.value) ? 1 : -1) var len = dataAverGetResults[i].length var indices = new Array(len) for (let j = 0; j < len; j++) { indices[j] = dataAverGetResults[i][j].id; } + this.StoreIndices.push(indices) dataKNNResults[i].sort(function(a, b){ return indices.indexOf(a.id) - indices.indexOf(b.id) @@ -160,7 +163,7 @@ export default { function databind(data, size, sqrtSize) { - colourScale = d3.scaleSequential(d3.interpolateReds).domain(d3.extent(data, function(d) { return d.value; })); + colourScale = d3.scaleSequential(d3.interpolateReds).domain([1, 0]) var join = custom.selectAll('custom.rect') .data(data); @@ -169,11 +172,11 @@ export default { .append('custom') .attr('class', 'rect') .attr('x', function(d, i) { - var x0 = Math.floor(i / 169) % 13, x1 = Math.floor(i % 13); + var x0 = Math.floor(i / size) % sqrtSize, x1 = Math.floor(i % sqrtSize); return groupSpacing * x0 + (cellSpacing + cellSize) * (x1 + x0 * 10); }) .attr('y', function(d, i) { - var y0 = Math.floor(i / 1000), y1 = Math.floor(i % 169 / 13); + var y0 = Math.floor(i / data.length), y1 = Math.floor(i % size / sqrtSize); return groupSpacing * y0 + (cellSpacing + cellSize) * (y1 + y0 * 10); }) .attr('width', 0) @@ -233,10 +236,26 @@ export default { } return idxs; }; - // Clear Heatmap first - var svg = d3.select("#GridView"); + + var svg = d3.select("#containerSelection"); svg.selectAll("*").remove(); + var predictionsAll = JSON.parse(this.GetResultsSelection[12]) + + if (this.predictSelection.length != 0) { + var predictions = this.predictSelection + var KNNPred = predictions[0] + var LRPred = predictions[1] + var PredAver = predictions[2] + } else { + var KNNPred = predictionsAll[0] + var LRPred = predictionsAll[1] + var PredAver = predictionsAll[2] + } + var KNNPredAll = predictionsAll[0] + var LRPredAll = predictionsAll[1] + var PredAverAll = predictionsAll[2] + var yValues = JSON.parse(this.GetResultsSelection[6]) var targetNames = JSON.parse(this.GetResultsSelection[7]) @@ -246,11 +265,6 @@ export default { } getIndices.reverse() - var predictions = JSON.parse(this.GetResultsSelection[12]) - var KNNPred = predictions[0] - var LRPred = predictions[1] - var PredAver = predictions[2] - var dataAver = [] var dataAverGetResults = [] var dataKNN = [] @@ -273,14 +287,14 @@ export default { dataKNN = [] dataLR = [] getIndices[targetNames[i]].forEach(element => { - dataAver.push({ id: element, value: PredAver[element][targetNames[i]] }) - dataKNN.push({ id: element, value: KNNPred[element][targetNames[i]] }) - dataLR.push({ id: element, value: LRPred[element][targetNames[i]] }) + dataAver.push({ id: element, value: PredAver[element][targetNames[i]] - PredAverAll[element][targetNames[i]] }) + dataKNN.push({ id: element, value: KNNPred[element][targetNames[i]] - KNNPredAll[element][targetNames[i]] }) + dataLR.push({ id: element, value: LRPred[element][targetNames[i]] - LRPredAll[element][targetNames[i]] }) }); for (let j = 0; j < size - getIndices[targetNames[i]].length; j++) { - dataAver.push({ id: null, value: 0.0 }) - dataKNN.push({ id: null, value: 0.0 }) - dataLR.push({ id: null, value: 0.0 }) + dataAver.push({ id: null, value: 0 }) + dataKNN.push({ id: null, value: 0 }) + dataLR.push({ id: null, value: 0 }) } dataAverGetResults.push(dataAver) dataKNNResults.push(dataKNN) @@ -293,13 +307,12 @@ export default { var classArray = [] for (let i = 0; i < dataAverGetResults.length; i++) { - dataAverGetResults[i].sort((a, b) => (a.value > b.value) ? -1 : 1) - var len = dataAverGetResults[i].length - var indices = new Array(len) - for (let j = 0; j < len; j++) { - indices[j] = dataAverGetResults[i][j].id; - } + var indices = this.StoreIndices[i] + dataAverGetResults[i].sort(function(a, b){ + return indices.indexOf(a.id) - indices.indexOf(b.id) + }); + dataKNNResults[i].sort(function(a, b){ return indices.indexOf(a.id) - indices.indexOf(b.id) }); @@ -312,7 +325,6 @@ export default { } var classStore = [].concat.apply([], classArray); - // === Set up canvas === // var width = 2500, @@ -351,7 +363,7 @@ export default { function databind(data, size, sqrtSize) { - colourScale = d3.scaleSequential(d3.interpolateReds).domain(d3.extent(data, function(d) { return d.value; })); + colourScale = d3.scaleSequential(d3.interpolatePRGn).domain([-1, 1]) var join = custom.selectAll('custom.rect') .data(data); @@ -360,11 +372,11 @@ export default { .append('custom') .attr('class', 'rect') .attr('x', function(d, i) { - var x0 = Math.floor(i / 169) % 13, x1 = Math.floor(i % 13); + var x0 = Math.floor(i / size) % sqrtSize, x1 = Math.floor(i % sqrtSize); return groupSpacing * x0 + (cellSpacing + cellSize) * (x1 + x0 * 10); }) .attr('y', function(d, i) { - var y0 = Math.floor(i / 1000), y1 = Math.floor(i % 169 / 13); + var y0 = Math.floor(i / data.length), y1 = Math.floor(i % size / sqrtSize); return groupSpacing * y0 + (cellSpacing + cellSize) * (y1 + y0 * 10); }) .attr('width', 0) @@ -421,6 +433,9 @@ export default { EventBus.$on('emittedEventCallingGridSelection', data => { this.GetResultsSelection = data; }) EventBus.$on('emittedEventCallingGridSelection', this.GridSelection) + EventBus.$on('SendSelectedPointsToServerEvent', data => { this.predictSelection = data; }) + EventBus.$on('SendSelectedPointsToServerEvent', this.GridSelection) + EventBus.$on('Responsive', data => { this.responsiveWidthHeight = data}) EventBus.$on('ResponsiveandChange', data => { diff --git a/run.py b/run.py index 1601819..268e583 100644 --- a/run.py +++ b/run.py @@ -18,6 +18,7 @@ from sklearn.model_selection import RandomizedSearchCV from sklearn.model_selection import GridSearchCV from sklearn.neighbors import KNeighborsClassifier from sklearn.linear_model import LogisticRegression +from sklearn.model_selection import cross_val_predict from sklearn.metrics import matthews_corrcoef from sklearn.metrics import log_loss from imblearn.metrics import geometric_mean_score @@ -562,7 +563,7 @@ def randomSearch(XData, yData, clf, params, eachAlgor, AlgorithmsIDsEnd): clf.fit(XData, yData) yPredict = clf.predict(XData) yPredict = np.nan_to_num(yPredict) - yPredictProb = clf.predict_proba(XData) + yPredictProb = cross_val_predict(clf, XData, yData, cv=crossValidation, method='predict_proba') yPredictProb = np.nan_to_num(yPredictProb) perModelProb.append(yPredictProb.tolist()) @@ -615,6 +616,7 @@ def PreprocessingPred(): dfLR = pd.DataFrame.from_dict(dicLR) df_concatProbs = pd.concat([dfKNN, dfLR]) + df_concatProbs.reset_index(drop=True, inplace=True) predictionsKNN = [] for column, content in dfKNN.items(): @@ -814,7 +816,7 @@ def CrossoverMutateFun(): countKNN = 0 countLR = 0 - setMaxLoopValue = 5 + setMaxLoopValue = 50 paramAllAlgs = PreprocessingParam() KNNIntIndex = [] LRIntIndex = [] @@ -873,7 +875,7 @@ def CrossoverMutateFun(): for column in pairDF: listData = [] if (column == 'n_neighbors'): - randomNumber = random.randint(1, math.floor(((len(yData)/crossValidation)*(crossValidation-1)))-1) + randomNumber = random.randint(101, math.floor(((len(yData)/crossValidation)*(crossValidation-1)))-1) listData.append(randomNumber) crossoverDF[column] = listData else: @@ -885,7 +887,7 @@ def CrossoverMutateFun(): else: clf = KNeighborsClassifier() params = {'n_neighbors': [crossoverDF['n_neighbors'].iloc[0]], 'metric': [crossoverDF['metric'].iloc[0]], 'algorithm': [crossoverDF['algorithm'].iloc[0]], 'weights': [crossoverDF['weights'].iloc[0]]} - AlgorithmsIDsEnd = 205 + countKNN + AlgorithmsIDsEnd = 250 + countKNN localCrossMutr = crossoverMutation(XData, yData, clf, params, 'KNN', AlgorithmsIDsEnd) countKNN += 1 crossoverDF = pd.DataFrame() @@ -924,7 +926,7 @@ def CrossoverMutateFun(): else: clf = LogisticRegression(random_state=RANDOM_SEED) params = {'C': [crossoverDF['C'].iloc[0]], 'max_iter': [crossoverDF['max_iter'].iloc[0]], 'solver': [crossoverDF['solver'].iloc[0]], 'penalty': [crossoverDF['penalty'].iloc[0]]} - AlgorithmsIDsEnd = 210 + countLR + AlgorithmsIDsEnd = 300 + countLR localCrossMutr = crossoverMutation(XData, yData, clf, params, 'LR', AlgorithmsIDsEnd) countLR += 1 crossoverDF = pd.DataFrame() @@ -957,7 +959,7 @@ def CrossoverMutateFun(): for column in pairDF: listData = [] if (column == 'C'): - randomNumber = random.randint(1, 100) + randomNumber = random.randint(101, 1000) listData.append(randomNumber) crossoverDF[column] = listData else: @@ -969,7 +971,7 @@ def CrossoverMutateFun(): else: clf = LogisticRegression(random_state=RANDOM_SEED) params = {'C': [crossoverDF['C'].iloc[0]], 'max_iter': [crossoverDF['max_iter'].iloc[0]], 'solver': [crossoverDF['solver'].iloc[0]], 'penalty': [crossoverDF['penalty'].iloc[0]]} - AlgorithmsIDsEnd = 215 + countLR + AlgorithmsIDsEnd = 350 + countLR localCrossMutr = crossoverMutation(XData, yData, clf, params, 'LR', AlgorithmsIDsEnd) countLR += 1 crossoverDF = pd.DataFrame() @@ -1073,7 +1075,7 @@ def crossoverMutation(XData, yData, clf, params, eachAlgor, AlgorithmsIDsEnd): clf.fit(XData, yData) yPredict = clf.predict(XData) yPredict = np.nan_to_num(yPredict) - yPredictProb = clf.predict_proba(XData) + yPredictProb = cross_val_predict(clf, XData, yData, cv=crossValidation, method='predict_proba') yPredictProb = np.nan_to_num(yPredictProb) perModelProb.append(yPredictProb.tolist()) @@ -1298,4 +1300,63 @@ def CrossMutateResults(ModelSpaceMDSCM,ModelSpaceTSNECM,ModelSpaceUMAPCM,Predict ResultsCM.append(json.dumps(ModelSpaceUMAPCM)) ResultsCM.append(json.dumps(PredictionProbSel)) - return Results \ No newline at end of file + return Results + +def PreprocessingPredSel(SelectedIDs): + + numberIDKNN = [] + numberIDLR = [] + for el in SelectedIDs: + match = re.match(r"([a-z]+)([0-9]+)", el, re.I) + if match: + items = match.groups() + if (items[0] == 'KNN'): + numberIDKNN.append(int(items[1])) + else: + numberIDLR.append(int(items[1]) - 100) + + dicKNN = allParametersPerformancePerModel[3] + dicLR = allParametersPerformancePerModel[7] + + dfKNN = pd.DataFrame.from_dict(dicKNN) + dfKNN = dfKNN.loc[numberIDKNN] + dfLR = pd.DataFrame.from_dict(dicLR) + dfLR = dfLR.loc[numberIDLR] + dfLR.index += 100 + df_concatProbs = pd.concat([dfKNN, dfLR]) + + predictionsKNN = [] + for column, content in dfKNN.items(): + el = [sum(x)/len(x) for x in zip(*content)] + predictionsKNN.append(el) + + predictionsLR = [] + for column, content in dfLR.items(): + el = [sum(x)/len(x) for x in zip(*content)] + predictionsLR.append(el) + predictions = [] + for column, content in df_concatProbs.items(): + el = [sum(x)/len(x) for x in zip(*content)] + predictions.append(el) + + return [predictionsKNN, predictionsLR, predictions] + +@cross_origin(origin='localhost',headers=['Content-Type','Authorization']) +@app.route('/data/SendtoSeverSelIDs', methods=["GET", "POST"]) +def RetrieveSelIDsPredict(): + global ResultsSelPred + ResultsSelPred = [] + RetrieveIDsSelection = request.get_data().decode('utf8').replace("'", '"') + RetrieveIDsSelection = json.loads(RetrieveIDsSelection) + RetrieveIDsSelection = RetrieveIDsSelection['predictSelectionIDs'] + ResultsSelPred = PreprocessingPredSel(RetrieveIDsSelection) + + return 'Everything Okay' + +@app.route('/data/RetrievePredictions', methods=["GET", "POST"]) +def SendPredictSel(): + global ResultsSelPred + response = { + 'PredictSel': ResultsSelPred + } + return jsonify(response) \ No newline at end of file