Angelos Chatzimparmpas 4 years ago
parent 03deab186f
commit e3a4a400b3
  1. BIN
      __pycache__/run.cpython-37.pyc
  2. 11
      frontend/src/components/Main.vue
  3. 484
      run.py

Binary file not shown.

@ -18,7 +18,7 @@
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<mdb-card> <mdb-card>
<mdb-card-header color="primary-color" tag="h5" class="text-center">Provenance</mdb-card-header> <mdb-card-header color="primary-color" tag="h5" class="text-center">History and Algorithms/Models Selector</mdb-card-header>
<mdb-card-body> <mdb-card-body>
<mdb-card-text class="text-left" style="font-size: 18.5px; min-height: 359px"> <mdb-card-text class="text-left" style="font-size: 18.5px; min-height: 359px">
</mdb-card-text> </mdb-card-text>
@ -27,7 +27,7 @@
</b-col> </b-col>
<b-col cols="3"> <b-col cols="3">
<mdb-card > <mdb-card >
<mdb-card-header color="primary-color" tag="h5" class="text-center">Majority-Voting Ensemble's Results</mdb-card-header> <mdb-card-header color="primary-color" tag="h5" class="text-center">Final Results of Majority-Voting Ensemble </mdb-card-header>
<mdb-card-body> <mdb-card-body>
<mdb-card-text class="text-left" style="font-size: 18.5px; min-height: 359px"> <mdb-card-text class="text-left" style="font-size: 18.5px; min-height: 359px">
</mdb-card-text> </mdb-card-text>
@ -119,7 +119,7 @@
<b-row class="md-3"> <b-row class="md-3">
<b-col cols="6"> <b-col cols="6">
<mdb-card style="margin-top: 15px;"> <mdb-card style="margin-top: 15px;">
<mdb-card-header color="primary-color" tag="h5" class="text-center">Hyper-Parameters' Space <mdb-card-header color="primary-color" tag="h5" class="text-center">Solution Space of Hyper-Parameters
[Sel: {{OverSelLength}} / All: {{OverAllLength}}]<small class="float-right"><active-scatter/></small><span class="badge badge-info badge-pill float-right">Projection<span class="badge badge-light" style="margin-left:4px; margin-bottom:1px">1</span></span> [Sel: {{OverSelLength}} / All: {{OverAllLength}}]<small class="float-right"><active-scatter/></small><span class="badge badge-info badge-pill float-right">Projection<span class="badge badge-light" style="margin-left:4px; margin-bottom:1px">1</span></span>
</mdb-card-header> </mdb-card-header>
<mdb-card-body> <mdb-card-body>
@ -145,7 +145,7 @@
<b-row class="md-3"> <b-row class="md-3">
<b-col cols="3"> <b-col cols="3">
<mdb-card style="margin-top: 15px;"> <mdb-card style="margin-top: 15px;">
<mdb-card-header color="primary-color" tag="h5" class="text-center">Manipulation of Algorithms<span class="badge badge-primary badge-pill float-right">Active<span class="badge badge-light" style="margin-left:4px; margin-bottom:1px">1&2</span></span> <mdb-card-header color="primary-color" tag="h5" class="text-center">Overall Performance for Each Algorithm/Model<span class="badge badge-primary badge-pill float-right">Active<span class="badge badge-light" style="margin-left:4px; margin-bottom:1px">1&2</span></span>
</mdb-card-header> </mdb-card-header>
<mdb-card-body> <mdb-card-body>
<mdb-card-text class="text-center" style="min-height: 270px"> <mdb-card-text class="text-center" style="min-height: 270px">
@ -921,6 +921,7 @@ export default Vue.extend({
console.log('Sent the unselected points for crossover and mutation.') console.log('Sent the unselected points for crossover and mutation.')
this.getDatafromtheBackEnd() this.getDatafromtheBackEnd()
this.getCMComputedData() this.getCMComputedData()
this.changeActiveTo2()
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
@ -979,7 +980,7 @@ export default Vue.extend({
EventBus.$on('RemainingPoints', this.changeActiveTo1) EventBus.$on('RemainingPoints', this.changeActiveTo1)
EventBus.$on('RemainingPoints', data => { this.unselectedRemainingPoints = data }) EventBus.$on('RemainingPoints', data => { this.unselectedRemainingPoints = data })
EventBus.$on('InitializeCrossoverMutation', this.changeActiveTo2)
EventBus.$on('InitializeCrossoverMutation', this.sendPointsCrossMutat) EventBus.$on('InitializeCrossoverMutation', this.sendPointsCrossMutat)
EventBus.$on('RemainingPointsCM', this.changeActiveTo2) EventBus.$on('RemainingPointsCM', this.changeActiveTo2)

484
run.py

@ -301,27 +301,15 @@ def retrieveFileName():
# models # models
global KNNModels global KNNModels
global SVCModels
global GausNBModels
global MLPModels global MLPModels
global LRModels global LRModels
global LDAModels
global QDAModels
global RFModels global RFModels
global ExtraTModels
global AdaBModels
global GradBModels global GradBModels
KNNModels = [] KNNModels = []
SVCModels = []
GausNBModels = []
MLPModels = [] MLPModels = []
LRModels = [] LRModels = []
LDAModels = []
QDAModels = []
RFModels = [] RFModels = []
ExtraTModels = []
AdaBModels = []
GradBModels = [] GradBModels = []
global results global results
@ -1051,12 +1039,15 @@ def CrossoverMutateFun():
EnsembleActive = json.loads(EnsembleActive) EnsembleActive = json.loads(EnsembleActive)
EnsembleActive = EnsembleActive['StoreEnsemble'] EnsembleActive = EnsembleActive['StoreEnsemble']
random.seed(RANDOM_SEED)
global XData global XData
global yData global yData
global LRModelsCount
global addKNN global addKNN
global addLR global addLR
global addMLP
global addRF
global addGradB
global countAllModels global countAllModels
# loop through the algorithms # loop through the algorithms
@ -1066,14 +1057,23 @@ def CrossoverMutateFun():
KNNIDs = list(filter(lambda k: 'KNN' in k, RemainingIds)) KNNIDs = list(filter(lambda k: 'KNN' in k, RemainingIds))
LRIDs = list(filter(lambda k: 'LR' in k, RemainingIds)) LRIDs = list(filter(lambda k: 'LR' in k, RemainingIds))
MLPIDs = list(filter(lambda k: 'MLP' in k, RemainingIds))
RFIDs = list(filter(lambda k: 'RF' in k, RemainingIds))
GradBIDs = list(filter(lambda k: 'GradB' in k, RemainingIds))
countKNN = 0 countKNN = 0
countLR = 0 countLR = 0
countMLP = 0
countRF = 0
countGradB = 0
setMaxLoopValue = 5 setMaxLoopValue = 5
paramAllAlgs = PreprocessingParam() paramAllAlgs = PreprocessingParam()
KNNIntIndex = [] KNNIntIndex = []
LRIntIndex = [] LRIntIndex = []
MLPIntIndex = []
RFIntIndex = []
GradBIntIndex = []
localCrossMutr = [] localCrossMutr = []
allParametersPerfCrossMutrKNNC = [] allParametersPerfCrossMutrKNNC = []
@ -1099,7 +1099,7 @@ def CrossoverMutateFun():
countKNN += 1 countKNN += 1
crossoverDF = pd.DataFrame() crossoverDF = pd.DataFrame()
countAllModels = countAllModels + 5 countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1): for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4] localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
@ -1146,7 +1146,7 @@ def CrossoverMutateFun():
countKNN += 1 countKNN += 1
crossoverDF = pd.DataFrame() crossoverDF = pd.DataFrame()
countAllModels = countAllModels + 5 countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1): for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4] localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
@ -1187,7 +1187,7 @@ def CrossoverMutateFun():
countLR += 1 countLR += 1
crossoverDF = pd.DataFrame() crossoverDF = pd.DataFrame()
countAllModels = countAllModels + 5 countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1): for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4] localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
@ -1234,7 +1234,7 @@ def CrossoverMutateFun():
countLR += 1 countLR += 1
crossoverDF = pd.DataFrame() crossoverDF = pd.DataFrame()
countAllModels = countAllModels + 5 countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1): for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4] localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
@ -1248,12 +1248,277 @@ def CrossoverMutateFun():
allParametersPerfCrossMutrLRM.append(localCrossMutr[3]) allParametersPerfCrossMutrLRM.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrLRM HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrLRM
localCrossMutr.clear()
allParametersPerfCrossMutrMLPC = []
while countMLP < setMaxLoopValue:
for dr in MLPIDs:
MLPIntIndex.append(int(re.findall('\d+', dr)[0]))
MLPPickPair = random.sample(MLPIntIndex,2)
pairDF = paramAllAlgs.iloc[MLPPickPair]
crossoverDF = pd.DataFrame()
for column in pairDF:
listData = []
randomZeroOne = random.randint(0, 1)
valuePerColumn = pairDF[column].iloc[randomZeroOne]
listData.append(valuePerColumn)
crossoverDF[column] = listData
if (((paramAllAlgs['hidden_layer_sizes'] == crossoverDF['hidden_layer_sizes'].iloc[0]) & (paramAllAlgs['alpha'] == crossoverDF['alpha'].iloc[0]) & (paramAllAlgs['tol'] == crossoverDF['tol'].iloc[0]) & (paramAllAlgs['max_iter'] == crossoverDF['max_iter'].iloc[0]) & (paramAllAlgs['activation'] == crossoverDF['activation'].iloc[0]) & (paramAllAlgs['solver'] == crossoverDF['solver'].iloc[0])).any()):
crossoverDF = pd.DataFrame()
else:
clf = MLPClassifier(random_state=RANDOM_SEED)
params = {'hidden_layer_sizes': [crossoverDF['hidden_layer_sizes'].iloc[0]], 'alpha': [crossoverDF['alpha'].iloc[0]], 'tol': [crossoverDF['tol'].iloc[0]], 'max_iter': [crossoverDF['max_iter'].iloc[0]], 'activation': [crossoverDF['activation'].iloc[0]], 'solver': [crossoverDF['solver'].iloc[0]]}
AlgorithmsIDsEnd = countAllModels + countMLP
localCrossMutr = crossoverMutation(XData, yData, clf, params, 'MLP', AlgorithmsIDsEnd)
countMLP += 1
crossoverDF = pd.DataFrame()
countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
localCrossMutr[1] = pd.concat([localCrossMutr[1], localCrossMutr[(loop+1)*4+1]], ignore_index=True)
localCrossMutr[2] = pd.concat([localCrossMutr[2], localCrossMutr[(loop+1)*4+2]], ignore_index=True)
localCrossMutr[3] = pd.concat([localCrossMutr[3], localCrossMutr[(loop+1)*4+3]], ignore_index=True)
allParametersPerfCrossMutrMLPC.append(localCrossMutr[0])
allParametersPerfCrossMutrMLPC.append(localCrossMutr[1])
allParametersPerfCrossMutrMLPC.append(localCrossMutr[2])
allParametersPerfCrossMutrMLPC.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrMLPC
countMLP = 0
MLPIntIndex = []
localCrossMutr.clear() localCrossMutr.clear()
allParametersPerfCrossMutrMLPM = []
while countMLP < setMaxLoopValue:
for dr in MLPIDs:
MLPIntIndex.append(int(re.findall('\d+', dr)[0]))
MLPPickPair = random.sample(MLPIntIndex,1)
pairDF = paramAllAlgs.iloc[MLPPickPair]
crossoverDF = pd.DataFrame()
for column in pairDF:
listData = []
if (column == 'hidden_layer_sizes'):
randomNumber = (random.randint(10,60), random.randint(4,10))
listData.append(randomNumber)
crossoverDF[column] = listData
else:
valuePerColumn = pairDF[column].iloc[0]
listData.append(valuePerColumn)
crossoverDF[column] = listData
if (((paramAllAlgs['hidden_layer_sizes'] == crossoverDF['hidden_layer_sizes'].iloc[0]) & (paramAllAlgs['alpha'] == crossoverDF['alpha'].iloc[0]) & (paramAllAlgs['tol'] == crossoverDF['tol'].iloc[0]) & (paramAllAlgs['max_iter'] == crossoverDF['max_iter'].iloc[0]) & (paramAllAlgs['activation'] == crossoverDF['activation'].iloc[0]) & (paramAllAlgs['solver'] == crossoverDF['solver'].iloc[0])).any()):
crossoverDF = pd.DataFrame()
else:
clf = MLPClassifier(random_state=RANDOM_SEED)
params = {'hidden_layer_sizes': [crossoverDF['hidden_layer_sizes'].iloc[0]], 'alpha': [crossoverDF['alpha'].iloc[0]], 'tol': [crossoverDF['tol'].iloc[0]], 'max_iter': [crossoverDF['max_iter'].iloc[0]], 'activation': [crossoverDF['activation'].iloc[0]], 'solver': [crossoverDF['solver'].iloc[0]]}
AlgorithmsIDsEnd = countAllModels + countMLP
localCrossMutr = crossoverMutation(XData, yData, clf, params, 'MLP', AlgorithmsIDsEnd)
countMLP += 1
crossoverDF = pd.DataFrame()
allParametersPerfCrossMutr = allParametersPerfCrossMutrKNNC + allParametersPerfCrossMutrKNNM + allParametersPerfCrossMutrLRC + allParametersPerfCrossMutrLRM countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
localCrossMutr[1] = pd.concat([localCrossMutr[1], localCrossMutr[(loop+1)*4+1]], ignore_index=True)
localCrossMutr[2] = pd.concat([localCrossMutr[2], localCrossMutr[(loop+1)*4+2]], ignore_index=True)
localCrossMutr[3] = pd.concat([localCrossMutr[3], localCrossMutr[(loop+1)*4+3]], ignore_index=True)
allParametersPerfCrossMutrMLPM.append(localCrossMutr[0])
allParametersPerfCrossMutrMLPM.append(localCrossMutr[1])
allParametersPerfCrossMutrMLPM.append(localCrossMutr[2])
allParametersPerfCrossMutrMLPM.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrMLPM
localCrossMutr.clear()
allParametersPerfCrossMutrRFC = []
while countRF < setMaxLoopValue:
for dr in RFIDs:
RFIntIndex.append(int(re.findall('\d+', dr)[0]))
RFPickPair = random.sample(RFIntIndex,2)
pairDF = paramAllAlgs.iloc[RFPickPair]
crossoverDF = pd.DataFrame()
for column in pairDF:
listData = []
randomZeroOne = random.randint(0, 1)
valuePerColumn = pairDF[column].iloc[randomZeroOne]
listData.append(valuePerColumn)
crossoverDF[column] = listData
if (((paramAllAlgs['n_estimators'] == crossoverDF['n_estimators'].iloc[0]) & (paramAllAlgs['criterion'] == crossoverDF['criterion'].iloc[0])).any()):
crossoverDF = pd.DataFrame()
else:
clf = RandomForestClassifier(random_state=RANDOM_SEED)
params = {'n_estimators': [crossoverDF['n_estimators'].iloc[0]], 'criterion': [crossoverDF['criterion'].iloc[0]]}
AlgorithmsIDsEnd = countAllModels + countRF
localCrossMutr = crossoverMutation(XData, yData, clf, params, 'RF', AlgorithmsIDsEnd)
countRF += 1
crossoverDF = pd.DataFrame()
countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
localCrossMutr[1] = pd.concat([localCrossMutr[1], localCrossMutr[(loop+1)*4+1]], ignore_index=True)
localCrossMutr[2] = pd.concat([localCrossMutr[2], localCrossMutr[(loop+1)*4+2]], ignore_index=True)
localCrossMutr[3] = pd.concat([localCrossMutr[3], localCrossMutr[(loop+1)*4+3]], ignore_index=True)
allParametersPerfCrossMutrRFC.append(localCrossMutr[0])
allParametersPerfCrossMutrRFC.append(localCrossMutr[1])
allParametersPerfCrossMutrRFC.append(localCrossMutr[2])
allParametersPerfCrossMutrRFC.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrRFC
countRF = 0
RFIntIndex = []
localCrossMutr.clear()
allParametersPerfCrossMutrRFM = []
while countRF < setMaxLoopValue:
for dr in RFIDs:
RFIntIndex.append(int(re.findall('\d+', dr)[0]))
RFPickPair = random.sample(RFIntIndex,1)
pairDF = paramAllAlgs.iloc[RFPickPair]
crossoverDF = pd.DataFrame()
for column in pairDF:
listData = []
if (column == 'n_estimators'):
randomNumber = random.randint(100, 200)
listData.append(randomNumber)
crossoverDF[column] = listData
else:
valuePerColumn = pairDF[column].iloc[0]
listData.append(valuePerColumn)
crossoverDF[column] = listData
if (((paramAllAlgs['n_estimators'] == crossoverDF['n_estimators'].iloc[0]) & (paramAllAlgs['criterion'] == crossoverDF['criterion'].iloc[0])).any()):
crossoverDF = pd.DataFrame()
else:
clf = RandomForestClassifier(random_state=RANDOM_SEED)
params = {'n_estimators': [crossoverDF['n_estimators'].iloc[0]], 'criterion': [crossoverDF['criterion'].iloc[0]]}
AlgorithmsIDsEnd = countAllModels + countRF
localCrossMutr = crossoverMutation(XData, yData, clf, params, 'RF', AlgorithmsIDsEnd)
countRF += 1
crossoverDF = pd.DataFrame()
countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
localCrossMutr[1] = pd.concat([localCrossMutr[1], localCrossMutr[(loop+1)*4+1]], ignore_index=True)
localCrossMutr[2] = pd.concat([localCrossMutr[2], localCrossMutr[(loop+1)*4+2]], ignore_index=True)
localCrossMutr[3] = pd.concat([localCrossMutr[3], localCrossMutr[(loop+1)*4+3]], ignore_index=True)
allParametersPerfCrossMutrRFM.append(localCrossMutr[0])
allParametersPerfCrossMutrRFM.append(localCrossMutr[1])
allParametersPerfCrossMutrRFM.append(localCrossMutr[2])
allParametersPerfCrossMutrRFM.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrRFM
localCrossMutr.clear()
allParametersPerfCrossMutrGradBC = []
while countGradB < setMaxLoopValue:
for dr in GradBIDs:
GradBIntIndex.append(int(re.findall('\d+', dr)[0]))
GradBPickPair = random.sample(GradBIntIndex,2)
pairDF = paramAllAlgs.iloc[GradBPickPair]
crossoverDF = pd.DataFrame()
for column in pairDF:
listData = []
randomZeroOne = random.randint(0, 1)
valuePerColumn = pairDF[column].iloc[randomZeroOne]
listData.append(valuePerColumn)
crossoverDF[column] = listData
if (((paramAllAlgs['n_estimators'] == crossoverDF['n_estimators'].iloc[0]) & (paramAllAlgs['learning_rate'] == crossoverDF['learning_rate'].iloc[0]) & (paramAllAlgs['criterion'] == crossoverDF['criterion'].iloc[0])).any()):
crossoverDF = pd.DataFrame()
else:
clf = GradientBoostingClassifier(random_state=RANDOM_SEED)
params = {'n_estimators': [crossoverDF['n_estimators'].iloc[0]], 'learning_rate': [crossoverDF['learning_rate'].iloc[0]], 'criterion': [crossoverDF['criterion'].iloc[0]]}
AlgorithmsIDsEnd = countAllModels + countGradB
localCrossMutr = crossoverMutation(XData, yData, clf, params, 'GradB', AlgorithmsIDsEnd)
countGradB += 1
crossoverDF = pd.DataFrame()
countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
localCrossMutr[1] = pd.concat([localCrossMutr[1], localCrossMutr[(loop+1)*4+1]], ignore_index=True)
localCrossMutr[2] = pd.concat([localCrossMutr[2], localCrossMutr[(loop+1)*4+2]], ignore_index=True)
localCrossMutr[3] = pd.concat([localCrossMutr[3], localCrossMutr[(loop+1)*4+3]], ignore_index=True)
allParametersPerfCrossMutrGradBC.append(localCrossMutr[0])
allParametersPerfCrossMutrGradBC.append(localCrossMutr[1])
allParametersPerfCrossMutrGradBC.append(localCrossMutr[2])
allParametersPerfCrossMutrGradBC.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrGradBC
countGradB = 0
GradBIntIndex = []
localCrossMutr.clear()
allParametersPerfCrossMutrGradBM = []
while countGradB < setMaxLoopValue:
for dr in GradBIDs:
GradBIntIndex.append(int(re.findall('\d+', dr)[0]))
GradPickPair = random.sample(GradBIntIndex,1)
pairDF = paramAllAlgs.iloc[GradBPickPair]
crossoverDF = pd.DataFrame()
for column in pairDF:
listData = []
if (column == 'n_estimators'):
randomNumber = random.randint(100, 200)
listData.append(randomNumber)
crossoverDF[column] = listData
else:
valuePerColumn = pairDF[column].iloc[0]
listData.append(valuePerColumn)
crossoverDF[column] = listData
if (((paramAllAlgs['n_estimators'] == crossoverDF['n_estimators'].iloc[0]) & (paramAllAlgs['learning_rate'] == crossoverDF['learning_rate'].iloc[0]) & (paramAllAlgs['criterion'] == crossoverDF['criterion'].iloc[0])).any()):
crossoverDF = pd.DataFrame()
else:
clf = GradientBoostingClassifier(random_state=RANDOM_SEED)
params = {'n_estimators': [crossoverDF['n_estimators'].iloc[0]], 'learning_rate': [crossoverDF['learning_rate'].iloc[0]], 'criterion': [crossoverDF['criterion'].iloc[0]]}
AlgorithmsIDsEnd = countAllModels + countGradB
localCrossMutr = crossoverMutation(XData, yData, clf, params, 'RF', AlgorithmsIDsEnd)
countGradB += 1
crossoverDF = pd.DataFrame()
countAllModels = countAllModels + setMaxLoopValue
for loop in range(setMaxLoopValue - 1):
localCrossMutr[0] = localCrossMutr[0] + localCrossMutr[(loop+1)*4]
localCrossMutr[1] = pd.concat([localCrossMutr[1], localCrossMutr[(loop+1)*4+1]], ignore_index=True)
localCrossMutr[2] = pd.concat([localCrossMutr[2], localCrossMutr[(loop+1)*4+2]], ignore_index=True)
localCrossMutr[3] = pd.concat([localCrossMutr[3], localCrossMutr[(loop+1)*4+3]], ignore_index=True)
allParametersPerfCrossMutrGradBM.append(localCrossMutr[0])
allParametersPerfCrossMutrGradBM.append(localCrossMutr[1])
allParametersPerfCrossMutrGradBM.append(localCrossMutr[2])
allParametersPerfCrossMutrGradBM.append(localCrossMutr[3])
HistoryPreservation = HistoryPreservation + allParametersPerfCrossMutrGradBM
localCrossMutr.clear()
allParametersPerfCrossMutr = allParametersPerfCrossMutrKNNC + allParametersPerfCrossMutrKNNM + allParametersPerfCrossMutrLRC + allParametersPerfCrossMutrLRM + allParametersPerfCrossMutrMLPC + allParametersPerfCrossMutrMLPM + allParametersPerfCrossMutrRFC + allParametersPerfCrossMutrRFM + allParametersPerfCrossMutrGradBC + allParametersPerfCrossMutrGradBM
allParametersPerformancePerModel[4] = allParametersPerformancePerModel[4] + allParametersPerfCrossMutrKNNC[0] + allParametersPerfCrossMutrKNNM[0] allParametersPerformancePerModel[4] = allParametersPerformancePerModel[4] + allParametersPerfCrossMutrKNNC[0] + allParametersPerfCrossMutrKNNM[0]
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrKNNC[1]], ignore_index=True) allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrKNNC[1]], ignore_index=True)
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrKNNM[1]], ignore_index=True) allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrKNNM[1]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrKNNC[2]], ignore_index=True) allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrKNNC[2]], ignore_index=True)
@ -1273,27 +1538,45 @@ def CrossoverMutateFun():
allParametersPerformancePerModel[7] = pd.concat([allParametersPerformancePerModel[7], allParametersPerfCrossMutrLRC[3]], ignore_index=True) allParametersPerformancePerModel[7] = pd.concat([allParametersPerformancePerModel[7], allParametersPerfCrossMutrLRC[3]], ignore_index=True)
allParametersPerformancePerModel[7] = pd.concat([allParametersPerformancePerModel[7], allParametersPerfCrossMutrLRM[3]], ignore_index=True) allParametersPerformancePerModel[7] = pd.concat([allParametersPerformancePerModel[7], allParametersPerfCrossMutrLRM[3]], ignore_index=True)
addKNN = addLR allParametersPerformancePerModel[4] = allParametersPerformancePerModel[4] + allParametersPerfCrossMutrMLPC[0] + allParametersPerfCrossMutrMLPM[0]
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrMLPC[1]], ignore_index=True)
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrMLPM[1]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrMLPC[2]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrMLPM[2]], ignore_index=True)
allParametersPerformancePerModel[11] = pd.concat([allParametersPerformancePerModel[11], allParametersPerfCrossMutrMLPC[3]], ignore_index=True)
allParametersPerformancePerModel[11] = pd.concat([allParametersPerformancePerModel[11], allParametersPerfCrossMutrMLPM[3]], ignore_index=True)
allParametersPerformancePerModel[4] = allParametersPerformancePerModel[4] + allParametersPerfCrossMutrRFC[0] + allParametersPerfCrossMutrRFM[0]
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrRFC[1]], ignore_index=True)
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrRFM[1]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrRFC[2]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrRFM[2]], ignore_index=True)
allParametersPerformancePerModel[15] = pd.concat([allParametersPerformancePerModel[15], allParametersPerfCrossMutrRFC[3]], ignore_index=True)
allParametersPerformancePerModel[15] = pd.concat([allParametersPerformancePerModel[15], allParametersPerfCrossMutrRFM[3]], ignore_index=True)
allParametersPerformancePerModel[4] = allParametersPerformancePerModel[4] + allParametersPerfCrossMutrGradBC[0] + allParametersPerfCrossMutrGradBM[0]
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrGradBC[1]], ignore_index=True)
allParametersPerformancePerModel[5] = pd.concat([allParametersPerformancePerModel[5], allParametersPerfCrossMutrGradBM[1]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrGradBC[2]], ignore_index=True)
allParametersPerformancePerModel[6] = pd.concat([allParametersPerformancePerModel[6], allParametersPerfCrossMutrGradBM[2]], ignore_index=True)
allParametersPerformancePerModel[19] = pd.concat([allParametersPerformancePerModel[19], allParametersPerfCrossMutrGradBC[3]], ignore_index=True)
allParametersPerformancePerModel[19] = pd.concat([allParametersPerformancePerModel[19], allParametersPerfCrossMutrGradBM[3]], ignore_index=True)
addLR = addLR + 10 addKNN = addLR
# KNNIntIndex = [] addLR = addLR + setMaxLoopValue*2
# for dr in KNNIDs:
# KNNIntIndex.append(int(re.findall('\d+', dr)[0]))
# allParametersPerformancePerModel[0] = [j for i, j in enumerate(allParametersPerformancePerModel[0]) if i not in KNNIntIndex] addMLP = addLR + setMaxLoopValue*2
# allParametersPerformancePerModel[1].drop(allParametersPerformancePerModel[1].index[KNNIntIndex], inplace=True)
# allParametersPerformancePerModel[2].drop(allParametersPerformancePerModel[2].index[KNNIntIndex], inplace=True)
# allParametersPerformancePerModel[3].drop(allParametersPerformancePerModel[3].index[KNNIntIndex], inplace=True)
# LRIntIndex = [] addRF = addMLP + setMaxLoopValue*2
# for dr in LRIDs:
# LRIntIndex.append(int(re.findall('\d+', dr)[0]) - 100)
# allParametersPerformancePerModel[4] = [j for i, j in enumerate(allParametersPerformancePerModel[4]) if i not in LRIntIndex] addGradB = addRF + setMaxLoopValue*2
# allParametersPerformancePerModel[5].drop(allParametersPerformancePerModel[5].index[LRIntIndex], inplace=True)
# allParametersPerformancePerModel[6].drop(allParametersPerformancePerModel[6].index[LRIntIndex], inplace=True)
# allParametersPerformancePerModel[7].drop(allParametersPerformancePerModel[7].index[LRIntIndex], inplace=True)
return 'Everything Okay' return 'Everything Okay'
@ -1391,8 +1674,15 @@ def PreprocessingIDsCM():
dicKNNM = allParametersPerfCrossMutr[4] dicKNNM = allParametersPerfCrossMutr[4]
dicLRC = allParametersPerfCrossMutr[8] dicLRC = allParametersPerfCrossMutr[8]
dicLRM = allParametersPerfCrossMutr[12] dicLRM = allParametersPerfCrossMutr[12]
dicMLPC = allParametersPerfCrossMutr[16]
dicMLPM = allParametersPerfCrossMutr[20]
dicRFC = allParametersPerfCrossMutr[24]
dicRFM = allParametersPerfCrossMutr[28]
dicGradBC = allParametersPerfCrossMutr[32]
dicGradBM = allParametersPerfCrossMutr[36]
df_concatIDs = dicKNNC + dicKNNM + dicLRC + dicLRM df_concatIDs = dicKNNC + dicKNNM + dicLRC + dicLRM + dicMLPC + dicMLPM + dicRFC + dicRFM + dicGradBC + dicGradBM
return df_concatIDs return df_concatIDs
def PreprocessingMetricsCM(): def PreprocessingMetricsCM():
@ -1400,13 +1690,25 @@ def PreprocessingMetricsCM():
dicKNNM = allParametersPerfCrossMutr[6] dicKNNM = allParametersPerfCrossMutr[6]
dicLRC = allParametersPerfCrossMutr[10] dicLRC = allParametersPerfCrossMutr[10]
dicLRM = allParametersPerfCrossMutr[14] dicLRM = allParametersPerfCrossMutr[14]
dicMLPC = allParametersPerfCrossMutr[18]
dicMLPM = allParametersPerfCrossMutr[22]
dicRFC = allParametersPerfCrossMutr[26]
dicRFM = allParametersPerfCrossMutr[30]
dicGradBC = allParametersPerfCrossMutr[34]
dicGradBM = allParametersPerfCrossMutr[38]
dfKNNC = pd.DataFrame.from_dict(dicKNNC) dfKNNC = pd.DataFrame.from_dict(dicKNNC)
dfKNNM = pd.DataFrame.from_dict(dicKNNM) dfKNNM = pd.DataFrame.from_dict(dicKNNM)
dfLRC = pd.DataFrame.from_dict(dicLRC) dfLRC = pd.DataFrame.from_dict(dicLRC)
dfLRM = pd.DataFrame.from_dict(dicLRM) dfLRM = pd.DataFrame.from_dict(dicLRM)
dfMLPC = pd.DataFrame.from_dict(dicMLPC)
df_concatMetrics = pd.concat([dfKNNC, dfKNNM, dfLRC, dfLRM]) dfMLPM = pd.DataFrame.from_dict(dicMLPM)
dfRFC = pd.DataFrame.from_dict(dicRFC)
dfRFM = pd.DataFrame.from_dict(dicRFM)
dfGradBC = pd.DataFrame.from_dict(dicGradBC)
dfGradBM = pd.DataFrame.from_dict(dicGradBM)
df_concatMetrics = pd.concat([dfKNNC, dfKNNM, dfLRC, dfLRM, dfMLPC, dfMLPM, dfRFC, dfRFM, dfGradBC, dfGradBM])
df_concatMetrics = df_concatMetrics.reset_index(drop=True) df_concatMetrics = df_concatMetrics.reset_index(drop=True)
return df_concatMetrics return df_concatMetrics
@ -1415,17 +1717,35 @@ def PreprocessingPredCM():
dicKNNM = allParametersPerfCrossMutr[7] dicKNNM = allParametersPerfCrossMutr[7]
dicLRC = allParametersPerfCrossMutr[11] dicLRC = allParametersPerfCrossMutr[11]
dicLRM = allParametersPerfCrossMutr[15] dicLRM = allParametersPerfCrossMutr[15]
dicMLPC = allParametersPerfCrossMutr[19]
dicMLPM = allParametersPerfCrossMutr[23]
dicRFC = allParametersPerfCrossMutr[27]
dicRFM = allParametersPerfCrossMutr[31]
dicGradBC = allParametersPerfCrossMutr[35]
dicGradBM = allParametersPerfCrossMutr[39]
dfKNNC = pd.DataFrame.from_dict(dicKNNC) dfKNNC = pd.DataFrame.from_dict(dicKNNC)
dfKNNM = pd.DataFrame.from_dict(dicKNNM) dfKNNM = pd.DataFrame.from_dict(dicKNNM)
dfLRC = pd.DataFrame.from_dict(dicLRC) dfLRC = pd.DataFrame.from_dict(dicLRC)
dfLRM = pd.DataFrame.from_dict(dicLRM) dfLRM = pd.DataFrame.from_dict(dicLRM)
dfMLPC = pd.DataFrame.from_dict(dicMLPC)
dfMLPM = pd.DataFrame.from_dict(dicMLPM)
dfRFC = pd.DataFrame.from_dict(dicRFC)
dfRFM = pd.DataFrame.from_dict(dicRFM)
dfGradBC = pd.DataFrame.from_dict(dicGradBC)
dfGradBM = pd.DataFrame.from_dict(dicGradBM)
dfKNN = pd.concat([dfKNNC, dfKNNM]) dfKNN = pd.concat([dfKNNC, dfKNNM])
dfLR = pd.concat([dfLRC, dfLRM]) dfLR = pd.concat([dfLRC, dfLRM])
df_concatProbs = pd.concat([dfKNNC, dfKNNM, dfLRC, dfLRM]) dfMLP = pd.concat([dfMLPC, dfMLPM])
dfRF = pd.concat([dfRFC, dfRFM])
dfGradB = pd.concat([dfGradBC, dfGradBM])
df_concatProbs = pd.concat([dfKNNC, dfKNNM, dfLRC, dfLRM, dfMLPC, dfMLPM, dfRFC, dfRFM, dfGradBC, dfGradBM])
predictionsKNN = [] predictionsKNN = []
for column, content in dfKNN.items(): for column, content in dfKNN.items():
@ -1436,41 +1756,87 @@ def PreprocessingPredCM():
for column, content in dfLR.items(): for column, content in dfLR.items():
el = [sum(x)/len(x) for x in zip(*content)] el = [sum(x)/len(x) for x in zip(*content)]
predictionsLR.append(el) predictionsLR.append(el)
predictionsMLP = []
for column, content in dfMLP.items():
el = [sum(x)/len(x) for x in zip(*content)]
predictionsMLP.append(el)
predictionsRF = []
for column, content in dfRF.items():
el = [sum(x)/len(x) for x in zip(*content)]
predictionsRF.append(el)
predictionsGradB = []
for column, content in dfGradB.items():
el = [sum(x)/len(x) for x in zip(*content)]
predictionsGradB.append(el)
predictions = [] predictions = []
for column, content in df_concatProbs.items(): for column, content in df_concatProbs.items():
el = [sum(x)/len(x) for x in zip(*content)] el = [sum(x)/len(x) for x in zip(*content)]
predictions.append(el) predictions.append(el)
return [predictionsKNN, predictionsLR, predictions] return [predictionsKNN, predictionsLR, predictionsMLP, predictionsRF, predictionsGradB, predictions]
def PreprocessingParamCM(): def PreprocessingParamCM():
dicKNNC = allParametersPerfCrossMutr[1] dicKNNC = allParametersPerfCrossMutr[1]
dicKNNM = allParametersPerfCrossMutr[5] dicKNNM = allParametersPerfCrossMutr[5]
dicLRC = allParametersPerfCrossMutr[9] dicLRC = allParametersPerfCrossMutr[9]
dicLRM = allParametersPerfCrossMutr[13] dicLRM = allParametersPerfCrossMutr[13]
dicMLPC = allParametersPerfCrossMutr[17]
dicMLPM = allParametersPerfCrossMutr[21]
dicRFC = allParametersPerfCrossMutr[25]
dicRFM = allParametersPerfCrossMutr[29]
dicGradBC = allParametersPerfCrossMutr[33]
dicGradBM = allParametersPerfCrossMutr[37]
dicKNNC = dicKNNC['params'] dicKNNC = dicKNNC['params']
dicKNNM = dicKNNM['params'] dicKNNM = dicKNNM['params']
dicLRC = dicLRC['params'] dicLRC = dicLRC['params']
dicLRM = dicLRM['params'] dicLRM = dicLRM['params']
dicMLPC = dicMLPC['params']
dicMLPM = dicMLPM['params']
dicRFC = dicRFC['params']
dicRFM = dicRFM['params']
dicGradBC = dicGradBC['params']
dicGradBM = dicGradBM['params']
dicKNNC = {int(k):v for k,v in dicKNNC.items()} dicKNNC = {int(k):v for k,v in dicKNNC.items()}
dicKNNM = {int(k):v for k,v in dicKNNM.items()} dicKNNM = {int(k):v for k,v in dicKNNM.items()}
dicLRC = {int(k):v for k,v in dicLRC.items()} dicLRC = {int(k):v for k,v in dicLRC.items()}
dicLRM = {int(k):v for k,v in dicLRM.items()} dicLRM = {int(k):v for k,v in dicLRM.items()}
dicMLPC = {int(k):v for k,v in dicMLPC.items()}
dicMLPM = {int(k):v for k,v in dicMLPM.items()}
dicRFC = {int(k):v for k,v in dicRFC.items()}
dicRFM = {int(k):v for k,v in dicRFM.items()}
dicGradBC = {int(k):v for k,v in dicGradBC.items()}
dicGradBM = {int(k):v for k,v in dicGradBM.items()}
dfKNNC = pd.DataFrame.from_dict(dicKNNC) dfKNNC = pd.DataFrame.from_dict(dicKNNC)
dfKNNM = pd.DataFrame.from_dict(dicKNNM) dfKNNM = pd.DataFrame.from_dict(dicKNNM)
dfLRC = pd.DataFrame.from_dict(dicLRC) dfLRC = pd.DataFrame.from_dict(dicLRC)
dfLRM = pd.DataFrame.from_dict(dicLRM) dfLRM = pd.DataFrame.from_dict(dicLRM)
dfMLPC = pd.DataFrame.from_dict(dicMLPC)
dfMLPM = pd.DataFrame.from_dict(dicMLPM)
dfRFC = pd.DataFrame.from_dict(dicRFC)
dfRFM = pd.DataFrame.from_dict(dicRFM)
dfGradBC = pd.DataFrame.from_dict(dicGradBC)
dfGradBM = pd.DataFrame.from_dict(dicGradBM)
dfKNNC = dfKNNC.T dfKNNC = dfKNNC.T
dfKNNM = dfKNNM.T dfKNNM = dfKNNM.T
dfLRC = dfLRC.T dfLRC = dfLRC.T
dfLRM = dfLRM.T dfLRM = dfLRM.T
dfMLPC = dfMLPC.T
df_params = pd.concat([dfKNNC, dfKNNM, dfLRC, dfLRM]) dfMLPM = dfMLPM.T
dfRFC = dfRFC.T
dfRFM = dfRFM.T
dfGradBC = dfGradBC.T
dfGradBM = dfGradBM.T
df_params = pd.concat([dfKNNC, dfKNNM, dfLRC, dfLRM, dfMLPC, dfMLPM, dfRFC, dfRFM, dfGradBC, dfGradBM])
df_params = df_params.reset_index(drop=True) df_params = df_params.reset_index(drop=True)
return df_params return df_params
@ -1479,28 +1845,58 @@ def PreprocessingParamSepCM():
dicKNNM = allParametersPerfCrossMutr[5] dicKNNM = allParametersPerfCrossMutr[5]
dicLRC = allParametersPerfCrossMutr[9] dicLRC = allParametersPerfCrossMutr[9]
dicLRM = allParametersPerfCrossMutr[13] dicLRM = allParametersPerfCrossMutr[13]
dicMLPC = allParametersPerfCrossMutr[17]
dicMLPM = allParametersPerfCrossMutr[21]
dicRFC = allParametersPerfCrossMutr[25]
dicRFM = allParametersPerfCrossMutr[29]
dicGradBC = allParametersPerfCrossMutr[33]
dicGradBM = allParametersPerfCrossMutr[37]
dicKNNC = dicKNNC['params'] dicKNNC = dicKNNC['params']
dicKNNM = dicKNNM['params'] dicKNNM = dicKNNM['params']
dicLRC = dicLRC['params'] dicLRC = dicLRC['params']
dicLRM = dicLRM['params'] dicLRM = dicLRM['params']
dicMLPC = dicMLPC['params']
dicMLPM = dicMLPM['params']
dicRFC = dicRFC['params']
dicRFM = dicRFM['params']
dicGradBC = dicGradBC['params']
dicGradBM = dicGradBM['params']
dicKNNC = {int(k):v for k,v in dicKNNC.items()} dicKNNC = {int(k):v for k,v in dicKNNC.items()}
dicKNNM = {int(k):v for k,v in dicKNNM.items()} dicKNNM = {int(k):v for k,v in dicKNNM.items()}
dicLRC = {int(k):v for k,v in dicLRC.items()} dicLRC = {int(k):v for k,v in dicLRC.items()}
dicLRM = {int(k):v for k,v in dicLRM.items()} dicLRM = {int(k):v for k,v in dicLRM.items()}
dicMLPC = {int(k):v for k,v in dicMLPC.items()}
dicMLPM = {int(k):v for k,v in dicMLPM.items()}
dicRFC = {int(k):v for k,v in dicRFC.items()}
dicRFM = {int(k):v for k,v in dicRFM.items()}
dicGradBC = {int(k):v for k,v in dicGradBC.items()}
dicGradBM = {int(k):v for k,v in dicGradBM.items()}
dfKNNC = pd.DataFrame.from_dict(dicKNNC) dfKNNC = pd.DataFrame.from_dict(dicKNNC)
dfKNNM = pd.DataFrame.from_dict(dicKNNM) dfKNNM = pd.DataFrame.from_dict(dicKNNM)
dfLRC = pd.DataFrame.from_dict(dicLRC) dfLRC = pd.DataFrame.from_dict(dicLRC)
dfLRM = pd.DataFrame.from_dict(dicLRM) dfLRM = pd.DataFrame.from_dict(dicLRM)
dfMLPC = pd.DataFrame.from_dict(dicMLPC)
dfMLPM = pd.DataFrame.from_dict(dicMLPM)
dfRFC = pd.DataFrame.from_dict(dicRFC)
dfRFM = pd.DataFrame.from_dict(dicRFM)
dfGradBC = pd.DataFrame.from_dict(dicGradBC)
dfGradBM = pd.DataFrame.from_dict(dicGradBM)
dfKNNC = dfKNNC.T dfKNNC = dfKNNC.T
dfKNNM = dfKNNM.T dfKNNM = dfKNNM.T
dfLRC = dfLRC.T dfLRC = dfLRC.T
dfLRM = dfLRM.T dfLRM = dfLRM.T
dfMLPC = dfMLPC.T
return [dfKNNC, dfKNNM, dfLRC, dfLRM] dfMLPM = dfMLPM.T
dfRFC = dfRFC.T
dfRFM = dfRFM.T
dfGradBC = dfGradBC.T
dfGradBM = dfGradBM.T
return [dfKNNC, dfKNNM, dfLRC, dfLRM, dfMLPC, dfMLPM, dfRFC, dfRFM, dfGradBC, dfGradBM]
# remove that maybe! # remove that maybe!
def preProcsumPerMetricCM(factors): def preProcsumPerMetricCM(factors):

Loading…
Cancel
Save