parent 68ff2d42b0
commit 9a93d84855
  1. BIN
      __pycache__/run.cpython-38.pyc
  2. BIN
      cachedir/joblib/run/estimatorFeatureSelection/031611c241ba479d18e1372b83d0b576/output.pkl
  3. BIN
      cachedir/joblib/run/estimatorFeatureSelection/08076429e1f4a912207d8f1318e23956/output.pkl
  4. BIN
      cachedir/joblib/run/estimatorFeatureSelection/0ac4b1e38d060ee7705418ad7d40ac9b/output.pkl
  5. 1
      cachedir/joblib/run/estimatorFeatureSelection/1ed1e3543e5b8c0b8ed8273e2b6d737b/metadata.json
  6. BIN
      cachedir/joblib/run/estimatorFeatureSelection/2bc28dfd99c9f6a65f1d74e67cd622bb/output.pkl
  7. 1
      cachedir/joblib/run/estimatorFeatureSelection/2ea39cd41bf1eea844679842787364a7/metadata.json
  8. BIN
      cachedir/joblib/run/estimatorFeatureSelection/2ea39cd41bf1eea844679842787364a7/output.pkl
  9. BIN
      cachedir/joblib/run/estimatorFeatureSelection/3f0623bf82584c5a558248b65b02e98a/output.pkl
  10. BIN
      cachedir/joblib/run/estimatorFeatureSelection/61cd7da84c1bbfd3fb974c2dba5bf7df/output.pkl
  11. 1
      cachedir/joblib/run/estimatorFeatureSelection/6c4a3c6ccc38028fd8eb8e3cafea6fb8/metadata.json
  12. 1
      cachedir/joblib/run/estimatorFeatureSelection/77fea9bd3b261749a4919132a55d4c8b/metadata.json
  13. BIN
      cachedir/joblib/run/estimatorFeatureSelection/7b0a5c188fd9aceb09dfd157de9124db/output.pkl
  14. BIN
      cachedir/joblib/run/estimatorFeatureSelection/883ab89549bbca0bfafb9f9e5a3e0400/output.pkl
  15. 1
      cachedir/joblib/run/estimatorFeatureSelection/8acd1de1317c1ff3977e18a58b7d3733/metadata.json
  16. 1
      cachedir/joblib/run/estimatorFeatureSelection/94da8e9a31bea28d8ff8ea53a406d37b/metadata.json
  17. 1
      cachedir/joblib/run/estimatorFeatureSelection/9902cbfccf20447a3c3f958bc3ba28f0/metadata.json
  18. 1
      cachedir/joblib/run/estimatorFeatureSelection/9a08c17b423b35a0c58bb1d4053f6ab9/metadata.json
  19. 1
      cachedir/joblib/run/estimatorFeatureSelection/a42f327147499bdd5ab86868e8668849/metadata.json
  20. BIN
      cachedir/joblib/run/estimatorFeatureSelection/bb0856b15a01508f89cf610063750776/output.pkl
  21. BIN
      cachedir/joblib/run/estimatorFeatureSelection/c01cd11e96d9a10fbadcce2961183ecd/output.pkl
  22. 1
      cachedir/joblib/run/estimatorFeatureSelection/c5a7d28fb08d1dd352f1a14ab72c2f82/metadata.json
  23. 99
      cachedir/joblib/run/estimatorFeatureSelection/func_code.py
  24. 1
      cachedir/joblib/run/executeModel/12cb5fa7abfa03ab029a92fa8c40616f/metadata.json
  25. BIN
      cachedir/joblib/run/executeModel/12cb5fa7abfa03ab029a92fa8c40616f/output.pkl
  26. 1
      cachedir/joblib/run/executeModel/72a755383fba437e4dead6ff3e3d81e3/metadata.json
  27. BIN
      cachedir/joblib/run/executeModel/72a755383fba437e4dead6ff3e3d81e3/output.pkl
  28. 172
      cachedir/joblib/run/executeModel/func_code.py
  29. 4
      frontend/src/components/DataSetSlider.vue
  30. 2
      frontend/src/components/DataSpace.vue
  31. 40
      frontend/src/components/Export.vue
  32. 2
      frontend/src/components/FeatureSpaceDetail.vue
  33. 44
      frontend/src/components/Knowledge.vue
  34. 89
      frontend/src/components/Main.vue
  35. 9
      frontend/src/components/Results.vue
  36. 4
      frontend/src/main.js
  37. 139
      run.py

Binary file not shown.

@ -0,0 +1 @@
{"duration": 7.470085859298706, "input_args": {"Data": " F1 F2 F3 F4\n0 2.5 3.3 6.3 6.0\n1 1.9 2.7 5.8 5.1\n2 2.1 3.0 7.1 5.9\n3 1.8 2.9 6.3 5.6\n4 2.2 3.0 6.5 5.8\n.. ... ... ... ...\n145 0.3 3.0 4.8 1.4\n146 0.2 3.8 5.1 1.6\n147 0.2 3.2 4.6 1.4\n148 0.2 3.7 5.3 1.5\n149 0.2 3.3 5.0 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=9.044474534604408, gamma=0.1, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 2.0144307613372803, "input_args": {"Data": " F1 F2_mms F3 F4 F1xF3\n0 2.5 0.541667 6.3 6.0 15.75\n1 1.9 0.291667 5.8 5.1 11.02\n2 2.1 0.416667 7.1 5.9 14.91\n3 1.8 0.375000 6.3 5.6 11.34\n4 2.2 0.416667 6.5 5.8 14.30\n.. ... ... ... ... ...\n145 0.3 0.416667 4.8 1.4 1.44\n146 0.2 0.750000 5.1 1.6 1.02\n147 0.2 0.500000 4.6 1.4 0.92\n148 0.2 0.708333 5.3 1.5 1.06\n149 0.2 0.541667 5.0 1.4 1.00\n\n[150 rows x 5 columns]", "clf": "SVC(C=44.03816499590499, gamma=0.01, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 2.988314151763916, "input_args": {"Data": " F1 F2 F3_l10 F4\n0 2.5 3.3 0.298389 6.0\n1 1.9 2.7 0.282605 5.1\n2 2.1 3.0 0.320533 5.9\n3 1.8 2.9 0.298389 5.6\n4 2.2 3.0 0.304254 5.8\n.. ... ... ... ...\n145 0.3 3.0 0.244984 1.4\n146 0.2 3.8 0.257268 1.6\n147 0.2 3.2 0.236226 1.4\n148 0.2 3.7 0.264948 1.5\n149 0.2 3.3 0.253280 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=44.03816499590499, gamma=0.01, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 7.335001707077026, "input_args": {"Data": " F1 F2 F3 F4\n0 2.5 3.3 6.3 6.0\n1 1.9 2.7 5.8 5.1\n2 2.1 3.0 7.1 5.9\n3 1.8 2.9 6.3 5.6\n4 2.2 3.0 6.5 5.8\n.. ... ... ... ...\n145 0.3 3.0 4.8 1.4\n146 0.2 3.8 5.1 1.6\n147 0.2 3.2 4.6 1.4\n148 0.2 3.7 5.3 1.5\n149 0.2 3.3 5.0 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=46.46493418419044, gamma=0.1, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 3.0411131381988525, "input_args": {"Data": " F1 F2 F3_l1p F4\n0 2.5 3.3 1.987874 6.0\n1 1.9 2.7 1.916923 5.1\n2 2.1 3.0 2.091864 5.9\n3 1.8 2.9 1.987874 5.6\n4 2.2 3.0 2.014903 5.8\n.. ... ... ... ...\n145 0.3 3.0 1.757858 1.4\n146 0.2 3.8 1.808289 1.6\n147 0.2 3.2 1.722767 1.4\n148 0.2 3.7 1.840550 1.5\n149 0.2 3.3 1.791759 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=44.03816499590499, gamma=0.01, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 8.3280029296875, "input_args": {"Data": " F1 F2 F3 F4\n0 2.5 3.3 6.3 6.0\n1 1.9 2.7 5.8 5.1\n2 2.1 3.0 7.1 5.9\n3 1.8 2.9 6.3 5.6\n4 2.2 3.0 6.5 5.8\n.. ... ... ... ...\n145 0.3 3.0 4.8 1.4\n146 0.2 3.8 5.1 1.6\n147 0.2 3.2 4.6 1.4\n148 0.2 3.7 5.3 1.5\n149 0.2 3.3 5.0 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=4.407539756085735, gamma=0.1935853267468035, probability=True,\n random_state=42)"}}

@ -0,0 +1 @@
{"duration": 5.4526307582855225, "input_args": {"Data": " F1 F2_mms F3 F4\n0 2.5 0.541667 6.3 6.0\n1 1.9 0.291667 5.8 5.1\n2 2.1 0.416667 7.1 5.9\n3 1.8 0.375000 6.3 5.6\n4 2.2 0.416667 6.5 5.8\n.. ... ... ... ...\n145 0.3 0.416667 4.8 1.4\n146 0.2 0.750000 5.1 1.6\n147 0.2 0.500000 4.6 1.4\n148 0.2 0.708333 5.3 1.5\n149 0.2 0.541667 5.0 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=44.03816499590499, gamma=0.01, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 8.652288913726807, "input_args": {"Data": " F1 F2 F3 F4\n0 2.5 3.3 6.3 6.0\n1 1.9 2.7 5.8 5.1\n2 2.1 3.0 7.1 5.9\n3 1.8 2.9 6.3 5.6\n4 2.2 3.0 6.5 5.8\n.. ... ... ... ...\n145 0.3 3.0 4.8 1.4\n146 0.2 3.8 5.1 1.6\n147 0.2 3.2 4.6 1.4\n148 0.2 3.7 5.3 1.5\n149 0.2 3.3 5.0 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=44.03816499590499, gamma=0.01, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 3.5112879276275635, "input_args": {"Data": " F1 F3 F1+F3 |F1-F3| F1xF3 F1/F3 F3/F1\n0 2.5 6.3 8.8 3.8 15.75 0.396825 2.520000\n1 1.9 5.8 7.7 3.9 11.02 0.327586 3.052632\n2 2.1 7.1 9.2 5.0 14.91 0.295775 3.380952\n3 1.8 6.3 8.1 4.5 11.34 0.285714 3.500000\n4 2.2 6.5 8.7 4.3 14.30 0.338462 2.954545\n.. ... ... ... ... ... ... ...\n145 0.3 4.8 5.1 4.5 1.44 0.062500 16.000000\n146 0.2 5.1 5.3 4.9 1.02 0.039216 25.500000\n147 0.2 4.6 4.8 4.4 0.92 0.043478 23.000000\n148 0.2 5.3 5.5 5.1 1.06 0.037736 26.500000\n149 0.2 5.0 5.2 4.8 1.00 0.040000 25.000000\n\n[150 rows x 7 columns]", "clf": "SVC(C=44.03816499590499, gamma=0.01, probability=True, random_state=42)"}}

@ -0,0 +1 @@
{"duration": 2.5880067348480225, "input_args": {"Data": " F1 F2 F3_l1p F4\n0 2.5 3.3 1.987874 6.0\n1 1.9 2.7 1.916923 5.1\n2 2.1 3.0 2.091864 5.9\n3 1.8 2.9 1.987874 5.6\n4 2.2 3.0 2.014903 5.8\n.. ... ... ... ...\n145 0.3 3.0 1.757858 1.4\n146 0.2 3.8 1.808289 1.6\n147 0.2 3.2 1.722767 1.4\n148 0.2 3.7 1.840550 1.5\n149 0.2 3.3 1.791759 1.4\n\n[150 rows x 4 columns]", "clf": "SVC(C=46.46493418419044, gamma=0.1, probability=True, random_state=42)"}}

@ -0,0 +1,99 @@
# first line: 687
@memory.cache
def estimatorFeatureSelection(Data, clf):
resultsFS = []
permList = []
PerFeatureAccuracy = []
PerFeatureAccuracyAll = []
ImpurityFS = []
RankingFS = []
rf = RandomForestClassifier(n_estimators = 100,
n_jobs = -1,
random_state = RANDOM_SEED)
rf.fit(Data, yData)
importances = rf.feature_importances_
std = np.std([tree.feature_importances_ for tree in rf.estimators_],
axis=0)
maxList = max(importances)
minList = min(importances)
for f in range(Data.shape[1]):
ImpurityFS.append((importances[f] - minList) / (maxList - minList))
estim = LogisticRegression(n_jobs = -1, random_state=RANDOM_SEED)
selector = RFECV(estimator=estim, n_jobs = -1, step=1, cv=crossValidation)
selector = selector.fit(Data, yData)
RFEImp = selector.ranking_
for f in range(Data.shape[1]):
if (RFEImp[f] == 1):
RankingFS.append(0.95)
elif (RFEImp[f] == 2):
RankingFS.append(0.85)
elif (RFEImp[f] == 3):
RankingFS.append(0.75)
elif (RFEImp[f] == 4):
RankingFS.append(0.65)
elif (RFEImp[f] == 5):
RankingFS.append(0.55)
elif (RFEImp[f] == 6):
RankingFS.append(0.45)
elif (RFEImp[f] == 7):
RankingFS.append(0.35)
elif (RFEImp[f] == 8):
RankingFS.append(0.25)
elif (RFEImp[f] == 9):
RankingFS.append(0.15)
else:
RankingFS.append(0.05)
perm = PermutationImportance(clf, cv=None, refit = True, n_iter = 25).fit(Data, yData)
permList.append(perm.feature_importances_)
n_feats = Data.shape[1]
num_cores = multiprocessing.cpu_count()
print("Parallelization Initialized")
flat_results = Parallel(n_jobs=num_cores)(delayed(featFun)(clf,Data.values[:, i].reshape(-1, 1),yData) for i in range(n_feats))
PerFeatureAccuracy = [item for sublist in flat_results for item in sublist]
# for i in range(n_feats):
# scoresHere = model_selection.cross_val_score(clf, Data.values[:, i].reshape(-1, 1), yData, cv=None, n_jobs=-1)
# PerFeatureAccuracy.append(scoresHere.mean())
PerFeatureAccuracyAll.append(PerFeatureAccuracy)
clf.fit(Data, yData)
yPredict = clf.predict(Data)
yPredict = np.nan_to_num(yPredict)
RankingFSDF = pd.DataFrame(RankingFS)
RankingFSDF = RankingFSDF.to_json()
ImpurityFSDF = pd.DataFrame(ImpurityFS)
ImpurityFSDF = ImpurityFSDF.to_json()
perm_imp_eli5PD = pd.DataFrame(permList)
perm_imp_eli5PD = perm_imp_eli5PD.to_json()
PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracyAll)
PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json()
bestfeatures = SelectKBest(score_func=f_classif, k='all')
fit = bestfeatures.fit(Data,yData)
dfscores = pd.DataFrame(fit.scores_)
dfcolumns = pd.DataFrame(Data.columns)
featureScores = pd.concat([dfcolumns,dfscores],axis=1)
featureScores.columns = ['Specs','Score'] #naming the dataframe columns
featureScores = featureScores.to_json()
resultsFS.append(featureScores)
resultsFS.append(ImpurityFSDF)
resultsFS.append(perm_imp_eli5PD)
resultsFS.append(PerFeatureAccuracyPandas)
resultsFS.append(RankingFSDF)
return resultsFS

@ -0,0 +1 @@
{"duration": 13.781832933425903, "input_args": {"exeCall": "[]", "flagEx": "0", "nodeTransfName": "''"}}

@ -1,15 +1,175 @@
# first line: 457 # first line: 473
@memory.cache @memory.cache
def executeModel(): # check this issue later because we are not getting the same results
def executeModel(exeCall, flagEx, nodeTransfName):
create_global_function() global keyFirstTime
global estimator global estimator
global yPredictProb
global scores
global featureImportanceData
global XData
global XDataStored
global previousState
global columnsNewGen
global columnsNames
global listofTransformations
global XDataStoredOriginal
global finalResultsData
columnsNames = []
scores = []
if (len(exeCall) == 0):
if (flagEx == 3):
XDataStored = XData.copy()
else:
XData = XDataStored.copy()
XDataStoredOriginal = XDataStored.copy()
else:
if (flagEx == 4):
XDataStored = XData.copy()
else:
XData = XDataStored.copy()
XDataStoredOriginal = XDataStored.copy()
columnsNewGen = keepOriginalFeatures.columns.values.tolist()
# Bayesian Optimization for 150 iterations
if (keyFirstTime):
create_global_function()
params = {"C": (0.0001, 10000), "gamma": (0.0001, 10000)} params = {"C": (0.0001, 10000), "gamma": (0.0001, 10000)}
svc_bayesopt = BayesianOptimization(estimator, params) svc_bayesopt = BayesianOptimization(estimator, params, random_state=RANDOM_SEED)
svc_bayesopt.maximize(init_points=10, n_iter=25, 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) estimator = SVC(C=bestParams.get('C'), gamma=bestParams.get('gamma'), probability=True, random_state=RANDOM_SEED)
if (len(exeCall) != 0):
if (flagEx == 1):
XData = XData.drop(XData.columns[exeCall], axis=1)
XDataStoredOriginal = XDataStoredOriginal.drop(XDataStoredOriginal.columns[exeCall], axis=1)
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
XDataStoredOriginal[columnsKeepNew] = XDataTemp.values
elif (flagEx == 4):
splittedCol = nodeTransfName.split('_')
XData.rename(columns={ XData.columns[exeCall[0]]: nodeTransfName }, inplace = True)
currentColumn = columnsNewGen[exeCall[0]]
subString = currentColumn[currentColumn.find("(")+1:currentColumn.find(")")]
replacement = currentColumn.replace(subString, nodeTransfName)
storePositions.append(exeCall[0])
storeReplacements.append(replacement)
pos = 0
for repl in storeReplacements:
columnsNewGen[storePositions[pos]] = repl
pos += 1
if (len(splittedCol) == 1):
XData[nodeTransfName] = XDataStoredOriginal[nodeTransfName]
else:
if (splittedCol[1] == 'r'):
XData[nodeTransfName] = XData[nodeTransfName].round()
elif (splittedCol[1] == 'b'):
number_of_bins = np.histogram_bin_edges(XData[nodeTransfName], bins='auto')
emptyLabels = []
for index, number in enumerate(number_of_bins):
if (index == 0):
pass
else:
emptyLabels.append(index)
XData[nodeTransfName] = pd.cut(XData[nodeTransfName], bins=number_of_bins, labels=emptyLabels, include_lowest=True, right=True)
XData[nodeTransfName] = pd.to_numeric(XData[nodeTransfName], downcast='signed')
elif (splittedCol[1] == 'zs'):
zScore = (XData[nodeTransfName]-XData[nodeTransfName].mean())/XData[nodeTransfName].std()
XData[nodeTransfName] = abs(zScore.min()) + zScore
elif (splittedCol[1] == 'mms'):
XData[nodeTransfName] = (XData[nodeTransfName]-XData[nodeTransfName].min())/(XData[nodeTransfName].max()-XData[nodeTransfName].min())
elif (splittedCol[1] == 'l2'):
dfTemp = np.log10(XData[nodeTransfName])
if (dfTemp < 0).values.any():
XData[nodeTransfName] = abs(dfTemp.min()) + dfTemp
else:
XData[nodeTransfName] = dfTemp
elif (splittedCol[1] == 'l1p'):
XData[nodeTransfName] = np.log1p(XData[nodeTransfName])
elif (splittedCol[1] == 'l10'):
dfTemp = np.log10(XData[nodeTransfName])
if (dfTemp < 0).values.any():
XData[nodeTransfName] = abs(dfTemp.min()) + dfTemp
else:
XData[nodeTransfName] = dfTemp
elif (splittedCol[1] == 'e2'):
XData[nodeTransfName] = np.exp2(XData[nodeTransfName])
elif (splittedCol[1] == 'em1'):
XData[nodeTransfName] = np.expm1(XData[nodeTransfName])
elif (splittedCol[1] == 'p2'):
XData[nodeTransfName] = np.power(XData[nodeTransfName], 2)
elif (splittedCol[1] == 'p3'):
XData[nodeTransfName] = np.power(XData[nodeTransfName], 3)
else:
XData[nodeTransfName] = np.power(XData[nodeTransfName], 4)
XDataStored = XData.copy()
columnsNamesLoc = XData.columns.values.tolist()
for col in columnsNamesLoc:
splittedCol = col.split('_')
if (len(splittedCol) == 1):
for tran in listofTransformations:
columnsNames.append(splittedCol[0]+'_'+tran)
else:
for tran in listofTransformations:
if (splittedCol[1] == tran):
columnsNames.append(splittedCol[0])
else:
columnsNames.append(splittedCol[0]+'_'+tran)
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')
print(XData)
num_cores = multiprocessing.cpu_count()
inputsSc = ['accuracy','precision_macro','recall_macro']
flat_results = Parallel(n_jobs=num_cores)(delayed(solve)(estimator,XData,yData,crossValidation,item,index) for index, item in enumerate(inputsSc))
scoresAct = [item for sublist in flat_results for item in sublist]
howMany = 0
if (keyFirstTime):
previousState = scoresAct
keyFirstTime = False
howMany = 3
if (((scoresAct[0]-scoresAct[1]) + (scoresAct[2]-scoresAct[3]) + (scoresAct[4]-scoresAct[5])) >= ((previousState[0]-previousState[1]) + (previousState[2]-previousState[3]) + (previousState[4]-previousState[5]))):
finalResultsData = XData.copy()
print('improved')
if (keyFirstTime == False):
if ((scoresAct[0]-scoresAct[1]) > (previousState[0]-previousState[1])):
previousState[0] = scoresAct[0]
previousState[1] = scoresAct[1]
howMany = howMany + 1
elif ((scoresAct[2]-scoresAct[3]) > (previousState[2]-previousState[3])):
previousState[2] = scoresAct[2]
previousState[3] = scoresAct[3]
howMany = howMany + 1
elif ((scoresAct[4]-scoresAct[5]) > (previousState[4]-previousState[5])):
previousState[4] = scoresAct[4]
previousState[5] = scoresAct[5]
howMany = howMany + 1
else:
pass
scores = scoresAct + previousState
if (howMany == 3):
scores.append(1)
else:
scores.append(0)
return 'Everything Okay'

@ -3,7 +3,7 @@
<b-col cols="2" style="margin-left: -35px"> <b-col cols="2" style="margin-left: -35px">
<label id="data" for="param-dataset" data-toggle="tooltip" data-placement="right" title="Tip: use one of the data sets already provided or upload a new file.">{{ dataset }}</label> <label id="data" for="param-dataset" data-toggle="tooltip" data-placement="right" title="Tip: use one of the data sets already provided or upload a new file.">{{ dataset }}</label>
<select id="selectFile" @change="selectDataSet()"> <select id="selectFile" @change="selectDataSet()">
<option value="BiodegC.csv">Biodegradation</option> <option value="HeartC.csv">Heart disease</option>
<option value="IrisC.csv" selected>Iris flower</option> <option value="IrisC.csv" selected>Iris flower</option>
<option value="local">Upload file</option> <option value="local">Upload file</option>
</select> </select>
@ -54,7 +54,7 @@ export default {
this.defaultDataSet = fileName.options[fileName.selectedIndex].value this.defaultDataSet = fileName.options[fileName.selectedIndex].value
this.defaultDataSet = this.defaultDataSet.split('.')[0] this.defaultDataSet = this.defaultDataSet.split('.')[0]
if (this.defaultDataSet == "BreastC" || this.defaultDataSet == "HeartC" || this.defaultDataSet == "IrisC" || this.defaultDataSet == "BiodegC") { // This is a function that handles a new file, which users can upload. if (this.defaultDataSet == "BiodegC" || this.defaultDataSet == "HeartC" || this.defaultDataSet == "IrisC") { // This is a function that handles a new file, which users can upload.
this.dataset = "Data set" this.dataset = "Data set"
d3.select("#data").select("input").remove(); // Remove the selection field. d3.select("#data").select("input").remove(); // Remove the selection field.
EventBus.$emit('SendToServerDataSetConfirmation', this.defaultDataSet) EventBus.$emit('SendToServerDataSetConfirmation', this.defaultDataSet)

@ -566,7 +566,7 @@ text {
#BeeSwarm { position: absolute; top: 0; left: 0; z-index: 1} #BeeSwarm { position: absolute; top: 0; left: 0; z-index: 1}
#Sliders { position: absolute; top: 0; left: 0; z-index: 2} #Sliders { position: absolute; top: 0; left: 0; z-index: 2}
#NoAction { position: absolute; top: 0; left: 0; z-index: -1} #NoAction { position: absolute; top: 0; left: 0; z-index: -1}
#TextLabels {position: absolute; top: 0; left: 0; z-index: 3} #TextLabels {position: absolute; top: 0; left: 0; z-index: 1}
.active-d3-item { .active-d3-item {
cursor: pointer; cursor: pointer;

@ -0,0 +1,40 @@
<template>
<div id="ExportResults">
=======================================================
<br>
New features: {{ FeaturesPickled }}
<br>
=======================================================
</div>
</template>
<script>
import { EventBus } from '../main.js'
import * as Cryo from 'cryo'
export default {
name: 'Export',
data () {
return {
FeaturesPickled: '',
Features: [],
}
},
methods: {
Pickle () {
this.FeaturesPickled = Cryo.stringify(this.Features)
}
},
mounted () {
EventBus.$on('sendSelectedFeaturestoPickle', data => {
this.Features = data})
EventBus.$on('sendSelectedFeaturestoPickle', this.Pickle)
}
}
</script>
<style scoped>
#ExportResults {
word-break: break-all !important;
}
</style>

@ -95,6 +95,7 @@ export default {
}, },
setLayerExplore() { setLayerExplore() {
console.log('mpike')
this.mode = 0 this.mode = 0
this.KeepIDs = [] this.KeepIDs = []
this.KeepIDTransform = [] this.KeepIDTransform = []
@ -1090,6 +1091,7 @@ export default {
} }
EventBus.$emit('UpdateIDs', IDsGather) EventBus.$emit('UpdateIDs', IDsGather)
if (selectionCounter == 1) { if (selectionCounter == 1) {
EventBus.$emit('diactiveTransform')
EventBus.$emit('Default') EventBus.$emit('Default')
} else if (selectionCounter == 2) { } else if (selectionCounter == 2) {
EventBus.$emit('UpdateIDs', IDsGather) EventBus.$emit('UpdateIDs', IDsGather)

@ -0,0 +1,44 @@
<template>
<h5><button class="btn-outline-custom"
style="float: center;"
id="know"
v-on:click="knowClass">
<font-awesome-icon icon="file-export" />
{{ valueKnowE }}
</button></h5>
</template>
<script>
import { EventBus } from '../main.js'
export default {
name: 'Knowledge',
data () {
return {
valueKnowE: 'Feature extraction'
}
},
methods: {
knowClass () {
EventBus.$emit('OpenModal')
}
}
}
</script>
<style>
.btn-outline-custom {
color: #B15928;
background-color: #FFFFFF;
border-color: #B15928;
}
.btn-outline-custom:hover {
color: #FFFFFF;
background-color: #B15928;
border-color: #B15928;
}
</style>

@ -55,6 +55,7 @@
</mdb-card-header> </mdb-card-header>
<mdb-card-body> <mdb-card-body>
<mdb-card-text class="text-center" style="min-height: 920px"> <mdb-card-text class="text-center" style="min-height: 920px">
<Knowledge/>
<Results/> <Results/>
</mdb-card-text> </mdb-card-text>
</mdb-card-body> </mdb-card-body>
@ -62,6 +63,24 @@
</b-col> </b-col>
</b-row> </b-row>
</b-container> </b-container>
<div class="w3-container">
<div id="myModal" class="w3-modal" style="position: fixed;">
<div class="w3-modal-content w3-card-4 w3-animate-zoom">
<header class="w3-container w3-blue">
<h3 style="display:inline-block; font-size: 16px; margin-top: 15px; margin-bottom:15px">Serialized features using Cryo</h3>
</header>
<Export/>
<div class="w3-container w3-light-grey w3-padding">
<button style="float: right; margin-top: -3px; margin-bottom: -3px"
id="closeModal" class="w3-button w3-right w3-white w3-border"
v-on:click="closeModalFun">
<font-awesome-icon icon="window-close" />
{{ valuePickled }}
</button>
</div>
</div>
</div>
</div>
</body> </body>
</template> </template>
@ -73,6 +92,8 @@ import DataSpace from './DataSpace.vue'
import FeatureSpaceOverview from './FeatureSpaceOverview.vue' import FeatureSpaceOverview from './FeatureSpaceOverview.vue'
import FeatureSpaceDetail from './FeatureSpaceDetail.vue' import FeatureSpaceDetail from './FeatureSpaceDetail.vue'
import Heatmap from './Heatmap.vue' import Heatmap from './Heatmap.vue'
import Export from './Export.vue'
import Knowledge from './Knowledge.vue'
import Results from './Results.vue' import Results from './Results.vue'
import axios from 'axios' import axios from 'axios'
import { loadProgressBar } from 'axios-progress-bar' import { loadProgressBar } from 'axios-progress-bar'
@ -80,8 +101,8 @@ import 'axios-progress-bar/dist/nprogress.css'
import 'bootstrap-css-only/css/bootstrap.min.css' import 'bootstrap-css-only/css/bootstrap.min.css'
import { mdbCard, mdbCardBody, mdbCardText, mdbCardHeader } from 'mdbvue' import { mdbCard, mdbCardBody, mdbCardText, mdbCardHeader } from 'mdbvue'
import { EventBus } from '../main.js' import { EventBus } from '../main.js'
import * as jQuery from 'jquery' import $ from 'jquery'; // <-to import jquery
import $ from 'jquery' import 'bootstrap';
import * as d3Base from 'd3' import * as d3Base from 'd3'
import Papa from 'papaparse' import Papa from 'papaparse'
@ -96,6 +117,8 @@ export default Vue.extend({
FeatureSpaceOverview, FeatureSpaceOverview,
FeatureSpaceDetail, FeatureSpaceDetail,
Heatmap, Heatmap,
Export,
Knowledge,
Results, Results,
mdbCard, mdbCard,
mdbCardBody, mdbCardBody,
@ -104,6 +127,7 @@ export default Vue.extend({
}, },
data () { data () {
return { return {
valuePickled: 'Close',
transformNodesFlag: false, transformNodesFlag: false,
storeDataTransf: [], storeDataTransf: [],
compareNumber: 0, compareNumber: 0,
@ -170,6 +194,27 @@ export default Vue.extend({
closeModalFun () { closeModalFun () {
$('#myModal').modal('hide') $('#myModal').modal('hide')
}, },
openModalCalculate () {
const path = `http://127.0.0.1:5000/data/RequestBestFeatures`
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 => {
var finalResultsData = JSON.parse(response.data.finalResultsData)
EventBus.$emit('sendSelectedFeaturestoPickle', finalResultsData)
console.log('Pickle data successful!')
})
.catch(error => {
console.log(error)
})
},
getCollection () { getCollection () {
this.Collection = this.getCollectionFromBackend() this.Collection = this.getCollectionFromBackend()
}, },
@ -431,7 +476,7 @@ export default Vue.extend({
EventBus.$emit('SlidersCall') EventBus.$emit('SlidersCall')
this.keySlider = false this.keySlider = false
} }
EventBus.$emit('ConfirmDataSet') // REMOVE THAT! //EventBus.$emit('ConfirmDataSet') // REMOVE THAT!
} else { } else {
EventBus.$emit('dataSpace', this.correlResul) EventBus.$emit('dataSpace', this.correlResul)
EventBus.$emit('quad', this.correlResul) EventBus.$emit('quad', this.correlResul)
@ -657,8 +702,35 @@ export default Vue.extend({
window.addEventListener('resize', this.change) window.addEventListener('resize', this.change)
}, },
mounted() { mounted() {
var coll = document.getElementsByClassName("collapsible");
EventBus.$on('storeGeneration', this.storeGenFun) var i;
var flagLocalMounted = true
var flagLocalSkip = true
EventBus.$on('OpenModal', data =>{ flagLocalSkip = false })
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
console.log(flagLocalSkip)
if (flagLocalSkip) {
var content = document.getElementsByClassName("content")
var value = "370px"
for (let j = 0; j < content.length; j++) {
if (content[j].style.display === "block") {
content[j].style.display = "none";
} else {
content[j].style.display = "block";
if (flagLocalMounted) {
content[j].style.display = "none";
}
}
}
flagLocalMounted = false
var combineWH = []
combineWH.push(this.width)
combineWH.push(this.height - 100)
}
flagLocalSkip = true
});
}
var modal = document.getElementById('myModal') var modal = document.getElementById('myModal')
window.onclick = function(event) { window.onclick = function(event) {
@ -684,6 +756,8 @@ export default Vue.extend({
EventBus.$on('CompareThree', data => { this.compareNumber = 2 }) EventBus.$on('CompareThree', data => { this.compareNumber = 2 })
EventBus.$on('CompareThree', this.Compare) EventBus.$on('CompareThree', this.Compare)
EventBus.$on('diactiveTransform', data => { this.transformNodesFlag = true })
EventBus.$on('activeTransform', data => { this.transformNodesFlag = false })
EventBus.$on('Default', this.returnImportance) EventBus.$on('Default', this.returnImportance)
EventBus.$on('updateFeatureImp', this.returnCorrel) EventBus.$on('updateFeatureImp', this.returnCorrel)
@ -751,6 +825,11 @@ export default Vue.extend({
EventBus.$on('flagSpace', data => { this.spaceChange = data }) EventBus.$on('flagSpace', data => { this.spaceChange = data })
EventBus.$on('finalResults', this.openModalCalculate)
EventBus.$on('OpenModal', this.openModalFun)
EventBus.$on('storeGeneration', this.storeGenFun)
//Prevent double click to search for a word. //Prevent double click to search for a word.
document.addEventListener('mousedown', function (event) { document.addEventListener('mousedown', function (event) {
if (event.detail > 1) { if (event.detail > 1) {

@ -37,7 +37,7 @@ export default {
var state = this.globalStep var state = this.globalStep
//console.log('Current Step: ', state) //console.log('Current Step: ', state)
if (state == 1) { if (state == 1) {
this.storeBestSoFarAV = ((parseFloat(this.scoresMean[0]) + parseFloat(this.scoresMean[1]) + parseFloat(this.scoresMean[2])) / 3) this.storeBestSoFarAV = parseFloat(this.scoresMean[0]) + parseFloat(this.scoresMean[1]) + parseFloat(this.scoresMean[2]) - parseFloat(this.scoresSTD[0]) - parseFloat(this.scoresSTD[1]) - parseFloat(this.scoresSTD[2])
} }
var svg = d3.select("#HistoryPlot"); var svg = d3.select("#HistoryPlot");
@ -45,7 +45,7 @@ export default {
var margin = {top: 0, right: 0, bottom: 0, left: 0} var margin = {top: 0, right: 0, bottom: 0, left: 0}
var width = 390 - margin.left - margin.right var width = 390 - margin.left - margin.right
var height = 620 - margin.top - margin.bottom var height = 578 - margin.top - margin.bottom
var padding = 3 var padding = 3
var xLabelHeight = 30 var xLabelHeight = 30
var yLabelWidth = 80 var yLabelWidth = 80
@ -155,10 +155,9 @@ export default {
.duration(duration) .duration(duration)
.attr('r', 0) .attr('r', 0)
.remove() .remove()
if (this.storeBestSoFarAV <= (parseFloat(this.scoresMean[0]) + parseFloat(this.scoresMean[1]) + parseFloat(this.scoresMean[2]) - parseFloat(this.scoresSTD[0]) - parseFloat(this.scoresSTD[1]) - parseFloat(this.scoresSTD[2]))) {
if (this.storeBestSoFarAV <= ((parseFloat(this.scoresMean[0]) + parseFloat(this.scoresMean[1]) + parseFloat(this.scoresMean[2])) / 3)) {
this.flag = true this.flag = true
this.storeBestSoFarAV = ((parseFloat(this.scoresMean[0]) + parseFloat(this.scoresMean[1]) + parseFloat(this.scoresMean[2])) / 3) this.storeBestSoFarAV = parseFloat(this.scoresMean[0]) + parseFloat(this.scoresMean[1]) + parseFloat(this.scoresMean[2]) - parseFloat(this.scoresSTD[0]) - parseFloat(this.scoresSTD[1]) - parseFloat(this.scoresSTD[2])
} }
var previously = this.previousState var previously = this.previousState

@ -6,10 +6,10 @@ import 'bootstrap-vue/dist/bootstrap-vue.css'
import router from './router' import router from './router'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faDna, faSearch, faTrash, faBalanceScale , faWrench } from '@fortawesome/free-solid-svg-icons' import { faDna, faSearch, faTrash, faBalanceScale , faWrench, faFileExport, faWindowClose} from '@fortawesome/free-solid-svg-icons'
import bFormSlider from 'vue-bootstrap-slider' import bFormSlider from 'vue-bootstrap-slider'
library.add(faDna, faSearch, faTrash, faBalanceScale, faWrench) library.add(faDna, faSearch, faTrash, faBalanceScale, faWrench, faFileExport, faWindowClose)
Vue.component('font-awesome-icon', FontAwesomeIcon) Vue.component('font-awesome-icon', FontAwesomeIcon)

139
run.py

@ -23,7 +23,7 @@ from sklearn.preprocessing import OneHotEncoder
from sklearn.metrics import classification_report from sklearn.metrics import classification_report
from sklearn.feature_selection import mutual_info_classif from sklearn.feature_selection import mutual_info_classif
from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2 from sklearn.feature_selection import f_classif
from sklearn.feature_selection import RFECV from sklearn.feature_selection import RFECV
from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression from sklearn.linear_model import LogisticRegression
@ -53,7 +53,7 @@ def reset():
global DataRawLength global DataRawLength
global DataResultsRaw global DataResultsRaw
global previousState global previousState
previousState = [] previousState = []\
global filterActionFinal global filterActionFinal
filterActionFinal = '' filterActionFinal = ''
@ -85,6 +85,9 @@ def reset():
global yDataStored global yDataStored
yDataStored = [] yDataStored = []
global finalResultsData
finalResultsData = []
global detailsParams global detailsParams
detailsParams = [] detailsParams = []
@ -133,6 +136,9 @@ def reset():
global columnsNames global columnsNames
columnsNames = [] columnsNames = []
global fileName
fileName = []
global listofTransformations global listofTransformations
listofTransformations = ["r","b","zs","mms","l2","l1p","l10","e2","em1","p2","p3","p4"] listofTransformations = ["r","b","zs","mms","l2","l1p","l10","e2","em1","p2","p3","p4"]
@ -152,6 +158,8 @@ def retrieveFileName():
storePositions = [] storePositions = []
storeReplacements = [] storeReplacements = []
global fileName
fileName = []
fileName = request.get_data().decode('utf8').replace("'", '"') fileName = request.get_data().decode('utf8').replace("'", '"')
global keySpecInternal global keySpecInternal
@ -187,8 +195,8 @@ def retrieveFileName():
global yDataStored global yDataStored
yDataStored = [] yDataStored = []
global filterDataFinal global finalResultsData
filterDataFinal = 'mean' finalResultsData = []
global ClassifierIDsList global ClassifierIDsList
ClassifierIDsList = '' ClassifierIDsList = ''
@ -249,25 +257,25 @@ def retrieveFileName():
global listofTransformations global listofTransformations
listofTransformations = ["r","b","zs","mms","l2","l1p","l10","e2","em1","p2","p3","p4"] listofTransformations = ["r","b","zs","mms","l2","l1p","l10","e2","em1","p2","p3","p4"]
print('data set:',fileName)
DataRawLength = -1 DataRawLength = -1
DataRawLengthTest = -1 DataRawLengthTest = -1
data = json.loads(fileName) data = json.loads(fileName)
if data['fileName'] == 'HeartC': if data['fileName'] == 'HeartC':
CollectionDB = mongo.db.HeartC.find() CollectionDB = mongo.db.HeartC.find()
names_labels.append('Healthy') target_names.append('Healthy')
names_labels.append('Diseased') target_names.append('Diseased')
elif data['fileName'] == 'BiodegC': elif data['fileName'] == 'BiodegC':
StanceTest = True StanceTest = True
CollectionDB = mongo.db.biodegC.find() CollectionDB = mongo.db.biodegC.find()
CollectionDBTest = mongo.db.biodegCTest.find() CollectionDBTest = mongo.db.biodegCTest.find()
CollectionDBExternal = mongo.db.biodegCExt.find() CollectionDBExternal = mongo.db.biodegCExt.find()
names_labels.append('Non-biodegradable') target_names.append('Non-biodegradable')
names_labels.append('Biodegradable') target_names.append('Biodegradable')
elif data['fileName'] == 'BreastC': elif data['fileName'] == 'BreastC':
CollectionDB = mongo.db.diabetesC.find() CollectionDB = mongo.db.breastC.find()
names_labels.append('Malignant') target_names.append('Malignant')
names_labels.append('Benign') target_names.append('Benign')
else: else:
CollectionDB = mongo.db.IrisC.find() CollectionDB = mongo.db.IrisC.find()
DataResultsRaw = [] DataResultsRaw = []
@ -317,17 +325,26 @@ def sendToServerData():
AllTargets = [o[target] for o in DataResultsRaw] AllTargets = [o[target] for o in DataResultsRaw]
AllTargetsFloatValues = [] AllTargetsFloatValues = []
global fileName
data = json.loads(fileName)
previous = None previous = None
Class = 0 Class = 0
for i, value in enumerate(AllTargets): for i, value in enumerate(AllTargets):
if (i == 0): if (i == 0):
previous = value previous = value
if (data['fileName'] == 'IrisC'):
target_names.append(value) target_names.append(value)
else:
pass
if (value == previous): if (value == previous):
AllTargetsFloatValues.append(Class) AllTargetsFloatValues.append(Class)
else: else:
Class = Class + 1 Class = Class + 1
if (data['fileName'] == 'IrisC'):
target_names.append(value) target_names.append(value)
else:
pass
AllTargetsFloatValues.append(Class) AllTargetsFloatValues.append(Class)
previous = value previous = value
@ -342,6 +359,10 @@ def sendToServerData():
global XDataStoredOriginal global XDataStoredOriginal
XDataStoredOriginal = XData.copy() XDataStoredOriginal = XData.copy()
global finalResultsData
finalResultsData = XData.copy()
return 'Processed uploaded data set' return 'Processed uploaded data set'
def dataSetSelection(): def dataSetSelection():
@ -410,17 +431,26 @@ def dataSetSelection():
AllTargets = [o[target] for o in DataResultsRaw] AllTargets = [o[target] for o in DataResultsRaw]
AllTargetsFloatValues = [] AllTargetsFloatValues = []
global fileName
data = json.loads(fileName)
previous = None previous = None
Class = 0 Class = 0
for i, value in enumerate(AllTargets): for i, value in enumerate(AllTargets):
if (i == 0): if (i == 0):
previous = value previous = value
if (data['fileName'] == 'IrisC'):
target_names.append(value) target_names.append(value)
else:
pass
if (value == previous): if (value == previous):
AllTargetsFloatValues.append(Class) AllTargetsFloatValues.append(Class)
else: else:
Class = Class + 1 Class = Class + 1
if (data['fileName'] == 'IrisC'):
target_names.append(value) target_names.append(value)
else:
pass
AllTargetsFloatValues.append(Class) AllTargetsFloatValues.append(Class)
previous = value previous = value
@ -443,6 +473,9 @@ def dataSetSelection():
global XDataStoredOriginal global XDataStoredOriginal
XDataStoredOriginal = XData.copy() XDataStoredOriginal = XData.copy()
global finalResultsData
finalResultsData = XData.copy()
warnings.simplefilter('ignore') warnings.simplefilter('ignore')
executeModel([], 0, '') executeModel([], 0, '')
@ -474,6 +507,7 @@ def executeModel(exeCall, flagEx, nodeTransfName):
global columnsNames global columnsNames
global listofTransformations global listofTransformations
global XDataStoredOriginal global XDataStoredOriginal
global finalResultsData
columnsNames = [] columnsNames = []
scores = [] scores = []
@ -490,12 +524,12 @@ def executeModel(exeCall, flagEx, nodeTransfName):
XData = XDataStored.copy() XData = XDataStored.copy()
XDataStoredOriginal = XDataStored.copy() XDataStoredOriginal = XDataStored.copy()
columnsNewGen = keepOriginalFeatures.columns.values.tolist() columnsNewGen = keepOriginalFeatures.columns.values.tolist()
# Bayesian Optimization for 150 iterations # Bayesian Optimization for 50 iterations
if (keyFirstTime): if (keyFirstTime):
create_global_function() create_global_function()
params = {"C": (0.0001, 10000), "gamma": (0.0001, 10000)} params = {"C": (0.01, 100), "gamma": (0.01, 100)}
svc_bayesopt = BayesianOptimization(estimator, params, random_state=RANDOM_SEED) svc_bayesopt = BayesianOptimization(estimator, params, random_state=RANDOM_SEED)
svc_bayesopt.maximize(init_points=130, n_iter=20, acq='ucb') svc_bayesopt.maximize(init_points=30, 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)
@ -546,11 +580,17 @@ def executeModel(exeCall, flagEx, nodeTransfName):
elif (splittedCol[1] == 'mms'): elif (splittedCol[1] == 'mms'):
XData[nodeTransfName] = (XData[nodeTransfName]-XData[nodeTransfName].min())/(XData[nodeTransfName].max()-XData[nodeTransfName].min()) XData[nodeTransfName] = (XData[nodeTransfName]-XData[nodeTransfName].min())/(XData[nodeTransfName].max()-XData[nodeTransfName].min())
elif (splittedCol[1] == 'l2'): elif (splittedCol[1] == 'l2'):
XData[nodeTransfName] = np.log2(XData[nodeTransfName]) dfTemp = np.log2(XData[nodeTransfName])
dfTemp = dfTemp.replace(np.inf, 1.7976931348623157e+308)
dfTemp = dfTemp.replace(-np.inf, 2.2250738585072014e-308)
XData[nodeTransfName] = dfTemp
elif (splittedCol[1] == 'l1p'): elif (splittedCol[1] == 'l1p'):
XData[nodeTransfName] = np.log1p(XData[nodeTransfName]) XData[nodeTransfName] = np.log1p(XData[nodeTransfName])
elif (splittedCol[1] == 'l10'): elif (splittedCol[1] == 'l10'):
XData[nodeTransfName] = np.log10(XData[nodeTransfName]) dfTemp = np.log10(XData[nodeTransfName])
dfTemp = dfTemp.replace(np.inf, 1.7976931348623157e+308)
dfTemp = dfTemp.replace(-np.inf, 2.2250738585072014e-308)
XData[nodeTransfName] = dfTemp
elif (splittedCol[1] == 'e2'): elif (splittedCol[1] == 'e2'):
XData[nodeTransfName] = np.exp2(XData[nodeTransfName]) XData[nodeTransfName] = np.exp2(XData[nodeTransfName])
elif (splittedCol[1] == 'em1'): elif (splittedCol[1] == 'em1'):
@ -580,7 +620,7 @@ def executeModel(exeCall, flagEx, nodeTransfName):
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')
print(XData)
num_cores = multiprocessing.cpu_count() num_cores = multiprocessing.cpu_count()
inputsSc = ['accuracy','precision_macro','recall_macro'] inputsSc = ['accuracy','precision_macro','recall_macro']
@ -593,7 +633,12 @@ def executeModel(exeCall, flagEx, nodeTransfName):
previousState = scoresAct previousState = scoresAct
keyFirstTime = False keyFirstTime = False
howMany = 3 howMany = 3
else:
if (((scoresAct[0]-scoresAct[1]) + (scoresAct[2]-scoresAct[3]) + (scoresAct[4]-scoresAct[5])) >= ((previousState[0]-previousState[1]) + (previousState[2]-previousState[3]) + (previousState[4]-previousState[5]))):
finalResultsData = XData.copy()
print('improved')
if (keyFirstTime == False):
if ((scoresAct[0]-scoresAct[1]) > (previousState[0]-previousState[1])): if ((scoresAct[0]-scoresAct[1]) > (previousState[0]-previousState[1])):
previousState[0] = scoresAct[0] previousState[0] = scoresAct[0]
previousState[1] = scoresAct[1] previousState[1] = scoresAct[1]
@ -610,6 +655,7 @@ def executeModel(exeCall, flagEx, nodeTransfName):
pass pass
scores = scoresAct + previousState scores = scoresAct + previousState
if (howMany == 3): if (howMany == 3):
scores.append(1) scores.append(1)
else: else:
@ -617,6 +663,28 @@ def executeModel(exeCall, flagEx, nodeTransfName):
return 'Everything Okay' return 'Everything Okay'
@app.route('/data/RequestBestFeatures', methods=["GET", "POST"])
def BestFeat():
global finalResultsData
finalResultsDataJSON = finalResultsData.to_json()
response = {
'finalResultsData': finalResultsDataJSON
}
return jsonify(response)
def featFun (clfLocalPar,DataLocalPar,yDataLocalPar):
PerFeatureAccuracyLocalPar = []
scores = model_selection.cross_val_score(clfLocalPar, DataLocalPar, yDataLocalPar, cv=None, n_jobs=-1)
PerFeatureAccuracyLocalPar.append(scores.mean())
return PerFeatureAccuracyLocalPar
location = './cachedir'
memory = Memory(location, verbose=0)
# calculating for all algorithms and models the performance and other results
@memory.cache
def estimatorFeatureSelection(Data, clf): def estimatorFeatureSelection(Data, clf):
resultsFS = [] resultsFS = []
@ -670,13 +738,17 @@ def estimatorFeatureSelection(Data, clf):
else: else:
RankingFS.append(0.05) RankingFS.append(0.05)
perm = PermutationImportance(clf, cv = None, refit = True, n_iter = 25).fit(Data, yData) perm = PermutationImportance(clf, cv=None, refit = True, n_iter = 25).fit(Data, yData)
permList.append(perm.feature_importances_) permList.append(perm.feature_importances_)
n_feats = Data.shape[1] n_feats = Data.shape[1]
PerFeatureAccuracy = []
for i in range(n_feats): num_cores = multiprocessing.cpu_count()
scores = model_selection.cross_val_score(clf, Data.values[:, i].reshape(-1, 1), yData, cv=crossValidation) print("Parallelization Initialized")
PerFeatureAccuracy.append(scores.mean()) flat_results = Parallel(n_jobs=num_cores)(delayed(featFun)(clf,Data.values[:, i].reshape(-1, 1),yData) for i in range(n_feats))
PerFeatureAccuracy = [item for sublist in flat_results for item in sublist]
# for i in range(n_feats):
# scoresHere = model_selection.cross_val_score(clf, Data.values[:, i].reshape(-1, 1), yData, cv=None, n_jobs=-1)
# PerFeatureAccuracy.append(scoresHere.mean())
PerFeatureAccuracyAll.append(PerFeatureAccuracy) PerFeatureAccuracyAll.append(PerFeatureAccuracy)
clf.fit(Data, yData) clf.fit(Data, yData)
@ -695,7 +767,7 @@ def estimatorFeatureSelection(Data, clf):
PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracyAll) PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracyAll)
PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json() PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json()
bestfeatures = SelectKBest(score_func=chi2, k='all') bestfeatures = SelectKBest(score_func=f_classif, k='all')
fit = bestfeatures.fit(Data,yData) fit = bestfeatures.fit(Data,yData)
dfscores = pd.DataFrame(fit.scores_) dfscores = pd.DataFrame(fit.scores_)
dfcolumns = pd.DataFrame(Data.columns) dfcolumns = pd.DataFrame(Data.columns)
@ -854,7 +926,10 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4, quadrant5):
else: else:
d={} d={}
XDataNumericCopy = XDataNumeric.copy() XDataNumericCopy = XDataNumeric.copy()
XDataNumericCopy[i] = np.log2(XDataNumericCopy[i]) dfTemp = np.log2(XDataNumericCopy[i])
dfTemp = dfTemp.replace(np.inf, 1.7976931348623157e+308)
dfTemp = dfTemp.replace(-np.inf, 2.2250738585072014e-308)
XDataNumericCopy[i] = dfTemp
for number in range(1,6): for number in range(1,6):
quadrantVariable = str('quadrant%s' % number) quadrantVariable = str('quadrant%s' % number)
illusion = locals()[quadrantVariable] illusion = locals()[quadrantVariable]
@ -890,7 +965,10 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4, quadrant5):
else: else:
d={} d={}
XDataNumericCopy = XDataNumeric.copy() XDataNumericCopy = XDataNumeric.copy()
XDataNumericCopy[i] = np.log10(XDataNumericCopy[i]) dfTemp = np.log10(XDataNumericCopy[i])
dfTemp = dfTemp.replace(np.inf, 1.7976931348623157e+308)
dfTemp = dfTemp.replace(-np.inf, 2.2250738585072014e-308)
XDataNumericCopy[i] = dfTemp
for number in range(1,6): for number in range(1,6):
quadrantVariable = str('quadrant%s' % number) quadrantVariable = str('quadrant%s' % number)
illusion = locals()[quadrantVariable] illusion = locals()[quadrantVariable]
@ -991,6 +1069,13 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4, quadrant5):
return 'Everything Okay' return 'Everything Okay'
def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, DataRows5, quadrant1, quadrant2, quadrant3, quadrant4, quadrant5, feature, count): def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, DataRows5, quadrant1, quadrant2, quadrant3, quadrant4, quadrant5, feature, count):
print(DataRows1)
print(DataRows2)
print(DataRows3)
print(DataRows4)
print(DataRows5)
corrMatrix1 = DataRows1.corr() corrMatrix1 = DataRows1.corr()
corrMatrix1 = corrMatrix1.abs() corrMatrix1 = corrMatrix1.abs()
corrMatrix2 = DataRows2.corr() corrMatrix2 = DataRows2.corr()

Loading…
Cancel
Save