|
|
@ -119,6 +119,10 @@ def reset(): |
|
|
|
|
|
|
|
|
|
|
|
global columnsKeep |
|
|
|
global columnsKeep |
|
|
|
columnsKeep = [] |
|
|
|
columnsKeep = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global columnsNewGen |
|
|
|
|
|
|
|
columnsNewGen = [] |
|
|
|
|
|
|
|
|
|
|
|
return 'The reset was done!' |
|
|
|
return 'The reset was done!' |
|
|
|
|
|
|
|
|
|
|
|
# retrieve data from client and select the correct data set |
|
|
|
# retrieve data from client and select the correct data set |
|
|
@ -219,6 +223,9 @@ def retrieveFileName(): |
|
|
|
global columnsKeep |
|
|
|
global columnsKeep |
|
|
|
columnsKeep = [] |
|
|
|
columnsKeep = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
global columnsNewGen |
|
|
|
|
|
|
|
columnsNewGen = [] |
|
|
|
|
|
|
|
|
|
|
|
DataRawLength = -1 |
|
|
|
DataRawLength = -1 |
|
|
|
DataRawLengthTest = -1 |
|
|
|
DataRawLengthTest = -1 |
|
|
|
data = json.loads(fileName) |
|
|
|
data = json.loads(fileName) |
|
|
@ -399,6 +406,7 @@ def dataSetSelection(): |
|
|
|
global keepOriginalFeatures |
|
|
|
global keepOriginalFeatures |
|
|
|
keepOriginalFeatures = XData.copy() |
|
|
|
keepOriginalFeatures = XData.copy() |
|
|
|
keepOriginalFeatures.columns = [str(col) + ' (F'+str(idx+1)+')' for idx, col in enumerate(keepOriginalFeatures.columns)] |
|
|
|
keepOriginalFeatures.columns = [str(col) + ' (F'+str(idx+1)+')' for idx, col in enumerate(keepOriginalFeatures.columns)] |
|
|
|
|
|
|
|
columnsNewGen = keepOriginalFeatures.columns.values.tolist() |
|
|
|
|
|
|
|
|
|
|
|
XData.columns = ['F'+str(idx+1) for idx, col in enumerate(XData.columns)] |
|
|
|
XData.columns = ['F'+str(idx+1) for idx, col in enumerate(XData.columns)] |
|
|
|
|
|
|
|
|
|
|
@ -433,9 +441,18 @@ def executeModel(exeCall, flagEx): |
|
|
|
global XData |
|
|
|
global XData |
|
|
|
global XDataStored |
|
|
|
global XDataStored |
|
|
|
global previousState |
|
|
|
global previousState |
|
|
|
|
|
|
|
global columnsNewGen |
|
|
|
scores = [] |
|
|
|
scores = [] |
|
|
|
|
|
|
|
|
|
|
|
XData = XDataStored.copy() |
|
|
|
if (len(exeCall) == 0): |
|
|
|
|
|
|
|
if (flagEx == 3): |
|
|
|
|
|
|
|
XDataStored = XData.copy() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
XData = XDataStored.copy() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
XData = XDataStored.copy() |
|
|
|
|
|
|
|
columnsNewGen = keepOriginalFeatures.columns.values.tolist() |
|
|
|
|
|
|
|
|
|
|
|
# Bayesian Optimization for 150 iterations |
|
|
|
# Bayesian Optimization for 150 iterations |
|
|
|
if (keyFirstTime): |
|
|
|
if (keyFirstTime): |
|
|
|
create_global_function() |
|
|
|
create_global_function() |
|
|
@ -444,20 +461,23 @@ def executeModel(exeCall, flagEx): |
|
|
|
svc_bayesopt.maximize(init_points=130, n_iter=20, acq='ucb') |
|
|
|
svc_bayesopt.maximize(init_points=130, n_iter=20, acq='ucb') |
|
|
|
bestParams = svc_bayesopt.max['params'] |
|
|
|
bestParams = svc_bayesopt.max['params'] |
|
|
|
estimator = SVC(C=bestParams.get('C'), gamma=bestParams.get('gamma'), probability=True, random_state=RANDOM_SEED) |
|
|
|
estimator = SVC(C=bestParams.get('C'), gamma=bestParams.get('gamma'), probability=True, random_state=RANDOM_SEED) |
|
|
|
featureImportanceData = estimatorFeatureSelection(XData, estimator) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len(exeCall) != 0): |
|
|
|
if (len(exeCall) != 0): |
|
|
|
if (flagEx == 1): |
|
|
|
if (flagEx == 1): |
|
|
|
XData = XData.drop(XData.columns[exeCall], axis=1) |
|
|
|
XData = XData.drop(XData.columns[exeCall], axis=1) |
|
|
|
else: |
|
|
|
elif (flagEx == 2): |
|
|
|
columnsKeepNew = [] |
|
|
|
columnsKeepNew = [] |
|
|
|
columns = XDataGen.columns.values.tolist() |
|
|
|
columns = XDataGen.columns.values.tolist() |
|
|
|
for indx, col in enumerate(columns): |
|
|
|
for indx, col in enumerate(columns): |
|
|
|
if indx in exeCall: |
|
|
|
if indx in exeCall: |
|
|
|
columnsKeepNew.append(col) |
|
|
|
columnsKeepNew.append(col) |
|
|
|
|
|
|
|
columnsNewGen.append(col) |
|
|
|
|
|
|
|
|
|
|
|
XDataTemp = XDataGen[columnsKeepNew] |
|
|
|
XDataTemp = XDataGen[columnsKeepNew] |
|
|
|
XData[columnsKeepNew] = XDataTemp.values |
|
|
|
XData[columnsKeepNew] = XDataTemp.values |
|
|
|
|
|
|
|
print(XDataStored) |
|
|
|
print(XData) |
|
|
|
print(XData) |
|
|
|
|
|
|
|
featureImportanceData = estimatorFeatureSelection(XData, estimator) |
|
|
|
estimator.fit(XData, yData) |
|
|
|
estimator.fit(XData, yData) |
|
|
|
yPredict = estimator.predict(XData) |
|
|
|
yPredict = estimator.predict(XData) |
|
|
|
yPredictProb = cross_val_predict(estimator, XData, yData, cv=crossValidation, method='predict_proba') |
|
|
|
yPredictProb = cross_val_predict(estimator, XData, yData, cv=crossValidation, method='predict_proba') |
|
|
@ -1104,7 +1124,7 @@ def Seperation(): |
|
|
|
global packCorr |
|
|
|
global packCorr |
|
|
|
packCorr = [] |
|
|
|
packCorr = [] |
|
|
|
|
|
|
|
|
|
|
|
packCorr.append(list(keepOriginalFeatures.columns.values.tolist())) |
|
|
|
packCorr.append(json.dumps(columnsNewGen)) |
|
|
|
packCorr.append(json.dumps(target_names)) |
|
|
|
packCorr.append(json.dumps(target_names)) |
|
|
|
packCorr.append(json.dumps(probabilityPredictions)) |
|
|
|
packCorr.append(json.dumps(probabilityPredictions)) |
|
|
|
|
|
|
|
|
|
|
@ -1226,7 +1246,7 @@ def CompareFunPy(): |
|
|
|
feat2 = XDataGen.iloc[:,1] |
|
|
|
feat2 = XDataGen.iloc[:,1] |
|
|
|
XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]] = feat1 + feat2 |
|
|
|
XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]] = feat1 + feat2 |
|
|
|
XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|'] = abs(feat1 - feat2) |
|
|
|
XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|'] = abs(feat1 - feat2) |
|
|
|
XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]] = feat1 + feat2 |
|
|
|
XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]] = feat1 * feat2 |
|
|
|
XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat1 / feat2 |
|
|
|
XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat1 / feat2 |
|
|
|
XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat2 / feat1 |
|
|
|
XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat2 / feat1 |
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]) |
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]) |
|
|
@ -1235,8 +1255,66 @@ def CompareFunPy(): |
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) |
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) |
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) |
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) |
|
|
|
elif (compareMode == 2): |
|
|
|
elif (compareMode == 2): |
|
|
|
pass |
|
|
|
XDataGen = XData[columnsKeepNonOrig] |
|
|
|
|
|
|
|
feat1 = XDataGen.iloc[:,0] |
|
|
|
|
|
|
|
feat2 = XDataGen.iloc[:,1] |
|
|
|
|
|
|
|
feat3 = XDataGen.iloc[:,2] |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]] = feat1 + feat2 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[1]+'+F'+columnsKeepID[2]] = feat2 + feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[2]] = feat1 + feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]+'+F'+columnsKeepID[2]] = feat1 + feat2 + feat3 |
|
|
|
|
|
|
|
XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|'] = abs(feat1 - feat2) |
|
|
|
|
|
|
|
XDataGen['|F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|'] = abs(feat2 - feat3) |
|
|
|
|
|
|
|
XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[2]+'|'] = abs(feat1 - feat3) |
|
|
|
|
|
|
|
XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|'] = abs(feat1 - feat2 - feat3) |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]] = feat1 * feat2 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[1]+'xF'+columnsKeepID[2]] = feat2 * feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[2]] = feat1 * feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]+'xF'+columnsKeepID[2]] = feat1 * feat2 * feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat1 / feat2 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat2 / feat1 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[2]] = feat2 / feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[1]] = feat3 / feat2 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[2]] = feat1 / feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[0]] = feat3 / feat1 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[2]] = feat1 / feat2 / feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[1]] = feat1 / feat3 / feat2 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[0]] = feat2 / feat3 / feat1 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[2]] = feat2 / feat1 / feat3 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat3 / feat1 / feat2 |
|
|
|
|
|
|
|
XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat3 / feat2 / feat1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'+F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]+'+F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|') |
|
|
|
|
|
|
|
columnsKeep.append('|F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|') |
|
|
|
|
|
|
|
columnsKeep.append('|F'+columnsKeepID[0]+'-F'+columnsKeepID[2]+'|') |
|
|
|
|
|
|
|
columnsKeep.append('|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|') |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'xF'+columnsKeepID[1]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'xF'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'xF'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'xF'+columnsKeepID[1]+'xF'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[1]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[0]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[1]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[0]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[2]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) |
|
|
|
|
|
|
|
columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) |
|
|
|
else: |
|
|
|
else: |
|
|
|
pass |
|
|
|
pass |
|
|
|
featureCompareData = estimatorFeatureSelection(XDataGen, estimator) |
|
|
|
featureCompareData = estimatorFeatureSelection(XDataGen, estimator) |
|
|
|
return 'Okay' |
|
|
|
return 'Okay' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cross_origin(origin='localhost',headers=['Content-Type','Authorization']) |
|
|
|
|
|
|
|
@app.route('/data/storeGeneratedFeatures', methods=["GET", "POST"]) |
|
|
|
|
|
|
|
def storeGeneratedFeat(): |
|
|
|
|
|
|
|
executeModel([], 3) |
|
|
|
|
|
|
|
return 'Okay' |