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