fix only provenance

Former-commit-id: 3ae1d26727
master
parent 8f759ce962
commit 75d3d038f7
  1. BIN
      __pycache__/run.cpython-37.pyc
  2. 8
      frontend/src/components/DataSpace.vue
  3. 24
      frontend/src/components/FinalResultsLinePlot.vue
  4. 31
      frontend/src/components/Main.vue
  5. 28
      frontend/src/components/Provenance.vue
  6. 9
      frontend/src/components/ScatterPlot.vue
  7. 207
      run.py

Binary file not shown.

@ -74,6 +74,7 @@ export default {
responsiveWidthHeight: [], responsiveWidthHeight: [],
RetrieveDataSet: 'HeartC', RetrieveDataSet: 'HeartC',
colorsValues: ['#808000','#008080','#bebada','#fccde5','#d9d9d9','#bc80bd','#ccebc5'], colorsValues: ['#808000','#008080','#bebada','#fccde5','#d9d9d9','#bc80bd','#ccebc5'],
onlyOnce: true,
} }
}, },
methods: { methods: {
@ -398,8 +399,10 @@ export default {
var config = {scrollZoom: true, displaylogo: false, showLink: false, showSendToCloud: false, modeBarButtonsToRemove: ['toImage', 'toggleSpikelines', 'autoScale2d', 'hoverClosestGl2d','hoverCompareCartesian','select2d','hoverClosestCartesian','zoomIn2d','zoomOut2d','zoom2d'], responsive: true} var config = {scrollZoom: true, displaylogo: false, showLink: false, showSendToCloud: false, modeBarButtonsToRemove: ['toImage', 'toggleSpikelines', 'autoScale2d', 'hoverClosestGl2d','hoverCompareCartesian','select2d','hoverClosestCartesian','zoomIn2d','zoomOut2d','zoom2d'], responsive: true}
Plotly.newPlot('OverviewDataPlotly', traces, layout, config) Plotly.newPlot('OverviewDataPlotly', traces, layout, config)
if (this.onlyOnce) {
this.selectedDataPoints() this.selectedDataPoints()
}
this.onlyOnce = false
}, },
selectedDataPoints () { selectedDataPoints () {
const OverviewDataPlotly = document.getElementById('OverviewDataPlotly') const OverviewDataPlotly = document.getElementById('OverviewDataPlotly')
@ -419,9 +422,10 @@ export default {
} }
} }
if (ClassifierIDsList != '') { if (ClassifierIDsList != '') {
EventBus.$emit('ChangeKey', 1)
EventBus.$emit('SendSelectedPointsToServerEventfromData', ClassifierIDsListCleared) EventBus.$emit('SendSelectedPointsToServerEventfromData', ClassifierIDsListCleared)
} else { } else {
EventBus.$emit('SendSelectedPointsToServerEventfromData', '') EventBus.$emit('ChangeKey', 0)
} }
} }
}) })

@ -64,41 +64,41 @@ export default {
this.scoresPositive.push(parseFloat(this.scoresMean[this.scoresMean.length - 1]) + parseFloat(this.scoresSTD[this.scoresSTD.length - 1])) this.scoresPositive.push(parseFloat(this.scoresMean[this.scoresMean.length - 1]) + parseFloat(this.scoresSTD[this.scoresSTD.length - 1]))
this.scoresNegative.push(parseFloat(this.scoresMean[this.scoresMean.length - 1]) - parseFloat(this.scoresSTD[this.scoresSTD.length - 1])) this.scoresNegative.push(parseFloat(this.scoresMean[this.scoresMean.length - 1]) - parseFloat(this.scoresSTD[this.scoresSTD.length - 1]))
this.scoresMean2.push((JSON.parse(this.FinalResultsforLinePlot[2])*100).toFixed(2)) this.scoresMean2.push((JSON.parse(this.FinalResultsforLinePlot[4])*100).toFixed(2))
this.scoresSTD2.push((JSON.parse(this.FinalResultsforLinePlot[3])*100).toFixed(2)) this.scoresSTD2.push((JSON.parse(this.FinalResultsforLinePlot[5])*100).toFixed(2))
this.scoresPositive2.push(parseFloat(this.scoresMean2[this.scoresMean2.length - 1]) + parseFloat(this.scoresSTD2[this.scoresSTD2.length - 1])) this.scoresPositive2.push(parseFloat(this.scoresMean2[this.scoresMean2.length - 1]) + parseFloat(this.scoresSTD2[this.scoresSTD2.length - 1]))
this.scoresNegative2.push(parseFloat(this.scoresMean2[this.scoresMean2.length - 1]) - parseFloat(this.scoresSTD2[this.scoresSTD2.length - 1])) this.scoresNegative2.push(parseFloat(this.scoresMean2[this.scoresMean2.length - 1]) - parseFloat(this.scoresSTD2[this.scoresSTD2.length - 1]))
this.scoresMean3.push((JSON.parse(this.FinalResultsforLinePlot[4])*100).toFixed(2)) this.scoresMean3.push((JSON.parse(this.FinalResultsforLinePlot[8])*100).toFixed(2))
this.scoresSTD3.push((JSON.parse(this.FinalResultsforLinePlot[5])*100).toFixed(2)) this.scoresSTD3.push((JSON.parse(this.FinalResultsforLinePlot[9])*100).toFixed(2))
this.scoresPositive3.push(parseFloat(this.scoresMean3[this.scoresMean3.length - 1]) + parseFloat(this.scoresSTD3[this.scoresSTD3.length - 1])) this.scoresPositive3.push(parseFloat(this.scoresMean3[this.scoresMean3.length - 1]) + parseFloat(this.scoresSTD3[this.scoresSTD3.length - 1]))
this.scoresNegative3.push(parseFloat(this.scoresMean3[this.scoresMean3.length - 1]) - parseFloat(this.scoresSTD3[this.scoresSTD3.length - 1])) this.scoresNegative3.push(parseFloat(this.scoresMean3[this.scoresMean3.length - 1]) - parseFloat(this.scoresSTD3[this.scoresSTD3.length - 1]))
this.scoresMean4.push((JSON.parse(this.FinalResultsforLinePlot[6])*100).toFixed(2)) this.scoresMean4.push((JSON.parse(this.FinalResultsforLinePlot[12])*100).toFixed(2))
this.scoresSTD4.push((JSON.parse(this.FinalResultsforLinePlot[7])*100).toFixed(2)) this.scoresSTD4.push((JSON.parse(this.FinalResultsforLinePlot[13])*100).toFixed(2))
this.scoresPositive4.push(parseFloat(this.scoresMean4[this.scoresMean4.length - 1]) + parseFloat(this.scoresSTD4[this.scoresSTD4.length - 1])) this.scoresPositive4.push(parseFloat(this.scoresMean4[this.scoresMean4.length - 1]) + parseFloat(this.scoresSTD4[this.scoresSTD4.length - 1]))
this.scoresNegative4.push(parseFloat(this.scoresMean4[this.scoresMean4.length - 1]) - parseFloat(this.scoresSTD4[this.scoresSTD4.length - 1])) this.scoresNegative4.push(parseFloat(this.scoresMean4[this.scoresMean4.length - 1]) - parseFloat(this.scoresSTD4[this.scoresSTD4.length - 1]))
// Stack // Stack
this.Stack_scoresMean.push((JSON.parse(this.FinalResultsforLinePlot[8])*100).toFixed(2)) this.Stack_scoresMean.push((JSON.parse(this.FinalResultsforLinePlot[2])*100).toFixed(2))
this.Stack_scoresSTD.push((JSON.parse(this.FinalResultsforLinePlot[9])*100).toFixed(2)) this.Stack_scoresSTD.push((JSON.parse(this.FinalResultsforLinePlot[3])*100).toFixed(2))
this.Stack_scoresPositive.push(parseFloat(this.Stack_scoresMean[this.Stack_scoresMean.length - 1]) + parseFloat(this.Stack_scoresSTD[this.Stack_scoresSTD.length - 1])) this.Stack_scoresPositive.push(parseFloat(this.Stack_scoresMean[this.Stack_scoresMean.length - 1]) + parseFloat(this.Stack_scoresSTD[this.Stack_scoresSTD.length - 1]))
this.Stack_scoresNegative.push(parseFloat(this.Stack_scoresMean[this.Stack_scoresMean.length - 1]) - parseFloat(this.Stack_scoresSTD[this.Stack_scoresSTD.length - 1])) this.Stack_scoresNegative.push(parseFloat(this.Stack_scoresMean[this.Stack_scoresMean.length - 1]) - parseFloat(this.Stack_scoresSTD[this.Stack_scoresSTD.length - 1]))
this.Stack_scoresMean2.push((JSON.parse(this.FinalResultsforLinePlot[10])*100).toFixed(2)) this.Stack_scoresMean2.push((JSON.parse(this.FinalResultsforLinePlot[6])*100).toFixed(2))
this.Stack_scoresSTD2.push((JSON.parse(this.FinalResultsforLinePlot[11])*100).toFixed(2)) this.Stack_scoresSTD2.push((JSON.parse(this.FinalResultsforLinePlot[7])*100).toFixed(2))
this.Stack_scoresPositive2.push(parseFloat(this.Stack_scoresMean2[this.Stack_scoresMean2.length - 1]) + parseFloat(this.Stack_scoresSTD2[this.Stack_scoresSTD2.length - 1])) this.Stack_scoresPositive2.push(parseFloat(this.Stack_scoresMean2[this.Stack_scoresMean2.length - 1]) + parseFloat(this.Stack_scoresSTD2[this.Stack_scoresSTD2.length - 1]))
this.Stack_scoresNegative2.push(parseFloat(this.Stack_scoresMean2[this.Stack_scoresMean2.length - 1]) - parseFloat(this.Stack_scoresSTD2[this.Stack_scoresSTD2.length - 1])) this.Stack_scoresNegative2.push(parseFloat(this.Stack_scoresMean2[this.Stack_scoresMean2.length - 1]) - parseFloat(this.Stack_scoresSTD2[this.Stack_scoresSTD2.length - 1]))
this.Stack_scoresMean3.push((JSON.parse(this.FinalResultsforLinePlot[12])*100).toFixed(2)) this.Stack_scoresMean3.push((JSON.parse(this.FinalResultsforLinePlot[10])*100).toFixed(2))
this.Stack_scoresSTD3.push((JSON.parse(this.FinalResultsforLinePlot[13])*100).toFixed(2)) this.Stack_scoresSTD3.push((JSON.parse(this.FinalResultsforLinePlot[11])*100).toFixed(2))
this.Stack_scoresPositive3.push(parseFloat(this.Stack_scoresMean3[this.Stack_scoresMean3.length - 1]) + parseFloat(this.Stack_scoresSTD3[this.Stack_scoresSTD3.length - 1])) this.Stack_scoresPositive3.push(parseFloat(this.Stack_scoresMean3[this.Stack_scoresMean3.length - 1]) + parseFloat(this.Stack_scoresSTD3[this.Stack_scoresSTD3.length - 1]))
this.Stack_scoresNegative3.push(parseFloat(this.Stack_scoresMean3[this.Stack_scoresMean3.length - 1]) - parseFloat(this.Stack_scoresSTD3[this.Stack_scoresSTD3.length - 1])) this.Stack_scoresNegative3.push(parseFloat(this.Stack_scoresMean3[this.Stack_scoresMean3.length - 1]) - parseFloat(this.Stack_scoresSTD3[this.Stack_scoresSTD3.length - 1]))

@ -275,6 +275,8 @@ export default Vue.extend({
provenanceData: '', provenanceData: '',
localFile: '', localFile: '',
toggleDeepMain: 1, toggleDeepMain: 1,
keyLoc: 0,
keyData: true,
} }
}, },
methods: { methods: {
@ -324,13 +326,13 @@ export default Vue.extend({
this.OverviewResults = response.data.OverviewResults this.OverviewResults = response.data.OverviewResults
console.log('Server successfully sent all the data related to visualizations!') console.log('Server successfully sent all the data related to visualizations!')
EventBus.$emit('emittedEventCallingScatterPlot', this.OverviewResults) EventBus.$emit('emittedEventCallingScatterPlot', this.OverviewResults)
if (this.firstTimeFlag == 1) { // if (this.firstTimeFlag == 1) {
this.selectedModels_Stack.push(0) // this.selectedModels_Stack.push(0)
this.selectedModels_Stack.push(JSON.stringify(this.modelsUpdate)) // this.selectedModels_Stack.push(JSON.stringify(this.modelsUpdate))
EventBus.$emit('ParametersProvenance', this.OverviewResults) // EventBus.$emit('ParametersProvenance', this.OverviewResults)
EventBus.$emit('InitializeProvenance', this.selectedModels_Stack) // EventBus.$emit('InitializeProvenance', this.selectedModels_Stack)
} // }
this.firstTimeFlag = 0 // this.firstTimeFlag = 0
EventBus.$emit('InitializeMetricsBarChart', this.OverviewResults) EventBus.$emit('InitializeMetricsBarChart', this.OverviewResults)
this.valueSel = 0 this.valueSel = 0
this.valueAll = 0 this.valueAll = 0
@ -350,6 +352,13 @@ export default Vue.extend({
EventBus.$emit('emittedEventCallingPredictionsSpacePlotView', this.OverviewResults) EventBus.$emit('emittedEventCallingPredictionsSpacePlotView', this.OverviewResults)
EventBus.$emit('emittedEventCallingBalanceView', this.OverviewResults) EventBus.$emit('emittedEventCallingBalanceView', this.OverviewResults)
this.DataSpaceCall() this.DataSpaceCall()
if (this.keyData) {
this.selectedModels_Stack.push(0)
this.selectedModels_Stack.push(JSON.stringify(this.modelsUpdate))
EventBus.$emit('ParametersProvenance', this.OverviewResults)
EventBus.$emit('InitializeProvenance', this.selectedModels_Stack)
}
this.getFinalResults()
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
@ -407,7 +416,6 @@ export default Vue.extend({
this.OverSelLength = 0 this.OverSelLength = 0
EventBus.$emit('resetViews') EventBus.$emit('resetViews')
} else { } else {
console.log(this.keyNow)
this.OverSelLength = this.ClassifierIDsList.length this.OverSelLength = this.ClassifierIDsList.length
const path = `http://127.0.0.1:5000/data/ServerRequestSelPoin` const path = `http://127.0.0.1:5000/data/ServerRequestSelPoin`
const postData = { const postData = {
@ -455,7 +463,6 @@ export default Vue.extend({
console.log('Sent the selected points to the server (scatterplot)!') console.log('Sent the selected points to the server (scatterplot)!')
EventBus.$emit('updateFlagForFinalResults', 0) EventBus.$emit('updateFlagForFinalResults', 0)
this.updatePredictionsSpace() this.updatePredictionsSpace()
this.getFinalResults()
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
@ -826,9 +833,10 @@ export default Vue.extend({
EventBus.$emit('emittedEventCallingTogglesUpdate', toggles) EventBus.$emit('emittedEventCallingTogglesUpdate', toggles)
}, },
DataSpaceFun () { DataSpaceFun () {
this.keyData = false
const path = `http://127.0.0.1:5000/data/SendDataSpacPoints` const path = `http://127.0.0.1:5000/data/SendDataSpacPoints`
const postData = { const postData = {
points: this.dataPointsSelfromDataSpace points: this.dataPointsSelfromDataSpace,
} }
const axiosConfig = { const axiosConfig = {
headers: { headers: {
@ -961,6 +969,9 @@ export default Vue.extend({
$(window).on("unload", function(e) { $(window).on("unload", function(e) {
alert('Handler for .unload() called.'); alert('Handler for .unload() called.');
}) })
EventBus.$on('sendKeyNow', data => { this.keyLoc = data })
EventBus.$on('ReturningBrushedPointsIDs', data => { this.modelsUpdate = data }) EventBus.$on('ReturningBrushedPointsIDs', data => { this.modelsUpdate = data })
//EventBus.$on('ReturningBrushedPointsIDs', this.UpdateBarChartFeatures ) //EventBus.$on('ReturningBrushedPointsIDs', this.UpdateBarChartFeatures )
EventBus.$on('ConfirmDataSet', this.fileNameSend) EventBus.$on('ConfirmDataSet', this.fileNameSend)

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<div class="squares-container" style="min-height: 374px;"> <div class="squares-container" style="min-height: 374px; margin-left: 35px">
<div id="tooltip"></div> <!-- new --> <div id="tooltip"></div> <!-- new -->
<div id="performanceCapture" style="min-height: 150px; margin-top: -10px !important;"></div> <!-- new --> <div id="performanceCapture" style="min-height: 150px; margin-top: -10px !important;"></div> <!-- new -->
<canvas id="main-canvas" style="overflow-y: auto; overflow-x: auto; height:190px;"></canvas> <canvas id="main-canvas" style="overflow-y: auto; overflow-x: auto; height:190px;"></canvas>
@ -53,7 +53,7 @@ export default {
Stack_scoresMean2: [], Stack_scoresMean2: [],
Stack_scoresMean3: [], Stack_scoresMean3: [],
Stack_scoresMean4: [], Stack_scoresMean4: [],
firstInside: 0 firstInside: 0,
} }
}, },
methods: { methods: {
@ -356,9 +356,8 @@ export default {
var btn = document.getElementById($(this).attr('id')); var btn = document.getElementById($(this).attr('id'));
btn.style.fontWeight = 'bold'; btn.style.fontWeight = 'bold';
EventBus.$emit('requestProven',parseInt($(this).attr('id').replace(/\D/g,''))-1)
EventBus.$emit('ChangeKey', 0) EventBus.$emit('ChangeKey', 0)
EventBus.$emit('requestProven',parseInt($(this).attr('id').replace(/\D/g,''))-1)
} }
); );
}, },
@ -376,17 +375,15 @@ export default {
this.Stack_scoresMean3 = [] this.Stack_scoresMean3 = []
this.Stack_scoresMean4 = [] this.Stack_scoresMean4 = []
this.Stack_scoresMean.push((JSON.parse(this.FinalResultsProv[0])*100).toFixed(0)) this.Stack_scoresMean.push((JSON.parse(this.FinalResultsProv[0])*100).toFixed(1))
this.Stack_scoresMean2.push((JSON.parse(this.FinalResultsProv[2])*100).toFixed(0)) this.Stack_scoresMean2.push((JSON.parse(this.FinalResultsProv[4])*100).toFixed(1))
this.Stack_scoresMean3.push((JSON.parse(this.FinalResultsProv[4])*100).toFixed(0)) this.Stack_scoresMean3.push((JSON.parse(this.FinalResultsProv[8])*100).toFixed(1))
this.Stack_scoresMean4.push((JSON.parse(this.FinalResultsProv[6])*100).toFixed(0)) this.Stack_scoresMean4.push((JSON.parse(this.FinalResultsProv[12])*100).toFixed(1))
const colorsSingle = ['#fc9272','#fb6a4a','#ef3b2c','#cb181d','#a50f15','#67000d'] const colorsSingle = ['#fdd0a2','#f16913','#7f2704']
var scaleColor = d3v5.scaleLinear() var scaleColor = d3v5.scaleSequential(d3v5.interpolateReds)
.domain([0,100,5]) .domain([0, 100])
.range(colorsSingle)
.interpolate(d3v5.interpolateRgb); //interpolateHsl interpolateHcl interpolateRgb;
var data = [ var data = [
{value: this.Stack_scoresMean, label: "Accuracy", color: scaleColor(this.Stack_scoresMean)}, {value: this.Stack_scoresMean, label: "Accuracy", color: scaleColor(this.Stack_scoresMean)},
@ -395,7 +392,7 @@ export default {
{value: this.Stack_scoresMean4, label: "F1 Score", color: scaleColor(this.Stack_scoresMean4)} {value: this.Stack_scoresMean4, label: "F1 Score", color: scaleColor(this.Stack_scoresMean4)}
]; ];
var svg = d3.select('#svg'+this.firstInside).attr('width', width).attr('height', width).style('margin-right', '25px'); var svg = d3.select('#svg'+this.firstInside).attr('width', width).attr('height', width).style('margin-right', '38px');
var arcs = data.map(function (obj, i) { var arcs = data.map(function (obj, i) {
return d3.svg.arc().innerRadius(i * arcSize + innerRadius).outerRadius((i + 1) * arcSize - (width / 100) + innerRadius); return d3.svg.arc().innerRadius(i * arcSize + innerRadius).outerRadius((i + 1) * arcSize - (width / 100) + innerRadius);
@ -477,7 +474,10 @@ export default {
}); });
}, },
updateExtraction () { updateExtraction () {
if (this.flag) {
EventBus.$emit('SendSelectedPointsToServerEvent', this.storeData[this.flagUpdated]) EventBus.$emit('SendSelectedPointsToServerEvent', this.storeData[this.flagUpdated])
}
this.flag = true
var stringParameters = [] var stringParameters = []
var temp = 0 var temp = 0

@ -62,7 +62,8 @@ export default {
UMAPStore: [], UMAPStore: [],
keyLocal: 0, keyLocal: 0,
activeModels: 0, activeModels: 0,
pushModelsRemaining: [] pushModelsRemaining: [],
onlyOnce: true
} }
}, },
methods: { methods: {
@ -382,10 +383,13 @@ export default {
var scat = document.getElementById('OverviewPlotly') var scat = document.getElementById('OverviewPlotly')
Plotly.newPlot(scat, DataGeneral, layout, config) Plotly.newPlot(scat, DataGeneral, layout, config)
if (this.onlyOnce) {
this.selectedPointsOverview() this.selectedPointsOverview()
}
this.onlyOnce = false
}, },
selectedPointsOverview () { selectedPointsOverview () {
console.log('mpike')
const OverviewPlotly = document.getElementById('OverviewPlotly') const OverviewPlotly = document.getElementById('OverviewPlotly')
var allModels = JSON.parse(this.ScatterPlotResults[13]) var allModels = JSON.parse(this.ScatterPlotResults[13])
OverviewPlotly.on('plotly_selected', function (evt) { OverviewPlotly.on('plotly_selected', function (evt) {
@ -416,7 +420,6 @@ export default {
EventBus.$emit('SendSelectedPointsToBrushHeatmap', ClassifierIDsListCleared) EventBus.$emit('SendSelectedPointsToBrushHeatmap', ClassifierIDsListCleared)
} else { } else {
EventBus.$emit('ChangeKey', 1) EventBus.$emit('ChangeKey', 1)
EventBus.$emit('SendSelectedPointsToServerEvent', '')
} }
} }
}) })

207
run.py

@ -67,6 +67,14 @@ cors = CORS(app, resources={r"/data/*": {"origins": "*"}})
def Reset(): def Reset():
global DataRawLength global DataRawLength
global DataResultsRaw global DataResultsRaw
global previousState
previousState = []
global keySpecInternal
keySpecInternal = 1
global previousStateActive
previousStateActive = []
global RANDOM_SEED global RANDOM_SEED
RANDOM_SEED = 42 RANDOM_SEED = 42
@ -86,6 +94,9 @@ def Reset():
global AdaBModelsCount global AdaBModelsCount
global GradBModelsCount global GradBModelsCount
global keyData
keyData = 0
KNNModelsCount = 0 KNNModelsCount = 0
SVCModelsCount = 576 SVCModelsCount = 576
GausNBModelsCount = 736 GausNBModelsCount = 736
@ -168,12 +179,24 @@ def RetrieveFileName():
fileName = request.get_data().decode('utf8').replace("'", '"') fileName = request.get_data().decode('utf8').replace("'", '"')
global keySpecInternal
keySpecInternal = 1
global RANDOM_SEED global RANDOM_SEED
RANDOM_SEED = 42 RANDOM_SEED = 42
global keyData
keyData = 0
global XData global XData
XData = [] XData = []
global previousState
previousState = []
global previousStateActive
previousStateActive = []
global yData global yData
yData = [] yData = []
@ -1686,9 +1709,10 @@ def RetrieveSelClassifiersID():
ComputeMetricsForSel(ClassifierIDsList) ComputeMetricsForSel(ClassifierIDsList)
ClassifierIDCleaned = json.loads(ClassifierIDsList) ClassifierIDCleaned = json.loads(ClassifierIDsList)
global keySpec global keySpecInternal
keySpec = ClassifierIDCleaned['keyNow'] keySpecInternal = 1
print(keySpec) keySpecInternal = ClassifierIDCleaned['keyNow']
EnsembleModel(ClassifierIDsList, 1) EnsembleModel(ClassifierIDsList, 1)
return 'Everything Okay' return 'Everything Okay'
@ -2429,6 +2453,11 @@ def FeatureSelPerModel():
def EnsembleModel(Models, keyRetrieved): def EnsembleModel(Models, keyRetrieved):
global scores global scores
global previousState
global previousStateActive
global keySpec
global keySpecInternal
global keyData
scores = [] scores = []
global all_classifiersSelection global all_classifiersSelection
@ -2581,9 +2610,6 @@ def EnsembleModel(Models, keyRetrieved):
arg = dfParamGradBFilt[eachelem-GradBModelsCount] arg = dfParamGradBFilt[eachelem-GradBModelsCount]
all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsInit), GradientBoostingClassifier(random_state=RANDOM_SEED).set_params(**arg))) all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsInit), GradientBoostingClassifier(random_state=RANDOM_SEED).set_params(**arg)))
global sclfStack
sclfStack = 0
global sclf global sclf
sclf = 0 sclf = 0
sclf = StackingCVClassifier(classifiers=all_classifiers, sclf = StackingCVClassifier(classifiers=all_classifiers,
@ -2591,11 +2617,10 @@ def EnsembleModel(Models, keyRetrieved):
meta_classifier=lr, meta_classifier=lr,
random_state=RANDOM_SEED, random_state=RANDOM_SEED,
n_jobs = -1) n_jobs = -1)
sclfStack = sclf keySpec = 0
elif (keyRetrieved == 1): elif (keyRetrieved == 1):
Models = json.loads(Models) Models = json.loads(Models)
ModelsAll = preProceModels() ModelsAll = preProceModels()
global keySpec
for index, modHere in enumerate(ModelsAll): for index, modHere in enumerate(ModelsAll):
flag = 0 flag = 0
for loop in Models['ClassifiersList']: for loop in Models['ClassifiersList']:
@ -2609,11 +2634,8 @@ def EnsembleModel(Models, keyRetrieved):
meta_classifier=lr, meta_classifier=lr,
random_state=RANDOM_SEED, random_state=RANDOM_SEED,
n_jobs = -1) n_jobs = -1)
print('mpike') keySpec = 1
if (keySpec == 0):
sclfStack = sclf
elif (keyRetrieved == 2): elif (keyRetrieved == 2):
# fix this part!
if (len(all_classifiersSelection) == 0): if (len(all_classifiersSelection) == 0):
all_classifiers = [] all_classifiers = []
columnsInit = [] columnsInit = []
@ -2769,22 +2791,25 @@ def EnsembleModel(Models, keyRetrieved):
meta_classifier=lr, meta_classifier=lr,
random_state=RANDOM_SEED, random_state=RANDOM_SEED,
n_jobs = -1) n_jobs = -1)
keySpec = 1
else: else:
Models = json.loads(Models) keySpec = 2
ModelsAll = preProceModels()
for index, modHere in enumerate(ModelsAll): # Models = json.loads(Models)
flag = 0 # ModelsAll = preProceModels()
for loop in Models['ClassifiersList']: # for index, modHere in enumerate(ModelsAll):
if (int(loop) == int(modHere)): # flag = 0
flag = 1 # for loop in Models['ClassifiersList']:
if (flag is 1): # if (int(loop) == int(modHere)):
all_classifiersSelection.append(all_classifiers[index]) # flag = 1
# if (flag is 1):
sclfStack = StackingCVClassifier(classifiers=all_classifiersSelection, # all_classifiersSelection.append(all_classifiers[index])
use_probas=True,
meta_classifier=lr, # sclfStack = StackingCVClassifier(classifiers=all_classifiersSelection,
random_state=RANDOM_SEED, # use_probas=True,
n_jobs = -1) # meta_classifier=lr,
# random_state=RANDOM_SEED,
# n_jobs = -1)
#else: #else:
@ -2803,24 +2828,134 @@ def EnsembleModel(Models, keyRetrieved):
# random_state=RANDOM_SEED, # random_state=RANDOM_SEED,
# n_jobs = -1) # n_jobs = -1)
if (keyRetrieved == 0): # if (keyRetrieved == 0):
pass # pass
else: # else:
print(keySpec)
print(keySpecInternal)
if (keySpec == 0 or keySpec == 1):
num_cores = multiprocessing.cpu_count() num_cores = multiprocessing.cpu_count()
inputsSc = ['accuracy','precision_weighted','recall_weighted','accuracy','precision_weighted','recall_weighted','f1_weighted','f1_weighted'] inputsSc = ['accuracy','precision_weighted','recall_weighted','f1_weighted']
flat_results = Parallel(n_jobs=num_cores)(delayed(solve)(sclf,sclfStack,XData,yData,crossValidation,item,index) for index, item in enumerate(inputsSc))
flat_results = Parallel(n_jobs=num_cores)(delayed(solve)(sclf,keyData,keySpec,keySpecInternal,previousState,previousStateActive,XData,yData,crossValidation,item,index) for index, item in enumerate(inputsSc))
scores = [item for sublist in flat_results for item in sublist] scores = [item for sublist in flat_results for item in sublist]
if (keySpec == 0):
previousState = []
previousState.append(scores[2])
previousState.append(scores[3])
previousState.append(scores[6])
previousState.append(scores[7])
previousState.append(scores[10])
previousState.append(scores[11])
previousState.append(scores[14])
previousState.append(scores[15])
elif (keySpec == 1):
if (keySpecInternal == 1):
previousStateActive = []
previousStateActive.append(scores[0])
previousStateActive.append(scores[1])
previousStateActive.append(scores[4])
previousStateActive.append(scores[5])
previousStateActive.append(scores[8])
previousStateActive.append(scores[9])
previousStateActive.append(scores[12])
previousStateActive.append(scores[13])
else:
previousStateActive = []
previousStateActive.append(scores[0])
previousStateActive.append(scores[1])
previousStateActive.append(scores[4])
previousStateActive.append(scores[5])
previousStateActive.append(scores[8])
previousStateActive.append(scores[9])
previousStateActive.append(scores[12])
previousStateActive.append(scores[13])
previousState = []
previousState.append(scores[2])
previousState.append(scores[3])
previousState.append(scores[6])
previousState.append(scores[7])
previousState.append(scores[10])
previousState.append(scores[11])
previousState.append(scores[14])
previousState.append(scores[15])
else:
scores = []
previousState = []
scores.append(previousStateActive[0])
scores.append(previousStateActive[1])
scores.append(previousStateActive[0])
scores.append(previousStateActive[1])
previousState.append(previousStateActive[0])
previousState.append(previousStateActive[1])
scores.append(previousStateActive[2])
scores.append(previousStateActive[3])
scores.append(previousStateActive[2])
scores.append(previousStateActive[3])
previousState.append(previousStateActive[2])
previousState.append(previousStateActive[3])
scores.append(previousStateActive[4])
scores.append(previousStateActive[5])
scores.append(previousStateActive[4])
scores.append(previousStateActive[5])
previousState.append(previousStateActive[4])
previousState.append(previousStateActive[5])
scores.append(previousStateActive[6])
scores.append(previousStateActive[7])
scores.append(previousStateActive[6])
scores.append(previousStateActive[7])
previousState.append(previousStateActive[6])
previousState.append(previousStateActive[7])
return 'Okay' return 'Okay'
def solve(sclf,sclfStack,XData,yData,crossValidation,scoringIn,loop): def solve(sclf,keyData,keySpec,keySpecInternal,previousStateLoc,previousStateActiveLoc,XData,yData,crossValidation,scoringIn,loop):
scoresLoc = [] scoresLoc = []
if (loop < 3): if (keySpec == 0):
temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring=scoringIn, n_jobs=-1) temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring=scoringIn, n_jobs=-1)
scoresLoc.append(temp.mean())
scoresLoc.append(temp.std())
if (keyData == 1):
if (loop == 0):
scoresLoc.append(previousStateLoc[0])
scoresLoc.append(previousStateLoc[1])
elif (loop == 1):
scoresLoc.append(previousStateLoc[2])
scoresLoc.append(previousStateLoc[3])
elif (loop == 2):
scoresLoc.append(previousStateLoc[4])
scoresLoc.append(previousStateLoc[5])
else:
scoresLoc.append(previousStateLoc[6])
scoresLoc.append(previousStateLoc[7])
else:
scoresLoc.append(temp.mean())
scoresLoc.append(temp.std())
else: else:
temp = model_selection.cross_val_score(sclfStack, XData, yData, cv=crossValidation, scoring=scoringIn, n_jobs=-1) if (keySpecInternal == 1):
temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring=scoringIn, n_jobs=-1)
scoresLoc.append(temp.mean()) scoresLoc.append(temp.mean())
scoresLoc.append(temp.std()) scoresLoc.append(temp.std())
if (loop == 0):
scoresLoc.append(previousStateLoc[0])
scoresLoc.append(previousStateLoc[1])
elif (loop == 1):
scoresLoc.append(previousStateLoc[2])
scoresLoc.append(previousStateLoc[3])
elif (loop == 2):
scoresLoc.append(previousStateLoc[4])
scoresLoc.append(previousStateLoc[5])
else:
scoresLoc.append(previousStateLoc[6])
scoresLoc.append(previousStateLoc[7])
else:
temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring=scoringIn, n_jobs=-1)
scoresLoc.append(temp.mean())
scoresLoc.append(temp.std())
scoresLoc.append(temp.mean())
scoresLoc.append(temp.std())
return scoresLoc return scoresLoc
# Sending the final results to be visualized as a line plot # Sending the final results to be visualized as a line plot
@ -2856,6 +2991,8 @@ def RetrieveFilter():
def RetrieveDataSpacePoints(): def RetrieveDataSpacePoints():
dataSpacePoints = request.get_data().decode('utf8').replace("'", '"') dataSpacePoints = request.get_data().decode('utf8').replace("'", '"')
dataSpacePointsCleared = json.loads(dataSpacePoints) dataSpacePointsCleared = json.loads(dataSpacePoints)
global keyData
keyData = 1
global dataSpacePointsIDs global dataSpacePointsIDs
dataSpacePointsIDs = dataSpacePointsCleared['points'] dataSpacePointsIDs = dataSpacePointsCleared['points']
return 'Done' return 'Done'

Loading…
Cancel
Save