provenance, overview

master
parent ec6b7e75ff
commit 4987cda12a
  1. BIN
      __pycache__/run.cpython-37.pyc
  2. 2
      cachedir/joblib/run/EnsembleModel/caf5346693cf07e3226b8e0c61576f07/metadata.json
  3. BIN
      cachedir/joblib/run/EnsembleModel/caf5346693cf07e3226b8e0c61576f07/output.pkl
  4. 4
      cachedir/joblib/run/EnsembleModel/func_code.py
  5. 1
      cachedir/joblib/run/GridSearchForModels/10f352afa4c8547af96ab9905e3cfc87/metadata.json
  6. BIN
      cachedir/joblib/run/GridSearchForModels/1ace3632acb8ced29677b3bf1fd54ebb/output.pkl
  7. 1
      cachedir/joblib/run/GridSearchForModels/31e5f1d3030e082c3456a2cce3d41800/metadata.json
  8. BIN
      cachedir/joblib/run/GridSearchForModels/4b0679293742f99381cce3660e671df7/output.pkl
  9. 2
      cachedir/joblib/run/GridSearchForModels/7ed3e4ea234ba6e59e062c08100338df/metadata.json
  10. BIN
      cachedir/joblib/run/GridSearchForModels/e32f76451401c1a4c95d459bb4c74ce5/output.pkl
  11. 8
      cachedir/joblib/run/GridSearchForModels/func_code.py
  12. 569
      frontend/package-lock.json
  13. 20
      frontend/package.json
  14. 2
      frontend/src/components/AlgorithmHyperParam.vue
  15. 4
      frontend/src/components/Algorithms.vue
  16. 36
      frontend/src/components/BalancePredictions.vue
  17. 25
      frontend/src/components/DataSpace.vue
  18. 202
      frontend/src/components/FinalResultsLinePlot.vue
  19. 57
      frontend/src/components/Heatmap.vue
  20. 105
      frontend/src/components/Main.vue
  21. 528
      frontend/src/components/Parameters.vue
  22. 76
      frontend/src/components/PerMetricBarChart.vue
  23. 53
      frontend/src/components/PredictionsSpace.vue
  24. 71
      frontend/src/components/Provenance.vue
  25. 106
      frontend/src/components/ScatterPlot.vue
  26. 638
      run.py

Binary file not shown.

@ -1 +1 @@
{"duration": 52.6987738609314, "input_args": {"keyRetrieved": "0"}} {"duration": 31.525413036346436, "input_args": {"keyRetrieved": "0"}}

@ -1,4 +1,4 @@
# first line: 669 # first line: 703
@memory.cache @memory.cache
def EnsembleModel(keyRetrieved): def EnsembleModel(keyRetrieved):
@ -22,7 +22,7 @@ def EnsembleModel(keyRetrieved):
dfParamRF = pd.DataFrame.from_dict(temp) dfParamRF = pd.DataFrame.from_dict(temp)
dfParamRFFilt = dfParamRF.iloc[:,1] dfParamRFFilt = dfParamRF.iloc[:,1]
for eachelem in RFModels: for eachelem in RFModels:
arg = dfParamRFFilt[eachelem] arg = dfParamRFFilt[eachelem-576]
all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsInit), RandomForestClassifier().set_params(**arg))) all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsInit), RandomForestClassifier().set_params(**arg)))
lr = LogisticRegression() lr = LogisticRegression()

@ -0,0 +1 @@
{"duration": 348.3931636810303, "input_args": {"clf": "RandomForestClassifier(bootstrap=True, class_weight=None, criterion='entropy',\n max_depth=None, max_features='auto', max_leaf_nodes=None,\n min_impurity_decrease=0.0, min_impurity_split=None,\n min_samples_leaf=1, min_samples_split=2,\n min_weight_fraction_leaf=0.0, n_estimators=119,\n n_jobs=None, oob_score=False, random_state=None,\n verbose=0, warm_start=False)", "params": "{'n_estimators': [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119], 'criterion': ['gini', 'entropy']}", "eachAlgor": "'RF'", "factors": "[1, 1, 1, 1, 1]", "AlgorithmsIDsEnd": "576"}}

@ -1 +0,0 @@
{"duration": 218.97025108337402, "input_args": {"clf": "RandomForestClassifier(bootstrap=True, class_weight=None, criterion='entropy',\n max_depth=None, max_features='auto', max_leaf_nodes=None,\n min_impurity_decrease=0.0, min_impurity_split=None,\n min_samples_leaf=1, min_samples_split=2,\n min_weight_fraction_leaf=0.0, n_estimators=119,\n n_jobs=None, oob_score=False, random_state=None,\n verbose=0, warm_start=False)", "params": "{'n_estimators': [80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119], 'criterion': ['gini', 'entropy']}", "eachAlgor": "'RF'", "factors": "[1, 1, 1, 1, 1]", "AlgorithmsIDsEnd": "576"}}

@ -1 +1 @@
{"duration": 268.4585440158844, "input_args": {"clf": "KNeighborsClassifier(algorithm='ball_tree', leaf_size=30, metric='minkowski',\n metric_params=None, n_jobs=None, n_neighbors=24, p=2,\n weights='distance')", "params": "{'n_neighbors': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 'weights': ['uniform', 'distance'], 'algorithm': ['brute', 'kd_tree', 'ball_tree'], 'metric': ['chebyshev', 'manhattan', 'euclidean', 'minkowski']}", "eachAlgor": "'KNN'", "factors": "[1, 1, 1, 1, 1]", "AlgorithmsIDsEnd": "0"}} {"duration": 258.0446789264679, "input_args": {"clf": "KNeighborsClassifier(algorithm='ball_tree', leaf_size=30, metric='minkowski',\n metric_params=None, n_jobs=None, n_neighbors=24, p=2,\n weights='distance')", "params": "{'n_neighbors': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], 'weights': ['uniform', 'distance'], 'algorithm': ['brute', 'kd_tree', 'ball_tree'], 'metric': ['chebyshev', 'manhattan', 'euclidean', 'minkowski']}", "eachAlgor": "'KNN'", "factors": "[1, 1, 1, 1, 1]", "AlgorithmsIDsEnd": "0"}}

@ -1,4 +1,4 @@
# first line: 310 # first line: 307
@memory.cache @memory.cache
def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd): def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
@ -78,6 +78,7 @@ def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
permList = [] permList = []
PerFeatureAccuracy = [] PerFeatureAccuracy = []
PerFeatureAccuracyAll = []
PerClassMetric = [] PerClassMetric = []
perModelProb = [] perModelProb = []
@ -88,10 +89,11 @@ def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
permList.append(perm.feature_importances_) permList.append(perm.feature_importances_)
n_feats = XData.shape[1] n_feats = XData.shape[1]
PerFeatureAccuracy = []
for i in range(n_feats): for i in range(n_feats):
scores = model_selection.cross_val_score(clf, XData.values[:, i].reshape(-1, 1), yData, cv=crossValidation) scores = model_selection.cross_val_score(clf, XData.values[:, i].reshape(-1, 1), yData, cv=crossValidation)
PerFeatureAccuracy.append(scores.mean()) PerFeatureAccuracy.append(scores.mean())
PerFeatureAccuracyAll.append(PerFeatureAccuracy)
clf.fit(XData, yData) clf.fit(XData, yData)
yPredict = clf.predict(XData) yPredict = clf.predict(XData)
# retrieve target names (class names) # retrieve target names (class names)
@ -112,7 +114,7 @@ def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
perm_imp_eli5PD = pd.DataFrame(permList) perm_imp_eli5PD = pd.DataFrame(permList)
perm_imp_eli5PD = perm_imp_eli5PD.to_json() perm_imp_eli5PD = perm_imp_eli5PD.to_json()
PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracy) PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracyAll)
PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json() PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json()
bestfeatures = SelectKBest(score_func=chi2, k='all') bestfeatures = SelectKBest(score_func=chi2, k='all')

File diff suppressed because it is too large Load Diff

@ -11,15 +11,15 @@
"start": "npm run dev" "start": "npm run dev"
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.6.2", "@babel/core": "^7.6.4",
"@babel/runtime": "^7.6.2", "@babel/runtime": "^7.6.3",
"@fortawesome/fontawesome-free": "^5.11.2", "@fortawesome/fontawesome-free": "^5.11.2",
"@fortawesome/fontawesome-svg-core": "^1.2.25", "@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-solid-svg-icons": "^5.11.2", "@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fortawesome/vue-fontawesome": "^0.1.7", "@fortawesome/vue-fontawesome": "^0.1.7",
"@statnett/vue-plotly": "^0.3.2", "@statnett/vue-plotly": "^0.3.2",
"@types/d3-drag": "^1.2.3", "@types/d3-drag": "^1.2.3",
"@types/node": "^12.7.11", "@types/node": "^12.7.12",
"ajv": "^6.10.2", "ajv": "^6.10.2",
"audit": "0.0.6", "audit": "0.0.6",
"axios": "^0.19.0", "axios": "^0.19.0",
@ -28,7 +28,7 @@
"blob": "0.0.5", "blob": "0.0.5",
"bootstrap": "^4.3.1", "bootstrap": "^4.3.1",
"bootstrap-toggle": "^2.2.2", "bootstrap-toggle": "^2.2.2",
"bootstrap-vue": "^2.0.3", "bootstrap-vue": "^2.0.4",
"circlepack-chart": "^1.3.0", "circlepack-chart": "^1.3.0",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"colorbrewer": "^1.3.0", "colorbrewer": "^1.3.0",
@ -53,7 +53,7 @@
"npm-check-updates": "^3.1.24", "npm-check-updates": "^3.1.24",
"papaparse": "^5.1.0", "papaparse": "^5.1.0",
"parcoord-es": "^2.2.10", "parcoord-es": "^2.2.10",
"plotly.js": "^1.49.5", "plotly.js": "^1.50.0",
"popper.js": "^1.15.0", "popper.js": "^1.15.0",
"react": "^16.10.2", "react": "^16.10.2",
"react-dom": "^16.10.2", "react-dom": "^16.10.2",
@ -64,7 +64,7 @@
"toposort": "^2.0.2", "toposort": "^2.0.2",
"transform-loader": "^0.2.4", "transform-loader": "^0.2.4",
"update": "^0.7.4", "update": "^0.7.4",
"vega": "^5.7.0", "vega": "^5.7.2",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-bootstrap-slider": "^2.1.8", "vue-bootstrap-slider": "^2.1.8",
"vue-papa-parse": "^1.2.2", "vue-papa-parse": "^1.2.2",
@ -87,8 +87,8 @@
"@babel/plugin-syntax-import-meta": "^7.2.0", "@babel/plugin-syntax-import-meta": "^7.2.0",
"@babel/plugin-syntax-jsx": "^7.2.0", "@babel/plugin-syntax-jsx": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.6.2", "@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.2", "@babel/preset-env": "^7.6.3",
"autoprefixer": "^9.6.4", "autoprefixer": "^9.6.5",
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"babel-helper-vue-jsx-merge-props": "^2.0.3", "babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
@ -124,14 +124,14 @@
"uglifyjs-webpack-plugin": "^2.2.0", "uglifyjs-webpack-plugin": "^2.2.0",
"url-loader": "^2.2.0", "url-loader": "^2.2.0",
"vue-class-component": "^7.1.0", "vue-class-component": "^7.1.0",
"vue-cli-plugin-vuetify": "^0.6.3", "vue-cli-plugin-vuetify": "^1.0.1",
"vue-loader": "^15.7.1", "vue-loader": "^15.7.1",
"vue-property-decorator": "^8.2.2", "vue-property-decorator": "^8.2.2",
"vue-style-loader": "^4.1.2", "vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.6.10", "vue-template-compiler": "^2.6.10",
"vue2-simplert": "^1.0.0", "vue2-simplert": "^1.0.0",
"vuetify-loader": "^1.3.0", "vuetify-loader": "^1.3.0",
"webpack": "^4.41.0", "webpack": "^4.41.1",
"webpack-bundle-analyzer": "^3.5.2", "webpack-bundle-analyzer": "^3.5.2",
"webpack-dev-server": "^3.8.2", "webpack-dev-server": "^3.8.2",
"webpack-merge": "^4.2.2" "webpack-merge": "^4.2.2"

@ -26,7 +26,7 @@ export default {
PCPView () { PCPView () {
d3.selectAll("#PCP > *").remove(); d3.selectAll("#PCP > *").remove();
if (this.selAlgorithm != '') { if (this.selAlgorithm != '') {
var colors = ['#8dd3c7','#ffffb3','#bebada','#fb8072','#80b1d3','#fdb462','#b3de69','#fccde5','#d9d9d9','#bc80bd','#ccebc5','#ffed6f'] var colors = ['#8dd3c7','#8da0cb']
var colorGiv = 0 var colorGiv = 0
var Combined = 0 var Combined = 0

@ -76,7 +76,7 @@ export default {
this.chart('#exploding_boxplot') this.chart('#exploding_boxplot')
// colorscale // colorscale
const previousColor = ['#8dd3c7','#ffffb3','#bebada','#fb8072','#80b1d3','#fdb462','#b3de69','#fccde5','#d9d9d9','#bc80bd','#ccebc5','#ffed6f'] const previousColor = ['#8dd3c7','#8da0cb']
// check for brushing // check for brushing
var el = document.getElementsByClassName('d3-exploding-boxplot boxcontent') var el = document.getElementsByClassName('d3-exploding-boxplot boxcontent')
this.brushStatus = document.getElementsByClassName('extent') this.brushStatus = document.getElementsByClassName('extent')
@ -178,7 +178,7 @@ export default {
} else { } else {
var allPoints = document.getElementsByClassName('d3-exploding-boxplot point RF') var allPoints = document.getElementsByClassName('d3-exploding-boxplot point RF')
} }
const previousColor = ['#8dd3c7','#ffffb3','#bebada','#fb8072','#80b1d3','#fdb462','#b3de69','#fccde5','#d9d9d9','#bc80bd','#ccebc5','#ffed6f'] const previousColor = ['#8dd3c7','#8da0cb']
var modelsActive = [] var modelsActive = []
for (let j = 0; j < this.brushedBoxPl.length; j++) { for (let j = 0; j < this.brushedBoxPl.length; j++) {
modelsActive.push(this.brushedBoxPl[j].model) modelsActive.push(this.brushedBoxPl[j].model)

@ -16,14 +16,23 @@
data () { data () {
return { return {
resultsfromOverview: 0, resultsfromOverview: 0,
WH: []
} }
}, },
methods: { methods: {
Balance () { Balance () {
// Clear Heatmap first
var svg = d3.select("#my_dataviz");
svg.selectAll("*").remove();
var widthInitial = this.WH[0]*3 // interactive visualization
var heightInitial = this.WH[1]/1.6 // interactive visualization
// set the dimensions and margins of the graph // set the dimensions and margins of the graph
var margin = {top: 30, right: 30, bottom: 30, left: 60}, var margin = {top: 10, right: 30, bottom: 50, left: 60},
width = 600 - margin.left - margin.right, width = widthInitial - margin.left - margin.right,
height = 200 - margin.top - margin.bottom; height = heightInitial - margin.top - margin.bottom;
// append the svg object to the body of the page // append the svg object to the body of the page
var svg = d3.select("#my_dataviz") var svg = d3.select("#my_dataviz")
@ -69,8 +78,8 @@
svg.append("path") svg.append("path")
.attr("class", "mypath") .attr("class", "mypath")
.datum(density1) .datum(density1)
.attr("fill", "#69b3a2") .attr("fill", "#000")
.attr("opacity", ".6") .attr("opacity", "1")
.attr("stroke", "#000") .attr("stroke", "#000")
.attr("stroke-width", 1) .attr("stroke-width", 1)
.attr("stroke-linejoin", "round") .attr("stroke-linejoin", "round")
@ -84,8 +93,8 @@
svg.append("path") svg.append("path")
.attr("class", "mypath") .attr("class", "mypath")
.datum(density2) .datum(density2)
.attr("fill", "#404080") .attr("fill", "#00bbbb")
.attr("opacity", ".6") .attr("opacity", "1")
.attr("stroke", "#000") .attr("stroke", "#000")
.attr("stroke-width", 1) .attr("stroke-width", 1)
.attr("stroke-linejoin", "round") .attr("stroke-linejoin", "round")
@ -100,10 +109,11 @@
}) })
// Handmade legend // Handmade legend
svg.append("circle").attr("cx",290).attr("cy",30).attr("r", 6).style("fill", "#69b3a2") var heightforText = 175
svg.append("circle").attr("cx",290).attr("cy",60).attr("r", 6).style("fill", "#404080") svg.append("circle").attr("cx",80).attr("cy",heightforText).attr("r", 6).style("fill", "#000")
svg.append("text").attr("x", 310).attr("y", 30).text("variable A").style("font-size", "15px").attr("alignment-baseline","middle") svg.append("circle").attr("cx",300).attr("cy",heightforText).attr("r", 6).style("fill", "#00bbbb")
svg.append("text").attr("x", 310).attr("y", 60).text("variable B").style("font-size", "15px").attr("alignment-baseline","middle") svg.append("text").attr("x", 100).attr("y", heightforText).text("Entire distribution").style("font-size", "15px").attr("alignment-baseline","middle")
svg.append("text").attr("x", 320).attr("y", heightforText).text("Selected points").style("font-size", "15px").attr("alignment-baseline","middle")
// Function to compute density // Function to compute density
function kernelDensityEstimator(kernel, X) { function kernelDensityEstimator(kernel, X) {
@ -123,6 +133,10 @@
mounted () { mounted () {
EventBus.$on('emittedEventCallingBalanceView', data => { this.resultsfromOverview = data} ) EventBus.$on('emittedEventCallingBalanceView', data => { this.resultsfromOverview = data} )
EventBus.$on('emittedEventCallingBalanceView', this.Balance) EventBus.$on('emittedEventCallingBalanceView', this.Balance)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
} }
} }
</script> </script>

@ -11,12 +11,13 @@ export default {
data () { data () {
return { return {
CollectionData: '', CollectionData: '',
DataSpace: '' DataSpace: '',
WH: []
} }
}, },
methods: { methods: {
ScatterPlotDataView () { ScatterPlotDataView () {
const XandYCoordinates = JSON.parse(this.DataSpace[3]) const XandYCoordinates = JSON.parse(this.DataSpace[7])
var result = XandYCoordinates.reduce(function(r, a) { var result = XandYCoordinates.reduce(function(r, a) {
a.forEach(function(s, i) { a.forEach(function(s, i) {
@ -29,10 +30,21 @@ export default {
return r; return r;
}, {}) }, {})
var dataPointInfo = []
for (let i = 0; i < XandYCoordinates.length; i++) {
dataPointInfo[i] = 'Data Point ID: ' + i
}
var width = this.WH[0]*3 // interactive visualization
var height = this.WH[1]*1.5 // interactive visualization
const Data = [{ const Data = [{
x: result.Xax, x: result.Xax,
y: result.Yax, y: result.Yax,
mode: 'markers', mode: 'markers',
hovertemplate:
"<b>%{text}</b><br><br>" +
"<extra></extra>",
text: dataPointInfo,
}] }]
const layout = { const layout = {
title: 'Data Space Projection (tSNE)', title: 'Data Space Projection (tSNE)',
@ -41,7 +53,10 @@ export default {
}, },
yaxis: { yaxis: {
visible: false visible: false
} },
autosize: true,
width: width,
height: height,
} }
Plotly.newPlot('OverviewDataPlotly', Data, layout, {responsive: true}) Plotly.newPlot('OverviewDataPlotly', Data, layout, {responsive: true})
} }
@ -52,6 +67,10 @@ export default {
EventBus.$on('emittedEventCallingDataSpacePlotView', data => { EventBus.$on('emittedEventCallingDataSpacePlotView', data => {
this.DataSpace = data}) this.DataSpace = data})
EventBus.$on('emittedEventCallingDataSpacePlotView', this.ScatterPlotDataView) EventBus.$on('emittedEventCallingDataSpacePlotView', this.ScatterPlotDataView)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
} }
} }
</script> </script>

@ -16,7 +16,28 @@ export default {
scoresSTD: [], scoresSTD: [],
scoresPositive: [], scoresPositive: [],
scoresNegative: [], scoresNegative: [],
xaxis: [] scoresMean2: [],
scoresSTD2: [],
scoresPositive2: [],
scoresNegative2: [],
scoresMean3: [],
scoresSTD3: [],
scoresPositive3: [],
scoresNegative3: [],
Stack_scoresMean: [],
Stack_scoresSTD: [],
Stack_scoresPositive: [],
Stack_scoresNegative: [],
Stack_scoresMean2: [],
Stack_scoresSTD2: [],
Stack_scoresPositive2: [],
Stack_scoresNegative2: [],
Stack_scoresMean3: [],
Stack_scoresSTD3: [],
Stack_scoresPositive3: [],
Stack_scoresNegative3: [],
xaxis: [],
WH: []
} }
}, },
methods: { methods: {
@ -24,27 +45,66 @@ export default {
this.NumberofExecutions ++ this.NumberofExecutions ++
this.xaxis.push(this.NumberofExecutions) this.xaxis.push(this.NumberofExecutions)
// Under Exploration = Current
console.log(this.FinalResultsforLinePlot)
this.scoresMean.push((JSON.parse(this.FinalResultsforLinePlot[0])*100).toFixed(1)) this.scoresMean.push((JSON.parse(this.FinalResultsforLinePlot[0])*100).toFixed(1))
this.scoresSTD.push((JSON.parse(this.FinalResultsforLinePlot[1])*100).toFixed(1)) this.scoresSTD.push((JSON.parse(this.FinalResultsforLinePlot[1])*100).toFixed(1))
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(1))
this.scoresSTD2.push((JSON.parse(this.FinalResultsforLinePlot[3])*100).toFixed(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.scoresMean3.push((JSON.parse(this.FinalResultsforLinePlot[4])*100).toFixed(1))
this.scoresSTD3.push((JSON.parse(this.FinalResultsforLinePlot[5])*100).toFixed(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]))
// Stack
this.Stack_scoresMean.push((JSON.parse(this.FinalResultsforLinePlot[6])*100).toFixed(1))
this.Stack_scoresSTD.push((JSON.parse(this.FinalResultsforLinePlot[7])*100).toFixed(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_scoresMean2.push((JSON.parse(this.FinalResultsforLinePlot[8])*100).toFixed(1))
this.Stack_scoresSTD2.push((JSON.parse(this.FinalResultsforLinePlot[9])*100).toFixed(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_scoresMean3.push((JSON.parse(this.FinalResultsforLinePlot[10])*100).toFixed(1))
this.Stack_scoresSTD3.push((JSON.parse(this.FinalResultsforLinePlot[11])*100).toFixed(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]))
var xaxisReversed = [] var xaxisReversed = []
xaxisReversed = this.xaxis.slice().reverse() xaxisReversed = this.xaxis.slice().reverse()
xaxisReversed = this.xaxis.concat(xaxisReversed) xaxisReversed = this.xaxis.concat(xaxisReversed)
var width = this.WH[0]*3 // interactive visualization
var height = this.WH[1]*1.5 // interactive visualization
// fill in 'text' array for hover // fill in 'text' array for hover
var text = this.scoresSTD.map (function(value, i) { var text = this.scoresSTD.map (function(value, i) {
return `STD: +/-${value}` return `STD: +/-${value}`
}) })
// Current
var trace1 = { var trace1 = {
x: this.xaxis, x: this.xaxis,
y: this.scoresMean, y: this.scoresMean,
text: text, text: text,
line: {color: "rgb(0,100,80)"}, line: {color: "rgb(127,201,127)"},
mode: "lines+markers", mode: "lines+markers",
name: "Current Accuracy", name: "Current Accuracy",
type: "scatter" type: "scatter"
@ -56,14 +116,141 @@ export default {
text: '', text: '',
hoverinfo: 'text', hoverinfo: 'text',
fill: "tozerox", fill: "tozerox",
fillcolor: "rgba(0,100,80,0.2)", fillcolor: "rgba(127,201,127,0)",
line: {color: "transparent"}, line: {color: "transparent"},
name: "Current Accuracy", name: "Current Accuracy",
showlegend: false, showlegend: false,
type: "scatter" type: "scatter"
} }
const DataforLinePlot = [trace1, trace2] var trace3 = {
x: this.xaxis,
y: this.scoresMean2,
text: text,
line: {color: "rgb(191,91,23)"},
mode: "lines+markers",
marker : {
symbol: 'x' },
name: "Current Precision",
type: "scatter"
}
var trace4 = {
x: xaxisReversed,
y: this.scoresPositive2.concat(this.scoresNegative2),
text: '',
hoverinfo: 'text',
fill: "tozerox",
fillcolor: "rgba(191,91,23,0)",
line: {color: "transparent"},
name: "Current Precision",
showlegend: false,
type: "scatter"
}
var trace5 = {
x: this.xaxis,
y: this.scoresMean3,
text: text,
line: {color: "rgb(253,192,134)"},
mode: "lines+markers",
marker : {
symbol: 'diamond' },
name: "Current Recall",
type: "scatter"
}
var trace6 = {
x: xaxisReversed,
y: this.scoresPositive3.concat(this.scoresNegative3),
text: '',
hoverinfo: 'text',
fill: "tozerox",
fillcolor: "rgba(253,192,134,0)",
line: {color: "transparent"},
name: "Current Recall",
showlegend: false,
type: "scatter"
}
// Stack
var trace7 = {
x: this.xaxis,
y: this.Stack_scoresMean,
text: text,
line: {color: "rgb(190,174,212)"},
mode: "lines+markers",
marker : {
symbol: 'square' },
name: "Stack Accuracy",
type: "scatter"
}
var trace8 = {
x: xaxisReversed,
y: this.Stack_scoresPositive.concat(this.Stack_scoresNegative),
text: '',
hoverinfo: 'text',
fill: "tozerox",
fillcolor: "rgba(190,174,212,0)",
line: {color: "transparent"},
name: "Stack Accuracy",
showlegend: false,
type: "scatter"
}
var trace9 = {
x: this.xaxis,
y: this.Stack_scoresMean2,
text: text,
line: {color: "rgb(56,108,176)"},
mode: "lines+markers",
marker : {
symbol: 'star-triangle-up' },
name: "Stack Precision",
type: "scatter"
}
var trace10 = {
x: xaxisReversed,
y: this.Stack_scoresPositive2.concat(this.Stack_scoresNegative2),
text: '',
hoverinfo: 'text',
fill: "tozerox",
fillcolor: "rgba(56,108,176,0)",
line: {color: "transparent"},
name: "Stack Precision",
showlegend: false,
type: "scatter"
}
var trace11 = {
x: this.xaxis,
y: this.Stack_scoresMean3,
text: text,
line: {color: "rgb(240,2,127)"},
mode: "lines+markers",
marker : {
symbol: 'pentagon' },
name: "Stack Recall",
type: "scatter"
}
var trace12 = {
x: xaxisReversed,
y: this.Stack_scoresPositive3.concat(this.Stack_scoresNegative3),
text: '',
hoverinfo: 'text',
fill: "tozerox",
fillcolor: "rgba(240,2,127,0)",
line: {color: "transparent"},
name: "Stack Recall",
showlegend: false,
type: "scatter"
}
const DataforLinePlot = [trace1, trace2, trace7, trace8, trace3, trace4, trace9, trace10, trace5, trace6, trace11, trace12]
const layout = { const layout = {
title: 'Stack Ensemble Learning Score', title: 'Stack Ensemble Learning Score',
paper_bgcolor: "rgb(255,255,255)", paper_bgcolor: "rgb(255,255,255)",
@ -89,7 +276,10 @@ export default {
tickcolor: "rgb(127,127,127)", tickcolor: "rgb(127,127,127)",
ticks: "outside", ticks: "outside",
zeroline: false zeroline: false
} },
autosize: true,
width: width,
height: height,
} }
Plotly.newPlot('LinePlot', DataforLinePlot, layout, {showSendToCloud: true, responsive: true}) Plotly.newPlot('LinePlot', DataforLinePlot, layout, {showSendToCloud: true, responsive: true})
} }

@ -21,9 +21,7 @@ export default {
limitation: 0, limitation: 0,
flag: false, flag: false,
classesNumber: 10, classesNumber: 10,
cellSize: 24, cellSize: 20
indicestoRem: [],
modelIds: []
} }
}, },
methods: { methods: {
@ -38,46 +36,29 @@ export default {
var FeaturesAccuracy = JSON.parse(this.GetResultsAll[5]) var FeaturesAccuracy = JSON.parse(this.GetResultsAll[5])
var Features= JSON.parse(this.GetResultsAll[6]) var Features= JSON.parse(this.GetResultsAll[6])
var Classifiers = this.modelIds
var keepingArrayIndices = this.indicestoRem var keepingArrayIndices = this.indicestoRem
var PermImpEli = JSON.parse(this.GetResultsAll[10]) var PermImpEli = JSON.parse(this.GetResultsAll[10])
var featureUni = JSON.parse(this.GetResultsAll[11]) var featureUni = JSON.parse(this.GetResultsAll[11])
var modelIds = JSON.parse(this.GetResultsAll[13])
var len2 = modelIds.length
var lengthInitial = PermImpEli.length
var counter = 0
var flag
for (var i = 0; i < lengthInitial; i++) {
flag = 0
for (var j = 0; j < keepingArrayIndices.length; j++) {
if (i == parseInt(keepingArrayIndices[j])) {
flag = 1
}
}
if (flag == 0) {
PermImpEli.splice(i-counter, 1)
counter++
}
}
var len2 = Classifiers.length
console.log(len2)
var maxUni = Math.max.apply(Math, featureUni.map(function(o) { return o.Score; })) var maxUni = Math.max.apply(Math, featureUni.map(function(o) { return o.Score; }))
var minUni = Math.min.apply(Math, featureUni.map(function(o) { return o.Score; })) var minUni = Math.min.apply(Math, featureUni.map(function(o) { return o.Score; }))
let len = Features.length let len = Features.length
console.log(len)
let indicesYAxis = new Array(len) let indicesYAxis = new Array(len)
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
indicesYAxis[i] = [Features[i]] indicesYAxis[i] = [Features[i]]
} }
console.log(indicesYAxis)
let indicesXAxis = new Array(len) let indicesXAxis = new Array(len)
var temp = [] var temp = []
for (let i = 0; i < len2; i++) { for (let i = 0; i < len2; i++) {
temp = [] temp = []
temp.push("R") temp.push("R")
temp.push("Model "+Classifiers[i].toString()) temp.push("Model "+modelIds[i].toString())
indicesXAxis[i] = temp indicesXAxis[i] = temp
} }
console.log(indicesXAxis)
temp = [] temp = []
temp.push("R") temp.push("R")
temp.push("Average") temp.push("Average")
@ -85,19 +66,18 @@ export default {
var values = [] var values = []
var msg = false var msg = false
var counter = 0
var modelData = [] var modelData = []
for (let j = 0; j < len2; j++) { for (let j = 0; j < len2; j++) {
var data = [] var data = []
for (let i = 0; i <len; i++) { for (let i = 0; i <len; i++) {
if (this.Toggles[0] == 1 && this.Toggles[1] == 1 && this.Toggles[2] == 1) { if (this.Toggles[0] == 1 && this.Toggles[1] == 1 && this.Toggles[2] == 1) {
values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(PermImpEli[j][i]*100+(FeaturesAccuracy[counter][0]*100)))/3 values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(PermImpEli[j][i]*100+(FeaturesAccuracy[j][i]*100)))/3
} }
else if (this.Toggles[0] == 1 && this.Toggles[1] == 1 && this.Toggles[2] == 0) { else if (this.Toggles[0] == 1 && this.Toggles[1] == 1 && this.Toggles[2] == 0) {
values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(PermImpEli[j][i]*100))/2 values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(PermImpEli[j][i]*100))/2
} }
else if (this.Toggles[0] == 1 && this.Toggles[1] == 0 && this.Toggles[2] == 1) { else if (this.Toggles[0] == 1 && this.Toggles[1] == 0 && this.Toggles[2] == 1) {
values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(FeaturesAccuracy[counter][0]*100))/2 values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(FeaturesAccuracy[j][i]*100))/2
} }
else if (this.Toggles[0] == 0 && this.Toggles[1] == 1 && this.Toggles[2] == 1) { else if (this.Toggles[0] == 0 && this.Toggles[1] == 1 && this.Toggles[2] == 1) {
values[j] = ((PermImpEli[j][i]*100))/2 values[j] = ((PermImpEli[j][i]*100))/2
@ -109,12 +89,12 @@ export default {
values[j] = PermImpEli[j][i]*100 values[j] = PermImpEli[j][i]*100
} }
else if (this.Toggles[0] == 0 && this.Toggles[1] == 0 && this.Toggles[2] == 1) { else if (this.Toggles[0] == 0 && this.Toggles[1] == 0 && this.Toggles[2] == 1) {
values[j] = FeaturesAccuracy[counter][0]*100 values[j] = FeaturesAccuracy[j][i]*100
} else { } else {
continue alert('Please, keep at least one metric active') // Fix this!
values[j] = ((((featureUni[i].Score-minUni)/(maxUni-minUni))*100)+(PermImpEli[j][i]*100+(FeaturesAccuracy[j][i]*100)))/3
} }
data.push(values[j]/100) data.push(values[j]/100)
counter++
} }
modelData.push(data) modelData.push(data)
} }
@ -169,7 +149,7 @@ export default {
svg.attr('transform', d3.event.transform) // updated for d3 v4 svg.attr('transform', d3.event.transform) // updated for d3 v4
}) })
//================================================== //==================================================
var viewerWidth = $(document).width()/2; var viewerWidth = $(document).width()/2.2;
var viewerHeight = $(document).height()/5.5; var viewerHeight = $(document).height()/5.5;
var viewerPosTop = 125; var viewerPosTop = 125;
var viewerPosLeft = 100; var viewerPosLeft = 100;
@ -364,17 +344,18 @@ export default {
}) })
} }
} }
var results = new Array() var finalresults = []
for (let i = 0; i < rowsExtracted[0].childNodes.length; i++) { for (let i = 0; i < rowsExtracted[0].childNodes.length - 1; i++) {
var results = []
for (let j = 0; j < rowsExtracted.length; j++) { for (let j = 0; j < rowsExtracted.length; j++) {
if (rowsExtracted[j].childNodes[i].style.fill === "url(\"#diagonalHatch\")") { if (rowsExtracted[j].childNodes[i].style.fill === "url(\"#diagonalHatch\")") {
results.push('ClassifierID: ' + i, 'FeatureName: ' + j, 'Check: 0')
} else { } else {
results.push('ClassifierID: ' + i, 'FeatureName: ' + j, 'Check: 1') results.push(j)
} }
} }
finalresults.push(results)
} }
EventBus.$emit('SendSelectedFeaturesEvent', results) EventBus.$emit('SendSelectedFeaturesEvent', finalresults)
}); });
var legend = svg.append("g") var legend = svg.append("g")
@ -551,8 +532,6 @@ export default {
EventBus.$on('emittedEventCallingTogglesUpdate', this.Refresh) EventBus.$on('emittedEventCallingTogglesUpdate', this.Refresh)
EventBus.$on('emittedEventCallingTogglesUpdate', this.Heatmap) EventBus.$on('emittedEventCallingTogglesUpdate', this.Heatmap)
EventBus.$on('resetViews', this.reset) EventBus.$on('resetViews', this.reset)
EventBus.$on('sendModelsIDs', data => { this.modelIds = data })
EventBus.$on('sendIndicestoRemove', data => { this.indicestoRem = data })
} }
} }
</script> </script>

@ -14,14 +14,16 @@
</mdb-card-text> </mdb-card-text>
</mdb-card-body> </mdb-card-body>
</mdb-card> </mdb-card>
<mdb-card style="margin-top: 15px">
<mdb-card-header color="primary-color" tag="h5" class="text-center">Parameters Space Exploration Overview</mdb-card-header>
<mdb-card-body>
<Parameters/>
</mdb-card-body>
</mdb-card>
</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">Models Space Visualization <mdb-card-header color="primary-color" tag="h5" class="text-center">Models Space Visualization
<select id="selectBarChart" @change="selectVisualRepresentation()">
<option value="mds" selected>MDS Projection</option>
<option value="tsne">t-SNE Projection</option>
</select>
[Sel.:{{OverSelLength}}/All:{{OverAllLength}}] [Sel.:{{OverSelLength}}/All:{{OverAllLength}}]
</mdb-card-header> </mdb-card-header>
<mdb-card-body> <mdb-card-body>
@ -133,6 +135,7 @@ import Heatmap from './Heatmap.vue'
import ToggleSelection from './ToggleSelection.vue' import ToggleSelection from './ToggleSelection.vue'
import FinalResultsLinePlot from './FinalResultsLinePlot.vue' import FinalResultsLinePlot from './FinalResultsLinePlot.vue'
import Provenance from './Provenance.vue' import Provenance from './Provenance.vue'
import Parameters from './Parameters.vue'
import axios from 'axios' import axios from 'axios'
import { loadProgressBar } from 'axios-progress-bar' import { loadProgressBar } from 'axios-progress-bar'
import 'axios-progress-bar/dist/nprogress.css' import 'axios-progress-bar/dist/nprogress.css'
@ -163,6 +166,7 @@ export default Vue.extend({
Heatmap, Heatmap,
ToggleSelection, ToggleSelection,
Provenance, Provenance,
Parameters,
FinalResultsLinePlot, FinalResultsLinePlot,
mdbCard, mdbCard,
mdbCardBody, mdbCardBody,
@ -181,6 +185,8 @@ export default Vue.extend({
selectedAlgorithm: '', selectedAlgorithm: '',
PerformancePerModel: '', PerformancePerModel: '',
PerformanceCheck: '', PerformanceCheck: '',
firstTimeFlag: 1,
selectedAlgorithms_Stack: [],
selectedAlgorithms: [], selectedAlgorithms: [],
parametersofModels: [], parametersofModels: [],
reset: false, reset: false,
@ -190,7 +196,6 @@ export default Vue.extend({
combineWH: [], combineWH: [],
basicValuesFact: [], basicValuesFact: [],
sumPerClassifier: [], sumPerClassifier: [],
representationSelection: 'MDS',
valueSel: 0, valueSel: 0,
valueAll: 0, valueAll: 0,
OverSelLength: 0, OverSelLength: 0,
@ -200,14 +205,12 @@ export default Vue.extend({
toggle3: 1, toggle3: 1,
modelsUpdate: [], modelsUpdate: [],
AlgorithmsUpdate: [], AlgorithmsUpdate: [],
SelectedMetricsForModels: [],
DataPointsSel: '',
DataPointsModels: ''
} }
}, },
methods: { methods: {
selectVisualRepresentation () {
const representationSelectionDocum = document.getElementById('selectBarChart')
this.representationSelection = representationSelectionDocum.options[representationSelectionDocum.selectedIndex].value
EventBus.$emit('RepresentationSelection', this.representationSelection)
},
getCollection () { getCollection () {
this.Collection = this.getCollectionFromBackend() this.Collection = this.getCollectionFromBackend()
}, },
@ -248,7 +251,11 @@ 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)
EventBus.$emit('InitializeProvenance', this.OverviewResults) if (this.firstTimeFlag == 1) {
this.selectedAlgorithms_Stack = this.selectedAlgorithms
EventBus.$emit('InitializeProvenance', this.selectedAlgorithms_Stack)
}
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
@ -259,7 +266,6 @@ export default Vue.extend({
EventBus.$emit('emitToggles', this.OverviewResults) EventBus.$emit('emitToggles', this.OverviewResults)
EventBus.$emit('emittedEventCallingToggles', toggles) EventBus.$emit('emittedEventCallingToggles', toggles)
EventBus.$emit('emittedEventCallingHeatmapView', this.OverviewResults) EventBus.$emit('emittedEventCallingHeatmapView', this.OverviewResults)
EventBus.$emit('emittedEventCallingTableView', this.OverviewResults)
EventBus.$emit('emittedEventCallingDataSpacePlotView', this.OverviewResults) EventBus.$emit('emittedEventCallingDataSpacePlotView', this.OverviewResults)
EventBus.$emit('emittedEventCallingPredictionsSpacePlotView', this.OverviewResults) EventBus.$emit('emittedEventCallingPredictionsSpacePlotView', this.OverviewResults)
EventBus.$emit('emittedEventCallingBalanceView', this.OverviewResults) EventBus.$emit('emittedEventCallingBalanceView', this.OverviewResults)
@ -289,7 +295,7 @@ export default Vue.extend({
console.log('Server successfully sent updated per class features!') console.log('Server successfully sent updated per class features!')
EventBus.$emit('emittedEventCallingAllAlgorithms', this.PerformancePerModel) EventBus.$emit('emittedEventCallingAllAlgorithms', this.PerformancePerModel)
EventBus.$emit('emittedEventCallingBarChart', this.PerformancePerModel) EventBus.$emit('emittedEventCallingBarChart', this.PerformancePerModel)
EventBus.$emit('UpdateAllPerformanceResults', this.PerformancePerModel) EventBus.$emit('emittedEventCallingOverview')
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
@ -318,10 +324,7 @@ export default Vue.extend({
console.log('Sent the selected points to the server (scatterplot)!') console.log('Sent the selected points to the server (scatterplot)!')
this.OverSelLength = this.ClassifierIDsList.length this.OverSelLength = this.ClassifierIDsList.length
EventBus.$emit('emittedEventCallingHeatmapView', this.OverviewResults) EventBus.$emit('emittedEventCallingHeatmapView', this.OverviewResults)
EventBus.$emit('emittedEventCallingTableView', this.OverviewResults) this.getSelectedModelsMetrics()
EventBus.$emit('emittedEventCallingDataSpacePlotView', this.OverviewResults)
EventBus.$emit('emittedEventCallingPredictionsSpacePlotView', this.OverviewResults)
EventBus.$emit('emittedEventCallingBalanceView', this.OverviewResults)
this.getFinalResults() this.getFinalResults()
}) })
.catch(error => { .catch(error => {
@ -329,6 +332,72 @@ export default Vue.extend({
}) })
} }
}, },
SendSelectedDataPointsToServer () {
const path = `http://127.0.0.1:5000/data/ServerRequestDataPoint`
const postData = {
DataPointsSel: this.DataPointsSel
}
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.post(path, postData, axiosConfig)
.then(response => {
console.log('Sent the selected data points to the server!')
this.getSelectedDataPointsModels()
})
.catch(error => {
console.log(error)
})
},
getSelectedDataPointsModels () {
const path = `http://localhost:5000/data/ServerSentDataPointsModel`
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 => {
this.DataPointsModels = response.data.DataPointsModels
console.log('Server successfully sent the new models for the scatterplot!')
EventBus.$emit('UpdateModelsScatterplot', this.DataPointsModels)
})
.catch(error => {
console.log(error)
})
},
getSelectedModelsMetrics () {
const path = `http://localhost:5000/data/BarChartSelectedModels`
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 => {
this.SelectedMetricsForModels = response.data.SelectedMetricsForModels
console.log('Server successfully updated barchart for metrics based on selected models!')
EventBus.$emit('UpdateBarChartperMetric', this.SelectedMetricsForModels)
})
.catch(error => {
console.log(error)
})
},
getFinalResults () { getFinalResults () {
this.FinalResults = this.getFinalResultsFromBackend() this.FinalResults = this.getFinalResultsFromBackend()
}, },
@ -597,6 +666,8 @@ export default Vue.extend({
EventBus.$on('ReturningBrushedPointsParams', data => { this.parametersofModels = data; }) EventBus.$on('ReturningBrushedPointsParams', data => { this.parametersofModels = data; })
EventBus.$on('SendSelectedPointsToServerEvent', data => { this.ClassifierIDsList = data }) EventBus.$on('SendSelectedPointsToServerEvent', data => { this.ClassifierIDsList = data })
EventBus.$on('SendSelectedPointsToServerEvent', this.SendSelectedPointsToServer) EventBus.$on('SendSelectedPointsToServerEvent', this.SendSelectedPointsToServer)
EventBus.$on('SendSelectedDataPointsToServerEvent', data => { this.DataPointsSel = data })
EventBus.$on('SendSelectedDataPointsToServerEvent', this.SendSelectedDataPointsToServer)
EventBus.$on('SendSelectedFeaturesEvent', data => { this.SelectedFeaturesPerClassifier = data }) EventBus.$on('SendSelectedFeaturesEvent', data => { this.SelectedFeaturesPerClassifier = data })
EventBus.$on('SendSelectedFeaturesEvent', this.UpdateBasedonFeatures ) EventBus.$on('SendSelectedFeaturesEvent', this.UpdateBasedonFeatures )
EventBus.$on('SendToServerDataSetConfirmation', data => { this.RetrieveValueFile = data }) EventBus.$on('SendToServerDataSetConfirmation', data => { this.RetrieveValueFile = data })

@ -0,0 +1,528 @@
<template>
<div>
<div id="overview"></div>
</div>
</template>
<script>
import { EventBus } from '../main.js'
export default {
name: 'Parameters',
data () {
return {
WH: [],
}
},
methods: {
draw() {
var widthinter = this.WH[0]*3 // interactive visualization
var heightinter = this.WH[1]*1.23 // interactive visualization
var margin = 0,
width = widthinter,
height = heightinter,
maxBarHeight = height / 2 - (margin + 70);
var innerRadius = 0.1 * maxBarHeight; // innermost circle
var svg = d3.select('#overview')
.append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("class", "chart")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var defs = svg.append("defs");
var gradients = defs
.append("linearGradient")
.attr("id", "gradient-chart-area")
.attr("x1", "50%")
.attr("y1", "0%")
.attr("x2", "50%")
.attr("y2", "100%")
.attr("spreadMethod", "pad");
gradients.append("stop")
.attr("offset", "0%")
.attr("stop-color", "#EDF0F0")
.attr("stop-opacity", 1);
gradients.append("stop")
.attr("offset", "100%")
.attr("stop-color", "#ACB7BE")
.attr("stop-opacity", 1);
gradients = defs
.append("linearGradient")
.attr("id", "gradient-questions")
.attr("x1", "50%")
.attr("y1", "0%")
.attr("x2", "50%")
.attr("y2", "100%")
.attr("spreadMethod", "pad");
gradients.append("stop")
.attr("offset", "0%")
.attr("stop-color", "#F6F8F9")
.attr("stop-opacity", 1);
gradients.append("stop")
.attr("offset", "100%")
.attr("stop-color", "#D4DAE0")
.attr("stop-opacity", 1);
gradients = defs
.append("radialGradient")
.attr("id", "gradient-bars")
.attr("gradientUnits", "userSpaceOnUse")
.attr("cx", "0")
.attr("cy", "0")
.attr("r", maxBarHeight)
.attr("spreadMethod", "pad");
gradients.append("stop")
.attr("offset", "0%")
.attr("stop-color", "#F3D5AA");
gradients.append("stop")
.attr("offset", "50%")
.attr("stop-color", "#F4A636");
gradients.append("stop")
.attr("offset", "100%")
.attr("stop-color", "#AF4427");
svg.append("circle")
.attr("r", maxBarHeight + 70)
.classed("category-circle", true);
svg.append("circle")
.attr("r", maxBarHeight + 40)
.classed("question-circle", true);
svg.append("circle")
.attr("r", maxBarHeight)
.classed("chart-area-circle", true);
svg.append("circle")
.attr("r", innerRadius)
.classed("center-circle", true);
var data = [
{ algorithm: 'KNN', parameter: 'n_neighbors', percentage: 70 },
{ algorithm: 'KNN', parameter: 'metric', percentage: 50 },
{ algorithm: 'KNN', parameter: 'algorithm', percentage: 75 },
{ algorithm: 'KNN', parameter: 'weight', percentage: 50 },
{ algorithm: 'RF', parameter: 'n_estimators', percentage: 80 },
{ algorithm: 'RF', parameter: 'criterion', percentage: 50 }
];
var cats = data.map(function(d, i) {
return d.algorithm;
});
var catCounts = {};
for (var i = 0; i < cats.length; i++) {
var num = cats[i];
catCounts[num] = catCounts[num] ? catCounts[num] + 1 : 1;
}
// remove dupes (not exactly the fastest)
cats = cats.filter(function(v, i) {
return cats.indexOf(v) == i;
});
var numCatBars = cats.length;
var angle = 0,
rotate = 0;
data.forEach(function(d, i) {
// bars start and end angles
d.startAngle = angle;
angle += (2 * Math.PI) / numCatBars / catCounts[d.algorithm];
d.endAngle = angle;
// y axis minor lines (i.e. questions) rotation
d.rotate = rotate;
rotate += 360 / numCatBars / catCounts[d.algorithm];
});
// category_label
var arc_category_label = d3.svg.arc()
.startAngle(function(d, i) {
return (i * 2 * Math.PI) / numCatBars;
})
.endAngle(function(d, i) {
return ((i + 1) * 2 * Math.PI) / numCatBars;
})
.innerRadius(maxBarHeight + 40)
.outerRadius(maxBarHeight + 64);
var category_text = svg.selectAll("path.category_label_arc")
.data(cats)
.enter().append("path")
.classed("category-label-arc", true)
.attr("id", function(d, i) {
return "category_label_" + i;
}) //Give each slice a unique ID
.attr("fill", "none")
.attr("d", arc_category_label);
category_text.each(function(d, i) {
//Search pattern for everything between the start and the first capital L
var firstArcSection = /(^.+?)L/;
//Grab everything up to the first Line statement
var newArc = firstArcSection.exec(d3.select(this).attr("d"))[1];
//Replace all the commas so that IE can handle it
newArc = newArc.replace(/,/g, " ");
//If the whole bar lies beyond a quarter of a circle (90 degrees or pi/2)
// and less than 270 degrees or 3 * pi/2, flip the end and start position
var startAngle = (i * 2 * Math.PI) / numCatBars,
endAngle = ((i + 1) * 2 * Math.PI) / numCatBars;
if (startAngle > Math.PI / 2 && startAngle < 3 * Math.PI / 2 && endAngle > Math.PI / 2 && endAngle < 3 * Math.PI / 2) {
var startLoc = /M(.*?)A/, //Everything between the capital M and first capital A
middleLoc = /A(.*?)0 0 1/, //Everything between the capital A and 0 0 1
endLoc = /0 0 1 (.*?)$/; //Everything between the 0 0 1 and the end of the string (denoted by $)
//Flip the direction of the arc by switching the start and end point (and sweep flag)
var newStart = endLoc.exec(newArc)[1];
var newEnd = startLoc.exec(newArc)[1];
var middleSec = middleLoc.exec(newArc)[1];
//Build up the new arc notation, set the sweep-flag to 0
newArc = "M" + newStart + "A" + middleSec + "0 0 0 " + newEnd;
} //if
//Create a new invisible arc that the text can flow along
/* svg.append("path")
.attr("class", "hiddenDonutArcs")
.attr("id", "category_label_"+i)
.attr("d", newArc)
.style("fill", "none");*/
// modifying existing arc instead
d3.select(this).attr("d", newArc);
});
svg.selectAll(".category-label-text")
.data(cats)
.enter().append("text")
.attr("class", "category-label-text")
//.attr("x", 0) //Move the text from the start angle of the arc
//Move the labels below the arcs for those slices with an end angle greater than 90 degrees
.attr("dy", function(d, i) {
var startAngle = (i * 2 * Math.PI) / numCatBars,
endAngle = ((i + 1) * 2 * Math.PI) / numCatBars;
return (startAngle > Math.PI / 2 && startAngle < 3 * Math.PI / 2 && endAngle > Math.PI / 2 && endAngle < 3 * Math.PI / 2 ? -4 : 14);
})
.append("textPath")
.attr("startOffset", "50%")
.style("text-anchor", "middle")
.attr("xlink:href", function(d, i) {
return "#category_label_" + i;
})
.text(function(d) {
return d;
});
// parameter
var arc_parameter = d3.svg.arc()
.startAngle(function(d, i) {
return d.startAngle;
})
.endAngle(function(d, i) {
return d.endAngle;
})
//.innerRadius(maxBarHeight + 2)
.outerRadius(maxBarHeight + 2);
var question_text = svg.selectAll("path.parameter_arc")
.data(data)
.enter().append("path")
.classed("question-label-arc", true)
.attr("id", function(d, i) {
return "parameter_" + i;
}) //Give each slice a unique ID
.attr("fill", "none")
.attr("d", arc_parameter);
question_text.each(function(d, i) {
//Search pattern for everything between the start and the first capital L
var firstArcSection = /(^.+?)L/;
//Grab everything up to the first Line statement
var newArc = firstArcSection.exec(d3.select(this).attr("d"))[1];
//Replace all the commas so that IE can handle it
newArc = newArc.replace(/,/g, " ");
//If the end angle lies beyond a quarter of a circle (90 degrees or pi/2)
//flip the end and start position
if (d.startAngle > Math.PI / 2 && d.startAngle < 3 * Math.PI / 2 && d.endAngle > Math.PI / 2 && d.endAngle < 3 * Math.PI / 2) {
var startLoc = /M(.*?)A/, //Everything between the capital M and first capital A
middleLoc = /A(.*?)0 0 1/, //Everything between the capital A and 0 0 1
endLoc = /0 0 1 (.*?)$/; //Everything between the 0 0 1 and the end of the string (denoted by $)
//Flip the direction of the arc by switching the start and end point (and sweep flag)
var newStart = endLoc.exec(newArc)[1];
var newEnd = startLoc.exec(newArc)[1];
var middleSec = middleLoc.exec(newArc)[1];
//Build up the new arc notation, set the sweep-flag to 0
newArc = "M" + newStart + "A" + middleSec + "0 0 0 " + newEnd;
} //if
//Create a new invisible arc that the text can flow along
/* svg.append("path")
.attr("class", "hiddenDonutArcs")
.attr("id", "parameter_"+i)
.attr("d", newArc)
.style("fill", "none");*/
// modifying existing arc instead
d3.select(this).attr("d", newArc);
});
question_text = svg.selectAll(".question-label-text")
.data(data)
.enter().append("text")
.attr("class", "question-label-text")
//.attr("x", 0) //Move the text from the start angle of the arc
//.attr("y", 0)
//Move the labels below the arcs for those slices with an end angle greater than 90 degrees
/* .attr("dy", function (d, i) {
return (d.startAngle > Math.PI / 2 && d.startAngle < 3 * Math.PI / 2 && d.endAngle > Math.PI / 2 && d.endAngle < 3 * Math.PI / 2 ? 10 : -10);
})*/
.append("textPath")
//.attr("startOffset", "50%")
//.style("text-anchor", "middle")
//.style("dominant-baseline", "central")
.style('font-size', '7px')
.style('font-family', 'sans-serif')
.attr("xlink:href", function(d, i) {
return "#parameter_" + i;
})
.text(function(d) {
return d.parameter.toUpperCase();
})
.call(wrapTextOnArc, maxBarHeight);
// adjust dy (labels vertical start) based on number of lines (i.e. tspans)
question_text.each(function(d, i) {
//console.log(d3.select(this)[0]);
var textPath = d3.select(this)[0][0],
tspanCount = textPath.childNodes.length;
if (d.startAngle > Math.PI / 2 && d.startAngle < 3 * Math.PI / 2 && d.endAngle > Math.PI / 2 && d.endAngle < 3 * Math.PI / 2) {
// set baseline for one line and adjust if greater than one line
d3.select(textPath.childNodes[0]).attr("dy", 3 + (tspanCount - 1) * -0.6 + 'em');
} else {
d3.select(textPath.childNodes[0]).attr("dy", -2.1 + (tspanCount - 1) * -0.6 + 'em');
}
});
/* bars */
var arc = d3.svg.arc()
.startAngle(function(d, i) {
return d.startAngle;
})
.endAngle(function(d, i) {
return d.endAngle;
})
.innerRadius(innerRadius);
var bars = svg.selectAll("path.bar")
.data(data)
.enter().append("path")
.classed("bars", true)
.each(function(d) {
d.outerRadius = innerRadius;
})
.attr("d", arc);
bars.transition().ease("elastic").duration(1000).delay(function(d, i) {
return i * 100;
})
.attrTween("d", function(d, index) {
var i = d3.interpolate(d.outerRadius, x_scale(+d.percentage));
return function(t) {
d.outerRadius = i(t);
return arc(d, index);
};
});
var x_scale = d3.scale.linear()
.domain([0, 100])
.range([innerRadius, maxBarHeight]);
var y_scale = d3.scale.linear()
.domain([0, 100])
.range([-innerRadius, -maxBarHeight]);
svg.selectAll("circle.x.minor")
.data(y_scale.ticks(10))
.enter().append("circle")
.classed("gridlines minor", true)
.attr("r", function(d) {
return x_scale(d);
});
// question lines
svg.selectAll("line.y.minor")
.data(data)
.enter().append("line")
.classed("gridlines minor", true)
.attr("y1", -innerRadius)
.attr("y2", -maxBarHeight - 40)
.attr("transform", function(d, i) {
return "rotate(" + (d.rotate) + ")";
});
// category lines
svg.selectAll("line.y.major")
.data(cats)
.enter().append("line")
.classed("gridlines major", true)
.attr("y1", -innerRadius)
.attr("y2", -maxBarHeight - 70)
.attr("transform", function(d, i) {
return "rotate(" + (i * 360 / numCatBars) + ")";
});
function wrapTextOnArc(text, radius) {
// note getComputedTextLength() doesn't work correctly for text on an arc,
// hence, using a hidden text element for measuring text length.
var temporaryText = d3.select('svg')
.append("text")
.attr("class", "temporary-text") // used to select later
.style("font", "7px sans-serif")
.style("opacity", 0); // hide element
var getTextLength = function(string) {
temporaryText.text(string);
return temporaryText.node().getComputedTextLength();
};
text.each(function(d) {
var text = d3.select(this),
words = text.text().split(/[ \f\n\r\t\v]+/).reverse(), //Don't cut non-breaking space (\xA0), as well as the Unicode characters \u00A0 \u2028 \u2029)
word,
wordCount = words.length,
line = [],
textLength,
lineHeight = 1.1, // ems
x = 0,
y = 0,
dy = 0,
tspan = text.text(null).append("tspan").attr("x", x).attr("y", y).attr("dy", dy + "em"),
arcLength = ((d.endAngle - d.startAngle) / (2 * Math.PI)) * (2 * Math.PI * radius),
paddedArcLength = arcLength - 16;
while (word = words.pop()) {
line.push(word);
tspan.text(line.join(" "));
textLength = getTextLength(tspan.text());
tspan.attr("x", (arcLength - textLength) / 2);
if (textLength > paddedArcLength && line.length > 1) {
// remove last word
line.pop();
tspan.text(line.join(" "));
textLength = getTextLength(tspan.text());
tspan.attr("x", (arcLength - textLength) / 2);
// start new line with last word
line = [word];
tspan = text.append("tspan").attr("dy", lineHeight + dy + "em").text(word);
textLength = getTextLength(tspan.text());
tspan.attr("x", (arcLength - textLength) / 2);
}
}
});
d3.selectAll("text.temporary-text").remove()
}
}
},
mounted () {
EventBus.$on('emittedEventCallingOverview',this.draw)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
}
}
</script>
<style>
/* Styles go here */
.category-circle {
fill: #F4A636;
}
.question-circle {
fill: url(#gradient-questions);
}
.chart-area-circle {
stroke: #fff;
stroke-width: 3px;
fill: url(#gradient-chart-area);
}
.center-circle {
fill: #fff;
}
.bars {
fill: url(#gradient-bars);
}
.gridlines {
fill: none;
stroke: #fff;
}
.minor {
stroke-width: 1px
}
.major {
stroke-width: 6px
}
.question-label-arc {
/*fill: white;
stroke: #AAAAAA;
fill: url(#gradient-questions);*/
}
.category-label-text {
font-weight: bold;
font-size: 14px;
fill: #fff;
}
.question-label-text {
font-size: 7px;
font-weight: bold;
fill: gray;
}
.question-labels {
text-anchor: middle;
font-weight: bold;
}
.category-labels {
text-anchor: middle;
font-weight: bold;
font-size: 14px;
fill: #fff;
}
</style>

@ -10,64 +10,25 @@ export default {
name: 'PerMetricsBarChart', name: 'PerMetricsBarChart',
data () { data () {
return { return {
barchartmetrics: '' barchartmetrics: '',
WH: [],
SelBarChartMetrics: []
} }
}, },
methods: { methods: {
LineBar () { LineBar () {
Plotly.purge('PerMetricBar')
var metricsPerModel = JSON.parse(this.barchartmetrics[9]) var metricsPerModel = JSON.parse(this.barchartmetrics[9])
var vh = 80 var metricsPerModelSel = []
/*if (this.representationDefault === 'bar'){ if (this.SelBarChartMetrics.length == 0) {
var type = 'bar'; metricsPerModelSel = metricsPerModel
} else if (this.representationDefault === 'line'){
var type = 'line';
} else { } else {
var type = 'difference'; metricsPerModelSel = this.SelBarChartMetrics
} }
var difference = []; var width = this.WH[0]*3 // interactive visualization
for (var i=0; i<metricsPerModel.length; i++){ var height = this.WH[1]/2 // interactive visualization
difference.push(metricsPerModel[i] - metricsPerModel[i]);
}*/
/*if (type == 'difference'){
var trace = {
x: kValuesLegend,
y: difference,
name: 'Delta(preservation)',
showlegend: true,
type: 'line',
marker: {
color: 'rgb(128,128,0)'
}
};
var LimitXaxis = Number(maxKNN) + 1;
var data = [trace];
var layout = {
barmode: 'group',autosize: false,
width: 400,
height: vh * 1.3,
margin: {
l: 50,
r: 30,
b: 30,
t: 5,
pad: 4
},
xaxis: {range: [0, LimitXaxis],
title: 'Number of neighbors',
titlefont: {
size: 12,
color: 'black'
}},
yaxis: {
title: '+/- Pres.',
titlefont: {
size: 12,
color: 'black'
}}};
Plotly.newPlot('PerMetricBar', data, layout, {displayModeBar:false}, {staticPlot: true});
} else{*/
var trace1 = { var trace1 = {
x: ['Acc','F1s','Pre','Rec','Jac'], x: ['Acc','F1s','Pre','Rec','Jac'],
y: metricsPerModel, y: metricsPerModel,
@ -79,7 +40,7 @@ export default {
}; };
var trace2 = { var trace2 = {
x: ['Acc','F1s','Pre','Rec','Jac'], x: ['Acc','F1s','Pre','Rec','Jac'],
y: metricsPerModel, y: metricsPerModelSel,
name: 'Selected points', name: 'Selected points',
type: 'bar', type: 'bar',
marker: { marker: {
@ -89,8 +50,8 @@ export default {
var data = [trace1, trace2]; var data = [trace1, trace2];
var layout = { var layout = {
barmode: 'group',autosize: false, barmode: 'group',autosize: false,
width: 400, width: width,
height: vh * 1.3, height: height,
margin: { margin: {
l: 50, l: 50,
r: 30, r: 30,
@ -118,6 +79,13 @@ export default {
mounted () { mounted () {
EventBus.$on('InitializeMetricsBarChart', data => {this.barchartmetrics = data;}) EventBus.$on('InitializeMetricsBarChart', data => {this.barchartmetrics = data;})
EventBus.$on('InitializeMetricsBarChart', this.LineBar) EventBus.$on('InitializeMetricsBarChart', this.LineBar)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
EventBus.$on('UpdateBarChartperMetric', data => {
this.SelBarChartMetrics = data})
EventBus.$on('UpdateBarChartperMetric', this.LineBar)
} }
} }
</script> </script>

@ -10,12 +10,13 @@ export default {
name: 'PredictionsSpace', name: 'PredictionsSpace',
data () { data () {
return { return {
PredictionsData: '' PredictionsData: '',
WH: []
} }
}, },
methods: { methods: {
ScatterPlotDataView () { ScatterPlotDataView () {
const XandYCoordinates = JSON.parse(this.PredictionsData[4]) const XandYCoordinates = JSON.parse(this.PredictionsData[8])
var result = XandYCoordinates.reduce(function(r, a) { var result = XandYCoordinates.reduce(function(r, a) {
a.forEach(function(s, i) { a.forEach(function(s, i) {
@ -28,10 +29,21 @@ export default {
return r; return r;
}, {}) }, {})
var dataPointInfo = []
for (let i = 0; i < XandYCoordinates.length; i++) {
dataPointInfo[i] = 'Data Point ID: ' + i
}
var width = this.WH[0]*3 // interactive visualization
var height = this.WH[1]*1.48 // interactive visualization
const Data = [{ const Data = [{
x: result.Xax, x: result.Xax,
y: result.Yax, y: result.Yax,
mode: 'markers', mode: 'markers',
hovertemplate:
"<b>%{text}</b><br><br>" +
"<extra></extra>",
text: dataPointInfo,
}] }]
const layout = { const layout = {
title: 'Predictions Space Projection (tSNE)', title: 'Predictions Space Projection (tSNE)',
@ -41,17 +53,48 @@ export default {
yaxis: { yaxis: {
visible: false visible: false
}, },
dragmode: 'lasso',
hovermode: "closest",
autosize: true, autosize: true,
width: 400, width: width,
height: 400, height: height,
}
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('OverviewPredPlotly', Data, layout, config)
this.selectedPointsOverview()
},
selectedPointsOverview () {
const OverviewPlotly = document.getElementById('OverviewPredPlotly')
OverviewPlotly.on('plotly_selected', function (evt) {
if (typeof evt !== 'undefined') {
const DataPoints = []
for (let i = 0; evt.points.length; i++) {
if (evt.points[i] === undefined) {
break
} else {
const OnlyId = evt.points[i].text.split(' ')
DataPoints.push(OnlyId[3])
}
}
if (DataPoints != '') {
EventBus.$emit('SendSelectedDataPointsToServerEvent', DataPoints)
} else {
EventBus.$emit('SendSelectedDataPointsToServerEvent', '')
} }
Plotly.newPlot('OverviewPredPlotly', Data, layout, {responsive: true})
} }
})
},
}, },
mounted() { mounted() {
EventBus.$on('emittedEventCallingPredictionsSpacePlotView', data => { EventBus.$on('emittedEventCallingPredictionsSpacePlotView', data => {
this.PredictionsData = data}) this.PredictionsData = data})
EventBus.$on('emittedEventCallingPredictionsSpacePlotView', this.ScatterPlotDataView) EventBus.$on('emittedEventCallingPredictionsSpacePlotView', this.ScatterPlotDataView)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
} }
} }
</script> </script>

@ -21,32 +21,53 @@ export default {
name: 'Provenance', name: 'Provenance',
data () { data () {
return { return {
stackInformation: '' stackInformation: '',
WH: [],
data: [],
counter: 0,
typeCounter: [],
typeColumnCounter: []
} }
}, },
methods: { methods: {
provenance () { provenance () {
var canvas = document.getElementById("main-canvas"); var canvas = document.getElementById("main-canvas");
var width = 960; var width = this.WH[0]*9 // interactive visualization
var height = 500; var height = this.WH[1]*0.95 // interactive visualization
var flagKNN = 0
var flagRF = 0
// Create a WebGL 2D platform on the canvas: // Create a WebGL 2D platform on the canvas:
var platform = Stardust.platform("webgl-2d", canvas, width, height); var platform = Stardust.platform("webgl-2d", canvas, width, height);
var data = [];
[27, 53, 91, 52, 112, 42, 107, 91, 68, 56, 115, 86, 26, 102, 28, 23, 119, 110].forEach((x, index) => { for (let i = 0; i < this.stackInformation.length; i++) {
for (let i = 0; i < x; i++) { if (this.stackInformation[i] == 'KNN'){
data.push({ this.data.push({
type: index % 3, type:0, column:this.counter, height:height
column: Math.floor(index / 3) })
}); flagKNN = 1
} else {
this.data.push({
type:1, column:this.counter, height:height
})
flagRF = 1
} }
}
if (flagKNN == 1) {
this.typeCounter.push(0)
}
if (flagRF == 1) {
this.typeCounter.push(0)
}
this.typeColumnCounter.push(0)
this.data.forEach(d => {
d.typeIndex = this.typeCounter[d.type]++;
d.typeColumnIndex = this.typeColumnCounter[d.column]++;
}); });
var typeCounter = [0, 0, 0];
var typeColumnCounter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
data.forEach(d => {
d.typeIndex = typeCounter[d.type]++;
d.typeColumnIndex = typeColumnCounter[3 * d.column + d.type]++;
});
// Convert the SVG file to Stardust mark spec. // Convert the SVG file to Stardust mark spec.
let isotype = new Stardust.mark.circle(); let isotype = new Stardust.mark.circle();
@ -54,28 +75,30 @@ export default {
let isotypes = Stardust.mark.create(isotype, platform); let isotypes = Stardust.mark.create(isotype, platform);
let isotypeHeight = 18; let isotypeHeight = 18;
let colors = [[141,211,199], [255,255,179], [190,186,218]]; let colors = [[141,211,199], [141,160,203]];
colors = colors.map(x => [x[0] / 255, x[1] / 255, x[2] / 255, 1]); colors = colors.map(x => [x[0] / 255, x[1] / 255, x[2] / 255, 1]);
let pScale = Stardust.scale.custom(` let pScale = Stardust.scale.custom(`
Vector2( Vector2(
20 + column * 160 + type * 45 + typeColumnIndex % 5 * 8, 20 + column * 160 + typeColumnIndex % 5 * 8,
460 - floor(typeColumnIndex / 5) * 10 height - 10 - floor(typeColumnIndex / 5) * 10
) )
`); `);
pScale.attr("typeColumnIndex", d => d.typeColumnIndex); pScale.attr("typeColumnIndex", d => d.typeColumnIndex);
pScale.attr("column", d => d.column); pScale.attr("column", d => d.column);
pScale.attr("typeIndex", d => d.typeIndex); pScale.attr("typeIndex", d => d.typeIndex);
pScale.attr("type", d => d.type); pScale.attr("type", d => d.type);
pScale.attr("height", d => d.height);
let qScale = Stardust.scale.custom(` let qScale = Stardust.scale.custom(`
Vector2( Vector2(
65 + type * 300 + typeIndex % 30 * 8, 65 + typeIndex % 30 * 8,
460 - floor(typeIndex / 15) * 18 height - 10 - floor(typeIndex / 15) * 18
) )
`); `);
qScale.attr("typeIndex", d => d.typeIndex); qScale.attr("typeIndex", d => d.typeIndex);
qScale.attr("type", d => d.type); qScale.attr("type", d => d.type);
qScale.attr("height", d => d.height);
let interpolateScale = Stardust.scale.interpolate("Vector2"); let interpolateScale = Stardust.scale.interpolate("Vector2");
interpolateScale.t(0); interpolateScale.t(0);
@ -84,7 +107,7 @@ export default {
isotypes.attr("radius", 4.0); isotypes.attr("radius", 4.0);
isotypes.attr("color", d => colors[d.type]); isotypes.attr("color", d => colors[d.type]);
isotypes.data(data); isotypes.data(this.data);
isotypes.render(); isotypes.render();
@ -93,6 +116,10 @@ export default {
mounted () { mounted () {
EventBus.$on('InitializeProvenance', data => {this.stackInformation = data}) EventBus.$on('InitializeProvenance', data => {this.stackInformation = data})
EventBus.$on('InitializeProvenance', this.provenance) EventBus.$on('InitializeProvenance', this.provenance)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
} }
} }

@ -1,13 +1,11 @@
<template> <template>
<div> <div>
<div align="center"> <div align="center">
<button Projection Selection: <select id="selectBarChart" @change="selectVisualRepresentation()">
id="AddStack" <option value="mds" selected>MDS Projection</option>
v-on:click="AddStack"> <option value="tsne">t-SNE Projection</option>
<font-awesome-icon icon="plus" /> </select>
{{ valueStackAdd }} Action: <button
</button>
<button
id="RemoveStack" id="RemoveStack"
v-on:click="RemoveStack"> v-on:click="RemoveStack">
<font-awesome-icon icon="minus" /> <font-awesome-icon icon="minus" />
@ -33,23 +31,26 @@ export default {
return { return {
ScatterPlotResults: '', ScatterPlotResults: '',
representationDef: 'mds', representationDef: 'mds',
representationSelection: 'MDS',
colorsforOver: [], colorsforOver: [],
brushedBox : [], brushedBox : [],
max: 0, max: 0,
min: 0, min: 0,
WH: [],
parametersAll: [], parametersAll: [],
length: 0, length: 0,
valueStackAdd: 'Add to Stack',
valueStackRemove: 'Remove from Stack', valueStackRemove: 'Remove from Stack',
AllData: [] DataPointsSelUpdate: []
} }
}, },
methods: { methods: {
AddStack () { selectVisualRepresentation () {
//EventBus.$emit('PCPCallDB') const representationSelectionDocum = document.getElementById('selectBarChart')
this.representationSelection = representationSelectionDocum.options[representationSelectionDocum.selectedIndex].value
EventBus.$emit('RepresentationSelection', this.representationSelection)
}, },
RemoveStack () { RemoveStack () {
//EventBus.$emit('PCPCallDB') EventBus.$emit('PCPCallDB')
}, },
ScatterPlotView () { ScatterPlotView () {
@ -84,7 +85,11 @@ export default {
var MDSData = JSON.parse(this.ScatterPlotResults[1]) var MDSData = JSON.parse(this.ScatterPlotResults[1])
var parameters = JSON.parse(this.ScatterPlotResults[2]) var parameters = JSON.parse(this.ScatterPlotResults[2])
var TSNEData = JSON.parse(this.ScatterPlotResults[12]) var TSNEData = JSON.parse(this.ScatterPlotResults[12])
var modelId = JSON.parse(this.ScatterPlotResults[13])
EventBus.$emit('sendPointsNumber', modelId.length)
parameters = JSON.parse(parameters)
if (this.colorsforOver.length != 0) { if (this.colorsforOver.length != 0) {
if (this.colorsforOver[1].length != 0) { if (this.colorsforOver[1].length != 0) {
@ -96,47 +101,11 @@ export default {
} }
} }
parameters = JSON.parse(parameters)
var classifiersInfo = this.brushedBox
var keepingArrayIndices = []
var modelsDetails = []
var modelsIDs = []
for (var j in parameters) {
for (var i in classifiersInfo) {
if (isEquivalent(JSON.parse(this.parametersAll[classifiersInfo[i].model]),parameters[j])) {
keepingArrayIndices.push(j)
modelsDetails.push(this.parametersAll[classifiersInfo[i].model])
modelsIDs.push(classifiersInfo[i].model)
} else {
}
}
}
var flag
this.length = keepingArrayIndices.length
EventBus.$emit('sendPointsNumber', this.length)
EventBus.$emit('sendModelsIDs', modelsIDs)
EventBus.$emit('sendIndicestoRemove', keepingArrayIndices)
var lengthInitial = colorsforScatterPlot.length
var counter = 0
for (var i = 0; i < lengthInitial; i++) {
flag = 0
for (var j = 0; j < keepingArrayIndices.length; j++) {
if (i == parseInt(keepingArrayIndices[j])) {
flag = 1
}
}
if (flag == 0) {
colorsforScatterPlot.splice(i-counter, 1)
MDSData[0].splice(i-counter,1)
MDSData[1].splice(i-counter,1)
counter++
}
}
var classifiersInfoProcessing = [] var classifiersInfoProcessing = []
for (let i = 0; i < modelsDetails.length; i++) { for (let i = 0; i < modelId.length; i++) {
classifiersInfoProcessing[i] = 'Model ID: ' + modelsIDs[i] + '; Details: ' + modelsDetails[i] classifiersInfoProcessing[i] = 'Model ID: ' + modelId[i] + '; Details: ' + JSON.stringify(parameters[i])
} }
var DataGeneral var DataGeneral
var layout var layout
if (this.representationDef == 'mds') { if (this.representationDef == 'mds') {
@ -158,7 +127,10 @@ export default {
titleside: 'Top' titleside: 'Top'
}, },
} }
}] }]
var width = this.WH[0]*3 // interactive visualization
var height = this.WH[1]*1.5 // interactive visualization
layout = { layout = {
title: 'Models Performance (MDS)', title: 'Models Performance (MDS)',
xaxis: { xaxis: {
@ -168,8 +140,8 @@ export default {
visible: false visible: false
}, },
autosize: true, autosize: true,
width: 400, width: width,
height: 400, height: height,
dragmode: 'lasso', dragmode: 'lasso',
hovermode: "closest", hovermode: "closest",
hoverlabel: { bgcolor: "#FFF" }, hoverlabel: { bgcolor: "#FFF" },
@ -253,10 +225,30 @@ export default {
}, },
UpdateScatter () { UpdateScatter () {
this.ScatterPlotView() this.ScatterPlotView()
},
animate() {
var colorsforScatterPlot = JSON.parse(this.DataPointsSelUpdate[0])
var MDSData = JSON.parse(this.DataPointsSelUpdate[1])
Plotly.animate('OverviewPlotly', {
data: [
{x: MDSData[0], y: MDSData[1],marker: {
color: colorsforScatterPlot,
}}
],
traces: [0],
layout: {}
}, {
transition: {
duration: 1000,
easing: 'cubic-in-out'
},
frame: {
duration: 1000
}
})
} }
}, },
mounted() { mounted() {
EventBus.$on('UpdateAllPerformanceResults', data => { this.AllData = data })
EventBus.$on('emittedEventCallingBrushedBoxPlot', data => { EventBus.$on('emittedEventCallingBrushedBoxPlot', data => {
this.brushedBox = data}) this.brushedBox = data})
EventBus.$on('emittedEventCallingScatterPlot', data => { EventBus.$on('emittedEventCallingScatterPlot', data => {
@ -264,10 +256,16 @@ export default {
EventBus.$on('emittedEventCallingScatterPlot', this.ScatterPlotView) EventBus.$on('emittedEventCallingScatterPlot', this.ScatterPlotView)
EventBus.$on('getColors', data => { EventBus.$on('getColors', data => {
this.colorsforOver = data}) this.colorsforOver = data})
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
EventBus.$on('ParametersAll', data => { this.parametersAll = data }) EventBus.$on('ParametersAll', data => { this.parametersAll = data })
EventBus.$on('getColors', this.UpdateScatter) EventBus.$on('getColors', this.UpdateScatter)
EventBus.$on('RepresentationSelection', data => {this.representationDef = data}) EventBus.$on('RepresentationSelection', data => {this.representationDef = data})
EventBus.$on('RepresentationSelection', this.ScatterPlotView) EventBus.$on('RepresentationSelection', this.ScatterPlotView)
EventBus.$on('UpdateModelsScatterplot', data => {this.DataPointsSelUpdate = data})
EventBus.$on('UpdateModelsScatterplot', this.animate)
} }
} }
</script> </script>

638
run.py

@ -20,7 +20,6 @@ from sklearn.naive_bayes import GaussianNB
from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import RandomForestClassifier
from sklearn.pipeline import make_pipeline from sklearn.pipeline import make_pipeline
from sklearn import model_selection from sklearn import model_selection
from sklearn.model_selection import GridSearchCV
from sklearn.manifold import MDS from sklearn.manifold import MDS
from sklearn.manifold import TSNE from sklearn.manifold import TSNE
from sklearn.metrics import classification_report from sklearn.metrics import classification_report
@ -38,6 +37,8 @@ from mlxtend.feature_selection import ColumnSelector
from skdist.distribute.search import DistGridSearchCV from skdist.distribute.search import DistGridSearchCV
from pyspark.sql import SparkSession from pyspark.sql import SparkSession
from scipy.spatial import procrustes
# This block of code is for the connection between the server, the database, and the client (plus routing). # This block of code is for the connection between the server, the database, and the client (plus routing).
# Access MongoDB # Access MongoDB
@ -57,6 +58,9 @@ def Reset():
global RANDOM_SEED global RANDOM_SEED
RANDOM_SEED = 42 RANDOM_SEED = 42
global factors
factors = [1,1,1,1,1]
global XData global XData
XData = [] XData = []
@ -96,12 +100,15 @@ def Reset():
global loopFeatures global loopFeatures
loopFeatures = 2 loopFeatures = 2
global columns
columns = []
global results global results
results = [] results = []
global resultsMetrics
resultsMetrics = []
global parametersSelData
parametersSelData = []
global target_names global target_names
target_names = [] target_names = []
return 'The reset was done!' return 'The reset was done!'
@ -168,12 +175,15 @@ def RetrieveFileName():
global factors global factors
factors = [1,1,1,1,1] factors = [1,1,1,1,1]
global columns
columns = []
global results global results
results = [] results = []
global resultsMetrics
resultsMetrics = []
global parametersSelData
parametersSelData = []
global target_names global target_names
target_names = [] target_names = []
DataRawLength = -1 DataRawLength = -1
@ -283,6 +293,7 @@ def RetrieveModel():
RetrievedModel = request.get_data().decode('utf8').replace("'", '"') RetrievedModel = request.get_data().decode('utf8').replace("'", '"')
RetrievedModel = json.loads(RetrievedModel) RetrievedModel = json.loads(RetrievedModel)
global algorithms
algorithms = RetrievedModel['Algorithms'] algorithms = RetrievedModel['Algorithms']
# loop through the algorithms # loop through the algorithms
@ -294,7 +305,7 @@ def RetrieveModel():
AlgorithmsIDsEnd = 0 AlgorithmsIDsEnd = 0
else: else:
clf = RandomForestClassifier() clf = RandomForestClassifier()
params = {'n_estimators': list(range(80, 120)), 'criterion': ['gini', 'entropy']} params = {'n_estimators': list(range(40, 120)), 'criterion': ['gini', 'entropy']}
AlgorithmsIDsEnd = 576 AlgorithmsIDsEnd = 576
allParametersPerformancePerModel = GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd) allParametersPerformancePerModel = GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd)
@ -386,6 +397,7 @@ def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
permList = [] permList = []
PerFeatureAccuracy = [] PerFeatureAccuracy = []
PerFeatureAccuracyAll = []
PerClassMetric = [] PerClassMetric = []
perModelProb = [] perModelProb = []
@ -396,10 +408,11 @@ def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
permList.append(perm.feature_importances_) permList.append(perm.feature_importances_)
n_feats = XData.shape[1] n_feats = XData.shape[1]
PerFeatureAccuracy = []
for i in range(n_feats): for i in range(n_feats):
scores = model_selection.cross_val_score(clf, XData.values[:, i].reshape(-1, 1), yData, cv=crossValidation) scores = model_selection.cross_val_score(clf, XData.values[:, i].reshape(-1, 1), yData, cv=crossValidation)
PerFeatureAccuracy.append(scores.mean()) PerFeatureAccuracy.append(scores.mean())
PerFeatureAccuracyAll.append(PerFeatureAccuracy)
clf.fit(XData, yData) clf.fit(XData, yData)
yPredict = clf.predict(XData) yPredict = clf.predict(XData)
# retrieve target names (class names) # retrieve target names (class names)
@ -420,7 +433,7 @@ def GridSearchForModels(clf, params, eachAlgor, factors, AlgorithmsIDsEnd):
perm_imp_eli5PD = pd.DataFrame(permList) perm_imp_eli5PD = pd.DataFrame(permList)
perm_imp_eli5PD = perm_imp_eli5PD.to_json() perm_imp_eli5PD = perm_imp_eli5PD.to_json()
PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracy) PerFeatureAccuracyPandas = pd.DataFrame(PerFeatureAccuracyAll)
PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json() PerFeatureAccuracyPandas = PerFeatureAccuracyPandas.to_json()
bestfeatures = SelectKBest(score_func=chi2, k='all') bestfeatures = SelectKBest(score_func=chi2, k='all')
@ -452,18 +465,18 @@ def SendEachClassifiersPerformanceToVisualize():
} }
return jsonify(response) return jsonify(response)
#def Remove(duplicate): def Remove(duplicate):
# final_list = [] final_list = []
# for num in duplicate: for num in duplicate:
# if num not in final_list: if num not in final_list:
# if (isinstance(num, float)): if (isinstance(num, float)):
# if np.isnan(num): if np.isnan(num):
# pass pass
# else: else:
# final_list.append(int(num)) final_list.append(int(num))
# else: else:
# final_list.append(num) final_list.append(num)
# return final_list return final_list
# Retrieve data from client # Retrieve data from client
@cross_origin(origin='localhost',headers=['Content-Type','Authorization']) @cross_origin(origin='localhost',headers=['Content-Type','Authorization'])
@ -487,7 +500,7 @@ def RetrieveModelsParam():
KNNModels.append(int(RetrieveModelsPar['models'][index])) KNNModels.append(int(RetrieveModelsPar['models'][index]))
else: else:
counter2 = counter2 + 1 counter2 = counter2 + 1
RFModels.append(int(RetrieveModelsPar['models'][index])-576) RFModels.append(int(RetrieveModelsPar['models'][index]))
return 'Everything Okay' return 'Everything Okay'
@ -497,35 +510,33 @@ def RetrieveModelsParam():
def RetrieveFactors(): def RetrieveFactors():
Factors = request.get_data().decode('utf8').replace("'", '"') Factors = request.get_data().decode('utf8').replace("'", '"')
FactorsInt = json.loads(Factors) FactorsInt = json.loads(Factors)
factors = FactorsInt['Factors']
global sumPerClassifierSel global sumPerClassifierSel
global ModelSpaceMDSNew global ModelSpaceMDSNew
global ModelSpaceTSNENew global ModelSpaceTSNENew
global metricsPerModel
sumPerClassifierSel = [] sumPerClassifierSel = []
sumPerClassifierSel = sumPerMetric(FactorsInt['Factors']) sumPerClassifierSel = preProcsumPerMetric(factors)
ModelSpaceMDSNew = [] ModelSpaceMDSNew = []
ModelSpaceTSNENew = [] ModelSpaceTSNENew = []
preProcessResults = [] loopThroughMetrics = PreprocessingMetrics()
preProcessResults = Preprocessing() metricsPerModel = preProcMetricsAllAndSel()
XClassifiers = preProcessResults[3]
flagLocal = 0 flagLocal = 0
countRemovals = 0 countRemovals = 0
for l,el in enumerate(FactorsInt['Factors']): for l,el in enumerate(factors):
if el is 0: if el is 0:
XClassifiers.drop(XClassifiers.columns[[l-countRemovals]], axis=1, inplace=True) loopThroughMetrics.drop(loopThroughMetrics.columns[[l-countRemovals]], axis=1, inplace=True)
countRemovals = countRemovals + 1 countRemovals = countRemovals + 1
flagLocal = 1 flagLocal = 1
if flagLocal is 1: if flagLocal is 1:
ModelSpaceMDSNew = FunMDS(XClassifiers) ModelSpaceMDSNew = FunMDS(loopThroughMetrics)
ModelSpaceTSNENew = FunTsne(XClassifiers) ModelSpaceTSNENew = FunTsne(loopThroughMetrics)
ModelSpaceTSNENew = ModelSpaceTSNENew.tolist() ModelSpaceTSNENew = ModelSpaceTSNENew.tolist()
return 'Everything Okay' return 'Everything Okay'
@app.route('/data/UpdateOverv', methods=["GET", "POST"]) @app.route('/data/UpdateOverv', methods=["GET", "POST"])
def UpdateOverview(): def UpdateOverview():
global sumPerClassifierSel
global ModelSpaceMDSNew
global ModelSpaceTSNENew
global metricsPerModel
ResultsUpdateOverview = [] ResultsUpdateOverview = []
ResultsUpdateOverview.append(sumPerClassifierSel) ResultsUpdateOverview.append(sumPerClassifierSel)
ResultsUpdateOverview.append(ModelSpaceMDSNew) ResultsUpdateOverview.append(ModelSpaceMDSNew)
@ -540,9 +551,11 @@ def PreprocessingMetrics():
dicKNN = json.loads(allParametersPerformancePerModel[6]) dicKNN = json.loads(allParametersPerformancePerModel[6])
dicRF = json.loads(allParametersPerformancePerModel[14]) dicRF = json.loads(allParametersPerformancePerModel[14])
dfKNN = pd.DataFrame.from_dict(dicKNN) dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNNFiltered = dfKNN.iloc[KNNModels, :] dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF) dfRF = pd.DataFrame.from_dict(dicRF)
dfRFFiltered = dfRF.iloc[RFModels, :] dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
df_concatMetrics = pd.concat([dfKNNFiltered, dfRFFiltered]) df_concatMetrics = pd.concat([dfKNNFiltered, dfRFFiltered])
return df_concatMetrics return df_concatMetrics
@ -550,17 +563,122 @@ def PreprocessingPred():
dicKNN = json.loads(allParametersPerformancePerModel[7]) dicKNN = json.loads(allParametersPerformancePerModel[7])
dicRF = json.loads(allParametersPerformancePerModel[15]) dicRF = json.loads(allParametersPerformancePerModel[15])
dfKNN = pd.DataFrame.from_dict(dicKNN) dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNNFiltered = dfKNN.iloc[KNNModels, :] dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF) dfRF = pd.DataFrame.from_dict(dicRF)
dfRFFiltered = dfRF.iloc[RFModels, :] dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
df_concatProbs = pd.concat([dfKNNFiltered, dfRFFiltered]) df_concatProbs = pd.concat([dfKNNFiltered, dfRFFiltered])
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 predictions return predictions
def PreprocessingParam():
dicKNN = json.loads(allParametersPerformancePerModel[1])
dicRF = json.loads(allParametersPerformancePerModel[9])
dicKNN = dicKNN['params']
dicRF = dicRF['params']
dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNN = dfKNN.T
dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF)
dfRF = dfRF.T
dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
df_params = pd.concat([dfKNNFiltered, dfRFFiltered])
return df_params
def PreprocessingParamSep():
dicKNN = json.loads(allParametersPerformancePerModel[1])
dicRF = json.loads(allParametersPerformancePerModel[9])
dicKNN = dicKNN['params']
dicRF = dicRF['params']
dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNN = dfKNN.T
dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF)
dfRF = dfRF.T
dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
return [dfKNNFiltered,dfRFFiltered]
def preProcessPerClassM():
dicKNN = json.loads(allParametersPerformancePerModel[2])
dicRF = json.loads(allParametersPerformancePerModel[10])
dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF)
dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
df_concatParams = pd.concat([dfKNNFiltered, dfRFFiltered])
return df_concatParams
def preProcessFeatAcc():
dicKNN = json.loads(allParametersPerformancePerModel[3])
dicRF = json.loads(allParametersPerformancePerModel[11])
dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF)
dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
df_featAcc = pd.concat([dfKNNFiltered, dfRFFiltered])
return df_featAcc
def preProcessPerm():
dicKNN = json.loads(allParametersPerformancePerModel[4])
dicRF = json.loads(allParametersPerformancePerModel[12])
dfKNN = pd.DataFrame.from_dict(dicKNN)
dfKNN.index = dfKNN.index.astype(int)
dfKNNFiltered = dfKNN.loc[KNNModels, :]
dfRF = pd.DataFrame.from_dict(dicRF)
dfRF.index = dfRF.index.astype(int) + 576
dfRFFiltered = dfRF.loc[RFModels, :]
df_perm = pd.concat([dfKNNFiltered, dfRFFiltered])
return df_perm
def preProcessFeatSc():
dicKNN = json.loads(allParametersPerformancePerModel[5])
dfKNN = pd.DataFrame.from_dict(dicKNN)
return dfKNN
def preProcsumPerMetric(factors):
sumPerClassifier = []
loopThroughMetrics = PreprocessingMetrics()
for row in loopThroughMetrics.iterrows():
rowSum = 0
lengthFactors = len(scoring)
name, values = row
for loop, elements in enumerate(values):
lengthFactors = lengthFactors - 1 + factors[loop]
rowSum = elements*factors[loop] + rowSum
if lengthFactors is 0:
sumPerClassifier = 0
else:
sumPerClassifier.append(rowSum/lengthFactors)
return sumPerClassifier
def preProcMetricsAllAndSel():
loopThroughMetrics = PreprocessingMetrics()
metricsPerModelColl = []
metricsPerModelColl.append(loopThroughMetrics['mean_test_accuracy'].sum()/loopThroughMetrics['mean_test_accuracy'].count())
metricsPerModelColl.append(loopThroughMetrics['mean_test_f1_macro'].sum()/loopThroughMetrics['mean_test_f1_macro'].count())
metricsPerModelColl.append(loopThroughMetrics['mean_test_precision'].sum()/loopThroughMetrics['mean_test_precision'].count())
metricsPerModelColl.append(loopThroughMetrics['mean_test_recall'].sum()/loopThroughMetrics['mean_test_recall'].count())
metricsPerModelColl.append(loopThroughMetrics['mean_test_jaccard'].sum()/loopThroughMetrics['mean_test_jaccard'].count())
for index, metric in enumerate(metricsPerModelColl):
metricsPerModelColl[index] = metric*factors[index]
return metricsPerModelColl
def preProceModels():
models = KNNModels + RFModels
return models
def FunMDS (data): def FunMDS (data):
mds = MDS(n_components=2, random_state=RANDOM_SEED) mds = MDS(n_components=2, random_state=RANDOM_SEED)
XTransformed = mds.fit_transform(data).T XTransformed = mds.fit_transform(data).T
@ -578,6 +696,9 @@ def InitializeEnsemble():
DataSpace = FunTsne(XData) DataSpace = FunTsne(XData)
DataSpaceList = DataSpace.tolist() DataSpaceList = DataSpace.tolist()
global ModelSpaceMDS
global ModelSpaceTSNE
ModelSpaceMDS = FunMDS(XModels) ModelSpaceMDS = FunMDS(XModels)
ModelSpaceTSNE = FunTsne(XModels) ModelSpaceTSNE = FunTsne(XModels)
ModelSpaceTSNE = ModelSpaceTSNE.tolist() ModelSpaceTSNE = ModelSpaceTSNE.tolist()
@ -586,9 +707,10 @@ def InitializeEnsemble():
PredictionSpace = FunTsne(PredictionProbSel) PredictionSpace = FunTsne(PredictionProbSel)
PredictionSpaceList = PredictionSpace.tolist() PredictionSpaceList = PredictionSpace.tolist()
ModelsIDs = preProceModels()
key = 0 key = 0
global scores EnsembleModel(ModelsIDs, key)
scores = EnsembleModel(key)
ReturnResults(ModelSpaceMDS,ModelSpaceTSNE,DataSpaceList,PredictionSpaceList) ReturnResults(ModelSpaceMDS,ModelSpaceTSNE,DataSpaceList,PredictionSpaceList)
@ -597,17 +719,40 @@ def ReturnResults(ModelSpaceMDS,ModelSpaceTSNE,DataSpaceList,PredictionSpaceList
global Results global Results
Results = [] Results = []
parametersGen = PreprocessingParam()
PerClassMetrics = preProcessPerClassM()
FeatureAccuracy = preProcessFeatAcc()
perm_imp_eli5PDCon = preProcessPerm()
featureScoresCon = preProcessFeatSc()
metricsPerModel = preProcMetricsAllAndSel()
sumPerClassifier = preProcsumPerMetric(factors)
ModelsIDs = preProceModels()
parametersGenPD = parametersGen.to_json(orient='records')
PerClassMetrics = PerClassMetrics.to_json(orient='records')
FeatureAccuracy = FeatureAccuracy.to_json(orient='records')
perm_imp_eli5PDCon = perm_imp_eli5PDCon.to_json(orient='records')
featureScoresCon = featureScoresCon.to_json(orient='records')
XDataJSON = XData.columns.tolist() XDataJSON = XData.columns.tolist()
Results.append(json.dumps(ModelSpaceMDS)) # Position: 0 Results.append(json.dumps(sumPerClassifier)) # Position: 0
Results.append(json.dumps(target_names)) # Position: 1 Results.append(json.dumps(ModelSpaceMDS)) # Position: 1
Results.append(json.dumps(XDataJSON)) # Position: 2 Results.append(json.dumps(parametersGenPD)) # Position: 2
Results.append(json.dumps(DataSpaceList)) # Position: 3 Results.append(PerClassMetrics) # Position: 3
Results.append(json.dumps(PredictionSpaceList)) # Position: 4 Results.append(json.dumps(target_names)) # Position: 4
Results.append(json.dumps(ModelSpaceTSNE)) # Position: 5 Results.append(FeatureAccuracy) # Position: 5
Results.append(json.dumps(XDataJSON)) # Position: 6
Results.append(json.dumps(DataSpaceList)) # Position: 7
Results.append(json.dumps(PredictionSpaceList)) # Position: 8
Results.append(json.dumps(metricsPerModel)) # Position: 9
Results.append(perm_imp_eli5PDCon) # Position: 10
Results.append(featureScoresCon) # Position: 11
Results.append(json.dumps(ModelSpaceTSNE)) # Position: 12
Results.append(json.dumps(ModelsIDs)) # Position: 13
return Results return Results
# Sending the overview classifiers' results to be visualized as a scatterplot # Sending the overview classifiers' results to be visualized as a scatterplot
@app.route('/data/PlotClassifiers', methods=["GET", "POST"]) @app.route('/data/PlotClassifiers', methods=["GET", "POST"])
def SendToPlot(): def SendToPlot():
@ -623,58 +768,274 @@ def SendToPlot():
@cross_origin(origin='localhost',headers=['Content-Type','Authorization']) @cross_origin(origin='localhost',headers=['Content-Type','Authorization'])
@app.route('/data/ServerRequestSelPoin', methods=["GET", "POST"]) @app.route('/data/ServerRequestSelPoin', methods=["GET", "POST"])
def RetrieveSelClassifiersID(): def RetrieveSelClassifiersID():
global ClassifierIDsList
ClassifierIDsList = request.get_data().decode('utf8').replace("'", '"') ClassifierIDsList = request.get_data().decode('utf8').replace("'", '"')
ComputeMetricsForSel(ClassifierIDsList)
key = 1 key = 1
EnsembleModel(ClassifierIDsList, key) EnsembleModel(ClassifierIDsList, key)
return 'Everything Okay' return 'Everything Okay'
def ComputeMetricsForSel(Models):
Models = json.loads(Models)
MetricsAlltoSel = PreprocessingMetrics()
listofModels = []
for loop in Models['ClassifiersList']:
temp = [int(s) for s in re.findall(r'\b\d+\b', loop)]
listofModels.append(temp[0])
MetricsAlltoSel = MetricsAlltoSel.loc[listofModels,:]
global metricsPerModelCollSel
metricsPerModelCollSel = []
metricsPerModelCollSel.append(MetricsAlltoSel['mean_test_accuracy'].sum()/MetricsAlltoSel['mean_test_accuracy'].count())
metricsPerModelCollSel.append(MetricsAlltoSel['mean_test_f1_macro'].sum()/MetricsAlltoSel['mean_test_f1_macro'].count())
metricsPerModelCollSel.append(MetricsAlltoSel['mean_test_precision'].sum()/MetricsAlltoSel['mean_test_precision'].count())
metricsPerModelCollSel.append(MetricsAlltoSel['mean_test_recall'].sum()/MetricsAlltoSel['mean_test_recall'].count())
metricsPerModelCollSel.append(MetricsAlltoSel['mean_test_jaccard'].sum()/MetricsAlltoSel['mean_test_jaccard'].count())
for index, metric in enumerate(metricsPerModelCollSel):
metricsPerModelCollSel[index] = metric*factors[index]
return 'okay'
# Sending the overview classifiers' results to be visualized as a scatterplot
@app.route('/data/BarChartSelectedModels', methods=["GET", "POST"])
def SendToUpdateBarChart():
response = {
'SelectedMetricsForModels': metricsPerModelCollSel
}
return jsonify(response)
# Retrieve data from client # Retrieve data from client
@cross_origin(origin='localhost',headers=['Content-Type','Authorization']) @cross_origin(origin='localhost',headers=['Content-Type','Authorization'])
@app.route('/data/FeaturesSelection', methods=["GET", "POST"]) @app.route('/data/ServerRequestDataPoint', methods=["GET", "POST"])
def FeatureSelPerModel(): def RetrieveSelDataPoints():
global featureSelection
global ClassifierIDsList DataPointsSel = request.get_data().decode('utf8').replace("'", '"')
featureSelection = request.get_data().decode('utf8').replace("'", '"') DataPointsSelClear = json.loads(DataPointsSel)
featureSelection = json.loads(featureSelection) listofDataPoints = []
global detailsParams for loop in DataPointsSelClear['DataPointsSel']:
global algorithmList temp = [int(s) for s in re.findall(r'\b\d+\b', loop)]
results = [] listofDataPoints.append(temp[0])
global resultsList
resultsList = [] paramsListSepPD = []
global loopFeatures paramsListSepPD = PreprocessingParamSep()
loopFeatures = 2
algorithmsWithoutDuplicates = list(dict.fromkeys(algorithmList)) paramsListSeptoDicKNN = paramsListSepPD[0].to_dict(orient='list')
for index, eachalgor in enumerate(algorithmsWithoutDuplicates): paramsListSeptoDicRF = paramsListSepPD[1].to_dict(orient='list')
if (eachalgor == 'KNN'):
RetrieveParamsCleared = {}
RetrieveParamsClearedListKNN = []
for key, value in paramsListSeptoDicKNN.items():
withoutDuplicates = Remove(value)
RetrieveParamsCleared[key] = withoutDuplicates
RetrieveParamsClearedListKNN.append(RetrieveParamsCleared)
RetrieveParamsCleared = {}
RetrieveParamsClearedListRF = []
for key, value in paramsListSeptoDicRF.items():
withoutDuplicates = Remove(value)
RetrieveParamsCleared[key] = withoutDuplicates
RetrieveParamsClearedListRF.append(RetrieveParamsCleared)
if (len(paramsListSeptoDicKNN['n_neighbors']) is 0):
RetrieveParamsClearedListKNN = []
if (len(paramsListSeptoDicRF['n_estimators']) is 0):
RetrieveParamsClearedListRF = []
for eachAlgor in algorithms:
if (eachAlgor) == 'KNN':
clf = KNeighborsClassifier() clf = KNeighborsClassifier()
params = detailsParams[index] #params = {'n_neighbors': list(range(1, 25)), 'weights': ['uniform', 'distance'], 'algorithm': ['brute', 'kd_tree', 'ball_tree'], 'metric': ['chebyshev', 'manhattan', 'euclidean', 'minkowski']}
results.append(GridSearch(clf, params)) params = RetrieveParamsClearedListKNN
resultsList.append(results[0]) AlgorithmsIDsEnd = 0
else: else:
clf = RandomForestClassifier() clf = RandomForestClassifier()
params = detailsParams[index] #params = {'n_estimators': list(range(40, 120)), 'criterion': ['gini', 'entropy']}
results.append(GridSearch(clf, params)) params = RetrieveParamsClearedListRF
resultsList.append(results[0]) AlgorithmsIDsEnd = 576
if (featureSelection['featureSelection'] == ''): metricsSelList = GridSearchSel(clf, params, factors, AlgorithmsIDsEnd, listofDataPoints)
key = 0 if (len(metricsSelList[0]) != 0 and len(metricsSelList[1]) != 0):
dicKNN = json.loads(metricsSelList[0])
dfKNN = pd.DataFrame.from_dict(dicKNN)
parametersSelDataPD = parametersSelData[0].apply(pd.Series)
set_diff_df = pd.concat([parametersSelDataPD, paramsListSepPD[0], paramsListSepPD[0]]).drop_duplicates(keep=False)
set_diff_df = set_diff_df.index.tolist()
if (len(set_diff_df) == 0):
dfKNNCleared = dfKNN
else: else:
key = 2 dfKNNCleared = dfKNN.drop(dfKNN.index[set_diff_df])
dicRF = json.loads(metricsSelList[1])
dfRF = pd.DataFrame.from_dict(dicRF)
parametersSelDataPD = parametersSelData[1].apply(pd.Series)
set_diff_df = pd.concat([parametersSelDataPD, paramsListSepPD[1], paramsListSepPD[1]]).drop_duplicates(keep=False)
set_diff_df = set_diff_df.index.tolist()
if (len(set_diff_df) == 0):
dfRFCleared = dfRF
else:
dfRFCleared = dfRF.drop(dfRF.index[set_diff_df])
df_concatMetrics = pd.concat([dfKNNCleared, dfRFCleared])
else:
if (len(metricsSelList[0]) != 0):
dicKNN = json.loads(metricsSelList[0])
dfKNN = pd.DataFrame.from_dict(dicKNN)
parametersSelDataPD = parametersSelData[0].apply(pd.Series)
set_diff_df = pd.concat([parametersSelDataPD, paramsListSepPD[0], paramsListSepPD[0]]).drop_duplicates(keep=False)
set_diff_df = set_diff_df.index.tolist()
if (len(set_diff_df) == 0):
dfKNNCleared = dfKNN
else:
dfKNNCleared = dfKNN.drop(dfKNN.index[set_diff_df])
df_concatMetrics = dfKNNCleared
else:
dicRF = json.loads(metricsSelList[1])
dfRF = pd.DataFrame.from_dict(dicRF)
parametersSelDataPD = parametersSelData[1].apply(pd.Series)
set_diff_df = pd.concat([parametersSelDataPD, paramsListSepPD[1], paramsListSepPD[1]]).drop_duplicates(keep=False)
set_diff_df = set_diff_df.index.tolist()
if (len(set_diff_df) == 0):
dfRFCleared = dfRF
else:
dfRFCleared = dfRF.drop(dfRF.index[set_diff_df])
df_concatMetrics = dfRFCleared
global sumPerClassifierSelUpdate
sumPerClassifierSelUpdate = []
sumPerClassifierSelUpdate = preProcsumPerMetricAccordingtoData(factors, df_concatMetrics)
ModelSpaceMDSNewComb = [list(a) for a in zip(ModelSpaceMDS[0], ModelSpaceMDS[1])]
ModelSpaceMDSNewSel = FunMDS(df_concatMetrics)
ModelSpaceMDSNewSelComb = [list(a) for a in zip(ModelSpaceMDSNewSel[0], ModelSpaceMDSNewSel[1])]
global mt2xFinal
mt2xFinal = []
mtx1, mtx2, disparity = procrustes(ModelSpaceMDSNewComb, ModelSpaceMDSNewSelComb)
a, b = zip(*mtx2)
mt2xFinal.append(a)
mt2xFinal.append(b)
return 'Everything Okay' return 'Everything Okay'
location = './cachedir'
memory = Memory(location, verbose=0)
@memory.cache def GridSearchSel(clf, params, factors, AlgorithmsIDsEnd, DataPointsSel):
def EnsembleModel(keyRetrieved): if (len(params) == 0):
resultsMetrics.append([]) # Position: 0 and so on
parametersSelData.append([])
else:
# instantiate spark session
spark = (
SparkSession
.builder
.getOrCreate()
)
sc = spark.sparkContext
XDatasubset = XData.loc[DataPointsSel,:]
yDataSubset = [yData[i] for i in DataPointsSel]
# this is the grid we use to train the models
grid = DistGridSearchCV(
estimator=clf, param_grid=params,
sc=sc, cv=crossValidation, refit='accuracy', scoring=scoring,
verbose=0, n_jobs=-1)
# fit and extract the probabilities
grid.fit(XDatasubset, yDataSubset)
# process the results
cv_results = []
cv_results.append(grid.cv_results_)
df_cv_results = pd.DataFrame.from_dict(cv_results)
# number of models stored
number_of_models = len(df_cv_results.iloc[0][0])
# initialize results per row
df_cv_results_per_row = []
# loop through number of models
modelsIDs = []
for i in range(number_of_models):
modelsIDs.append(AlgorithmsIDsEnd+i)
# initialize results per item
df_cv_results_per_item = []
for column in df_cv_results.iloc[0]:
df_cv_results_per_item.append(column[i])
df_cv_results_per_row.append(df_cv_results_per_item)
# store the results into a pandas dataframe
df_cv_results_classifiers = pd.DataFrame(data = df_cv_results_per_row, columns= df_cv_results.columns)
parametersSelData.append(df_cv_results_classifiers['params'])
# copy and filter in order to get only the metrics
metrics = df_cv_results_classifiers.copy()
metrics = metrics.filter(['mean_test_accuracy','mean_test_f1_macro','mean_test_precision','mean_test_recall','mean_test_jaccard'])
metrics = metrics.to_json()
resultsMetrics.append(metrics) # Position: 0 and so on
return resultsMetrics
def preProcsumPerMetricAccordingtoData(factors, loopThroughMetrics):
sumPerClassifier = []
for row in loopThroughMetrics.iterrows():
rowSum = 0
lengthFactors = len(scoring)
name, values = row
for loop, elements in enumerate(values):
lengthFactors = lengthFactors - 1 + factors[loop]
rowSum = elements*factors[loop] + rowSum
if lengthFactors is 0:
sumPerClassifier = 0
else:
sumPerClassifier.append(rowSum/lengthFactors)
return sumPerClassifier
# Sending the overview classifiers' results to be visualized as a scatterplot
@app.route('/data/ServerSentDataPointsModel', methods=["GET", "POST"])
def SendDataPointsModels():
ResultsUpdate = []
global sumPerClassifierSelUpdate
sumPerClassifierSelUpdateJSON = json.dumps(sumPerClassifierSelUpdate)
ResultsUpdate.append(sumPerClassifierSelUpdateJSON)
global mt2xFinal
mt2xFinalJSON = json.dumps(mt2xFinal)
ResultsUpdate.append(mt2xFinalJSON)
response = {
'DataPointsModels': ResultsUpdate
}
return jsonify(response)
# Retrieve data from client
@cross_origin(origin='localhost',headers=['Content-Type','Authorization'])
@app.route('/data/FeaturesSelection', methods=["GET", "POST"])
def FeatureSelPerModel():
global featureSelection
featureSelection = request.get_data().decode('utf8').replace("'", '"')
featureSelection = json.loads(featureSelection)
key = 2
ModelsIDs = preProceModels()
EnsembleModel(ModelsIDs, key)
return 'Everything Okay'
def EnsembleModel(Models, keyRetrieved):
global scores
scores = []
scoresLocal = [] global all_classifiersSelection
all_classifiersSelection = [] all_classifiersSelection = []
sclf = 0
lr = LogisticRegression()
if (keyRetrieved == 0): if (keyRetrieved == 0):
columnsInit = [] global all_classifiers
all_classifiers = [] all_classifiers = []
columnsInit = []
columnsInit = [XData.columns.get_loc(c) for c in XData.columns if c in XData] columnsInit = [XData.columns.get_loc(c) for c in XData.columns if c in XData]
temp = json.loads(allParametersPerformancePerModel[1]) temp = json.loads(allParametersPerformancePerModel[1])
@ -689,77 +1050,108 @@ def EnsembleModel(keyRetrieved):
dfParamRF = pd.DataFrame.from_dict(temp) dfParamRF = pd.DataFrame.from_dict(temp)
dfParamRFFilt = dfParamRF.iloc[:,1] dfParamRFFilt = dfParamRF.iloc[:,1]
for eachelem in RFModels: for eachelem in RFModels:
arg = dfParamRFFilt[eachelem] arg = dfParamRFFilt[eachelem-576]
all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsInit), RandomForestClassifier().set_params(**arg))) all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsInit), RandomForestClassifier().set_params(**arg)))
lr = LogisticRegression() global sclfStack
sclfStack = 0
sclf = StackingCVClassifier(classifiers=all_classifiers, sclf = StackingCVClassifier(classifiers=all_classifiers,
use_probas=True, use_probas=True,
meta_classifier=lr, meta_classifier=lr,
random_state=RANDOM_SEED, random_state=RANDOM_SEED,
n_jobs = -1) n_jobs = -1)
sclfStack = sclf
elif (keyRetrieved == 1): elif (keyRetrieved == 1):
ClassifierIDsList = json.loads(ClassifierIDsList) Models = json.loads(Models)
for loop in ClassifierIDsList['ClassifiersList']: ModelsAll = preProceModels()
for index, modHere in enumerate(ModelsAll):
flag = 0
for loop in Models['ClassifiersList']:
temp = [int(s) for s in re.findall(r'\b\d+\b', loop)] temp = [int(s) for s in re.findall(r'\b\d+\b', loop)]
all_classifiersSelection.append(all_classifiers[temp[0]]) if (int(temp[0]) == int(modHere)):
flag = 1
if (flag is 1):
all_classifiersSelection.append(all_classifiers[index])
lr = LogisticRegression()
sclf = StackingCVClassifier(classifiers=all_classifiersSelection, sclf = StackingCVClassifier(classifiers=all_classifiersSelection,
use_probas=True, use_probas=True,
meta_classifier=lr, meta_classifier=lr,
random_state=RANDOM_SEED, random_state=RANDOM_SEED,
n_jobs = -1) n_jobs = -1)
else: else:
columnsReduce = columns.copy()
lr = LogisticRegression()
if (len(all_classifiersSelection) == 0): if (len(all_classifiersSelection) == 0):
all_classifiers = [] all_classifiers = []
for index, eachelem in enumerate(algorithmsWithoutDuplicates): columnsInit = []
if (eachelem == 'KNN'):
for j, each in enumerate(resultsList[index][1]): temp = json.loads(allParametersPerformancePerModel[1])
all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsReduce[j]), KNeighborsClassifier().set_params(**each))) dfParamKNN = pd.DataFrame.from_dict(temp)
del columnsReduce[0:len(resultsList[index][1])] dfParamKNNFilt = dfParamKNN.iloc[:,1]
print(featureSelection)
flag = 0
for index, eachelem in enumerate(KNNModels):
arg = dfParamKNNFilt[eachelem]
all_classifiers.append(make_pipeline(ColumnSelector(cols=featureSelection['featureSelection'][index]), KNeighborsClassifier().set_params(**arg)))
store = index
flag = 1
temp = json.loads(allParametersPerformancePerModel[9])
dfParamRF = pd.DataFrame.from_dict(temp)
dfParamRFFilt = dfParamRF.iloc[:,1]
if (flag == 0):
store = 0
else: else:
for j, each in enumerate(resultsList[index][1]): store = store + 1
all_classifiers.append(make_pipeline(ColumnSelector(cols=columnsReduce[j]), RandomForestClassifier().set_params(**each))) for index, eachelem in enumerate(RFModels):
del columnsReduce[0:len(resultsList[index][1])] arg = dfParamRFFilt[eachelem-576]
print(index)
print(featureSelection['featureSelection'][index+store])
all_classifiers.append(make_pipeline(ColumnSelector(cols=featureSelection['featureSelection'][index+store]), RandomForestClassifier().set_params(**arg)))
sclf = StackingCVClassifier(classifiers=all_classifiers, sclf = StackingCVClassifier(classifiers=all_classifiers,
use_probas=True, use_probas=True,
meta_classifier=lr, meta_classifier=lr,
random_state=RANDOM_SEED, random_state=RANDOM_SEED,
n_jobs = -1) n_jobs = -1)
else: #else:
for index, eachelem in enumerate(algorithmsWithoutDuplicates): # for index, eachelem in enumerate(algorithmsWithoutDuplicates):
if (eachelem == 'KNN'): # if (eachelem == 'KNN'):
for j, each in enumerate(resultsList[index][1]): # for j, each in enumerate(resultsList[index][1]):
all_classifiersSelection.append(make_pipeline(ColumnSelector(cols=columnsReduce[j]), KNeighborsClassifier().set_params(**each))) # all_classifiersSelection.append(make_pipeline(ColumnSelector(cols=columnsReduce[j]), KNeighborsClassifier().set_params(**each)))
del columnsReduce[0:len(resultsList[index][1])] # del columnsReduce[0:len(resultsList[index][1])]
else: # else:
for j, each in enumerate(resultsList[index][1]): # for j, each in enumerate(resultsList[index][1]):
all_classifiersSelection.append(make_pipeline(ColumnSelector(cols=columnsReduce[j]), RandomForestClassifier().set_params(**each))) # all_classifiersSelection.append(make_pipeline(ColumnSelector(cols=columnsReduce[j]), RandomForestClassifier().set_params(**each)))
del columnsReduce[0:len(resultsList[index][1])] # del columnsReduce[0:len(resultsList[index][1])]
sclf = StackingCVClassifier(classifiers=all_classifiersSelection, # sclf = StackingCVClassifier(classifiers=all_classifiersSelection,
use_probas=True, # use_probas=True,
meta_classifier=lr, # meta_classifier=lr,
random_state=RANDOM_SEED, # random_state=RANDOM_SEED,
n_jobs = -1) # n_jobs = -1)
for clf, label in zip([sclf], temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring='accuracy', n_jobs=-1)
['StackingClassifier']): scores.append(temp.mean())
scores.append(temp.std())
scoresLocal = model_selection.cross_val_score(clf, XData, yData, cv=crossValidation, scoring='accuracy') temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring='precision_weighted', n_jobs=-1)
return scoresLocal scores.append(temp.mean())
scores.append(temp.std())
temp = model_selection.cross_val_score(sclf, XData, yData, cv=crossValidation, scoring='recall_weighted', n_jobs=-1)
scores.append(temp.mean())
scores.append(temp.std())
temp = model_selection.cross_val_score(sclfStack, XData, yData, cv=crossValidation, scoring='accuracy', n_jobs=-1)
scores.append(temp.mean())
scores.append(temp.std())
temp = model_selection.cross_val_score(sclfStack, XData, yData, cv=crossValidation, scoring='precision_weighted', n_jobs=-1)
scores.append(temp.mean())
scores.append(temp.std())
temp = model_selection.cross_val_score(sclfStack, XData, yData, cv=crossValidation, scoring='recall_weighted', n_jobs=-1)
scores.append(temp.mean())
scores.append(temp.std())
return 'Okay'
# Sending the final results to be visualized as a line plot # Sending the final results to be visualized as a line plot
@app.route('/data/SendFinalResultsBacktoVisualize', methods=["GET", "POST"]) @app.route('/data/SendFinalResultsBacktoVisualize', methods=["GET", "POST"])
def SendToPlotFinalResults(): def SendToPlotFinalResults():
FinalResults = []
FinalResults.append(scores.mean())
FinalResults.append(scores.std())
response = { response = {
'FinalResults': FinalResults 'FinalResults': scores
} }
return jsonify(response) return jsonify(response)
Loading…
Cancel
Save