fixed diff pixel based

master
parent 8266eb3ad3
commit 0296b2057d
  1. BIN
      __pycache__/run.cpython-37.pyc
  2. 2
      cachedir/joblib/run/randomSearch/02f4b76834d076f3b2e8a3a6d6a6d0ad/metadata.json
  3. 2
      cachedir/joblib/run/randomSearch/37316eae58a8c74b9165423658201b28/metadata.json
  4. BIN
      cachedir/joblib/run/randomSearch/b4f7364f1930f16773596d5d85ded668/output.pkl
  5. BIN
      cachedir/joblib/run/randomSearch/f7b8e3b85d52717cbc9c9dd04277903e/output.pkl
  6. 4
      cachedir/joblib/run/randomSearch/func_code.py
  7. 2
      frontend/src/components/CrossoverMutationSpace.vue
  8. 1
      frontend/src/components/HyperParameterSpace.vue
  9. 56
      frontend/src/components/Main.vue
  10. 81
      frontend/src/components/Predictions.vue
  11. 79
      run.py

Binary file not shown.

@ -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"}}
{"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"}}

@ -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"}}
{"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"}}

@ -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())

@ -71,7 +71,7 @@ export default {
var classifiersInfoProcessing = []
for (let i = 0; i < modelId.length; i++) {
if (i < 10) {
if (i < 100) {
classifiersInfoProcessing[i] = '<b>Model ID:</b> ' + modelId[i] + '<br><b>Algorithm:</b> k-nearest neighbor' + '<br><b>Parameters:</b> ' + stringParameters[i]
}
else {

@ -288,6 +288,7 @@ export default {
}
}
EventBus.$emit('RemainingPoints', pushModelsRemainingTemp)
EventBus.$emit('SendSelectedPointsUpdateIndicator', ClassifierIDsList)
EventBus.$emit('SendSelectedPointsToServerEvent', ClassifierIDsList)
}
})

@ -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 })

@ -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 => {

@ -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
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)
Loading…
Cancel
Save