fixed grid-based

master
parent ba89ac64d4
commit 8266eb3ad3
  1. BIN
      __pycache__/run.cpython-37.pyc
  2. 37
      frontend/src/components/Main.vue
  3. 439
      frontend/src/components/Predictions.vue
  4. 2
      frontend/src/components/VotingResults.vue
  5. 13
      run.py

Binary file not shown.

@ -15,24 +15,24 @@
</mdb-card-body>
</mdb-card>
</b-col>
<!--
<b-col cols="6">
<mdb-card>
<mdb-card-header color="primary-color" tag="h5" class="text-center">Hyper-parameters' Space</mdb-card-header>
<mdb-card-header color="primary-color" tag="h5" class="text-center">Provenance</mdb-card-header>
<mdb-card-body>
<ScatterPlot/>
<mdb-card-text class="text-left" style="font-size: 18.5px; min-height: 230px">
</mdb-card-text>
</mdb-card-body>
</mdb-card>
</b-col>
<b-col cols="3">
<mdb-card >
<mdb-card-header color="primary-color" tag="h5" class="text-center" style="background-color: #C0C0C0;"><small class="float-left" style="padding-top: 3px;"><font-awesome-icon class="fa-lg" icon="dice-four"/>&nbsp;Metrics Support: [M1, M3-M5 (W)]</small>Metamodel's Performance</mdb-card-header>
<mdb-card-header color="primary-color" tag="h5" class="text-center">Majority Voting Results</mdb-card-header>
<mdb-card-body>
<FinalResultsLinePlot/>
<mdb-card-text class="text-left" style="font-size: 18.5px; min-height: 230px">
</mdb-card-text>
</mdb-card-body>
</mdb-card>
</b-col>
-->
</b-row>
<!--
<hr/>
@ -122,7 +122,7 @@
[Sel: {{OverSelLength}} / All: {{OverAllLength}}]<small class="float-right"><active-scatter/></small>
</mdb-card-header>
<mdb-card-body>
<mdb-card-text class="text-center" style="min-height: 822px">
<mdb-card-text class="text-center" style="min-height: 600px">
<HyperParameterSpace/>
</mdb-card-text>
</mdb-card-body>
@ -134,13 +134,26 @@
[Sel: {{OverSelLengthCM}} / All: {{OverAllLengthCM}}]<small class="float-right"><active-scatter/></small>
</mdb-card-header>
<mdb-card-body>
<mdb-card-text class="text-center" style="min-height: 822px">
<mdb-card-text class="text-center" style="min-height: 600px">
<CrossoverMutationSpace/>
</mdb-card-text>
</mdb-card-body>
</mdb-card>
</b-col>
</b-row>
<b-row class="md-3">
<b-col cols="12">
<mdb-card style="margin-top: 15px;">
<mdb-card-header color="primary-color" tag="h5" class="text-center">Predictions' Space
</mdb-card-header>
<mdb-card-body>
<mdb-card-text class="text-center" style="min-height: 270px">
<Predictions/>
</mdb-card-text>
</mdb-card-body>
</mdb-card>
</b-col>
</b-row>
</div>
</div>
</b-container>
@ -156,8 +169,9 @@ import Algorithms from './Algorithms.vue'
import AlgorithmHyperParam from './AlgorithmHyperParam.vue'
import HyperParameterSpace from './HyperParameterSpace.vue'
import CrossoverMutationSpace from './CrossoverMutationSpace.vue'
import FinalResultsLinePlot from './FinalResultsLinePlot.vue'
import VotingResults from './VotingResults.vue'
import Parameters from './Parameters.vue'
import Predictions from './Predictions.vue'
import axios from 'axios'
import { loadProgressBar } from 'axios-progress-bar'
import 'axios-progress-bar/dist/nprogress.css'
@ -182,7 +196,8 @@ export default Vue.extend({
HyperParameterSpace,
CrossoverMutationSpace,
Parameters,
FinalResultsLinePlot,
Predictions,
VotingResults,
mdbCard,
mdbCardBody,
mdbCardHeader,
@ -289,6 +304,8 @@ export default Vue.extend({
this.OverviewResults = response.data.OverviewResults
console.log('Server successfully sent all the data related to visualizations!')
EventBus.$emit('emittedEventCallingScatterPlot', this.OverviewResults)
EventBus.$emit('emittedEventCallingGrid', this.OverviewResults)
EventBus.$emit('emittedEventCallingGridSelection', this.OverviewResults)
//this.getFinalResults()
})
.catch(error => {

@ -0,0 +1,439 @@
<template>
<div>
<div id="containerAll"></div>
<div id="containerSelection"></div>
</div>
</template>
<script>
import * as d3Base from 'd3'
import { EventBus } from '../main.js'
import $ from 'jquery'
import * as colorbr from 'colorbrewer'
// attach all d3 plugins to the d3 library
const d3 = Object.assign(d3Base)
const colorbrewer = Object.assign(colorbr)
export default {
name: "Predictions",
data () {
return {
GetResultsAll: [],
GetResultsSelection: [],
responsiveWidthHeight: [],
}
},
methods: {
reset () {
var svg = d3.select("#containerAll");
svg.selectAll("*").remove();
var svg = d3.select("#containerSelection");
svg.selectAll("*").remove();
},
Grid () {
Array.prototype.multiIndexOf = function (el) {
var idxs = [];
for (var i = this.length - 1; i >= 0; i--) {
if (this[i] === el) {
idxs.unshift(i);
}
}
return idxs;
};
// Clear Heatmap first
var svg = d3.select("#GridView");
svg.selectAll("*").remove();
var yValues = JSON.parse(this.GetResultsAll[6])
var targetNames = JSON.parse(this.GetResultsAll[7])
var getIndices = []
for (let i = 0; i < targetNames.length; i++) {
getIndices.push(yValues.multiIndexOf(targetNames[i]))
}
getIndices.reverse()
var predictions = JSON.parse(this.GetResultsAll[12])
var KNNPred = predictions[0]
var LRPred = predictions[1]
var PredAver = predictions[2]
var dataAver = []
var dataAverGetResults = []
var dataKNN = []
var dataKNNResults = []
var dataLR = []
var dataLRResults = []
var max = 0
for (let i = 0; i < targetNames.length; i++) {
if (getIndices[targetNames[i]].length > max) {
max = getIndices[targetNames[i]].length
}
}
var sqrtSize = Math.ceil(Math.sqrt(max))
var size = sqrtSize * sqrtSize
for (let i = 0; i < targetNames.length; i++) {
dataAver = [];
dataKNN = []
dataLR = []
getIndices[targetNames[i]].forEach(element => {
dataAver.push({ id: element, value: PredAver[element][targetNames[i]] })
dataKNN.push({ id: element, value: KNNPred[element][targetNames[i]] })
dataLR.push({ id: element, value: LRPred[element][targetNames[i]] })
});
for (let j = 0; j < size - getIndices[targetNames[i]].length; j++) {
dataAver.push({ id: null, value: 0.0 })
dataKNN.push({ id: null, value: 0.0 })
dataLR.push({ id: null, value: 0.0 })
}
dataAverGetResults.push(dataAver)
dataKNNResults.push(dataKNN)
dataLRResults.push(dataLR)
}
dataAverGetResults.reverse()
dataKNNResults.reverse()
dataLRResults.reverse()
var classArray = []
for (let i = 0; i < dataAverGetResults.length; i++) {
dataAverGetResults[i].sort((a, b) => (a.value > b.value) ? -1 : 1)
var len = dataAverGetResults[i].length
var indices = new Array(len)
for (let j = 0; j < len; j++) {
indices[j] = dataAverGetResults[i][j].id;
}
dataKNNResults[i].sort(function(a, b){
return indices.indexOf(a.id) - indices.indexOf(b.id)
});
dataLRResults[i].sort(function(a, b){
return indices.indexOf(a.id) - indices.indexOf(b.id)
});
classArray.push(dataAverGetResults[i].concat(dataKNNResults[i], dataLRResults[i]));
}
var classStore = [].concat.apply([], classArray);
// === Set up canvas === //
var width = 2500,
height = 125;
var colourScale;
var canvas = d3.select('#containerAll')
.append('canvas')
.attr('width', width)
.attr('height', height);
var context = canvas.node().getContext('2d');
// === Bind data to custom elements === //
var customBase = document.createElement('custom');
var custom = d3.select(customBase); // this is our svg replacement
// settings for a grid with 40 cells in a row and 2x5 cells in a group
var groupSpacing = 60;
var cellSpacing = 2;
var cellSize = Math.floor((width - 11 * groupSpacing) / (15.2*sqrtSize)) - cellSpacing;
// === First call === //
databind(classStore, size, sqrtSize); // ...then update the databind function
var t = d3.timer(function(elapsed) {
draw();
if (elapsed > 300) t.stop();
}); // start a timer that runs the draw function for 500 ms (this needs to be higher than the transition in the databind function)
// === Bind and draw functions === //
function databind(data, size, sqrtSize) {
colourScale = d3.scaleSequential(d3.interpolateReds).domain(d3.extent(data, function(d) { return d.value; }));
var join = custom.selectAll('custom.rect')
.data(data);
var enterSel = join.enter()
.append('custom')
.attr('class', 'rect')
.attr('x', function(d, i) {
var x0 = Math.floor(i / 169) % 13, x1 = Math.floor(i % 13);
return groupSpacing * x0 + (cellSpacing + cellSize) * (x1 + x0 * 10);
})
.attr('y', function(d, i) {
var y0 = Math.floor(i / 1000), y1 = Math.floor(i % 169 / 13);
return groupSpacing * y0 + (cellSpacing + cellSize) * (y1 + y0 * 10);
})
.attr('width', 0)
.attr('height', 0);
join
.merge(enterSel)
.transition()
.attr('width', cellSize)
.attr('height', cellSize)
.attr('fillStyle', function(d) { return colourScale(d.value); })
var exitSel = join.exit()
.transition()
.attr('width', 0)
.attr('height', 0)
.remove();
} // databind()
// === Draw canvas === //
function draw() {
// clear canvas
context.fillStyle = '#fff';
context.fillRect(0, 0, width, height);
// draw each individual custom element with their properties
var elements = custom.selectAll('custom.rect') // this is the same as the join variable, but used here to draw
elements.each(function(d,i) {
// for each virtual/custom element...
var node = d3.select(this);
context.fillStyle = node.attr('fillStyle');
context.fillRect(node.attr('x'), node.attr('y'), node.attr('width'), node.attr('height'))
});
} // draw()
},
GridSelection () {
Array.prototype.multiIndexOf = function (el) {
var idxs = [];
for (var i = this.length - 1; i >= 0; i--) {
if (this[i] === el) {
idxs.unshift(i);
}
}
return idxs;
};
// Clear Heatmap first
var svg = d3.select("#GridView");
svg.selectAll("*").remove();
var yValues = JSON.parse(this.GetResultsSelection[6])
var targetNames = JSON.parse(this.GetResultsSelection[7])
var getIndices = []
for (let i = 0; i < targetNames.length; i++) {
getIndices.push(yValues.multiIndexOf(targetNames[i]))
}
getIndices.reverse()
var predictions = JSON.parse(this.GetResultsSelection[12])
var KNNPred = predictions[0]
var LRPred = predictions[1]
var PredAver = predictions[2]
var dataAver = []
var dataAverGetResults = []
var dataKNN = []
var dataKNNResults = []
var dataLR = []
var dataLRResults = []
var max = 0
for (let i = 0; i < targetNames.length; i++) {
if (getIndices[targetNames[i]].length > max) {
max = getIndices[targetNames[i]].length
}
}
var sqrtSize = Math.ceil(Math.sqrt(max))
var size = sqrtSize * sqrtSize
for (let i = 0; i < targetNames.length; i++) {
dataAver = [];
dataKNN = []
dataLR = []
getIndices[targetNames[i]].forEach(element => {
dataAver.push({ id: element, value: PredAver[element][targetNames[i]] })
dataKNN.push({ id: element, value: KNNPred[element][targetNames[i]] })
dataLR.push({ id: element, value: LRPred[element][targetNames[i]] })
});
for (let j = 0; j < size - getIndices[targetNames[i]].length; j++) {
dataAver.push({ id: null, value: 0.0 })
dataKNN.push({ id: null, value: 0.0 })
dataLR.push({ id: null, value: 0.0 })
}
dataAverGetResults.push(dataAver)
dataKNNResults.push(dataKNN)
dataLRResults.push(dataLR)
}
dataAverGetResults.reverse()
dataKNNResults.reverse()
dataLRResults.reverse()
var classArray = []
for (let i = 0; i < dataAverGetResults.length; i++) {
dataAverGetResults[i].sort((a, b) => (a.value > b.value) ? -1 : 1)
var len = dataAverGetResults[i].length
var indices = new Array(len)
for (let j = 0; j < len; j++) {
indices[j] = dataAverGetResults[i][j].id;
}
dataKNNResults[i].sort(function(a, b){
return indices.indexOf(a.id) - indices.indexOf(b.id)
});
dataLRResults[i].sort(function(a, b){
return indices.indexOf(a.id) - indices.indexOf(b.id)
});
classArray.push(dataAverGetResults[i].concat(dataKNNResults[i], dataLRResults[i]));
}
var classStore = [].concat.apply([], classArray);
// === Set up canvas === //
var width = 2500,
height = 125;
var colourScale;
var canvas = d3.select('#containerSelection')
.append('canvas')
.attr('width', width)
.attr('height', height);
var context = canvas.node().getContext('2d');
// === Bind data to custom elements === //
var customBase = document.createElement('custom');
var custom = d3.select(customBase); // this is our svg replacement
// settings for a grid with 40 cells in a row and 2x5 cells in a group
var groupSpacing = 60;
var cellSpacing = 2;
var cellSize = Math.floor((width - 11 * groupSpacing) / (15.2*sqrtSize)) - cellSpacing;
// === First call === //
databind(classStore, size, sqrtSize); // ...then update the databind function
var t = d3.timer(function(elapsed) {
draw();
if (elapsed > 300) t.stop();
}); // start a timer that runs the draw function for 500 ms (this needs to be higher than the transition in the databind function)
// === Bind and draw functions === //
function databind(data, size, sqrtSize) {
colourScale = d3.scaleSequential(d3.interpolateReds).domain(d3.extent(data, function(d) { return d.value; }));
var join = custom.selectAll('custom.rect')
.data(data);
var enterSel = join.enter()
.append('custom')
.attr('class', 'rect')
.attr('x', function(d, i) {
var x0 = Math.floor(i / 169) % 13, x1 = Math.floor(i % 13);
return groupSpacing * x0 + (cellSpacing + cellSize) * (x1 + x0 * 10);
})
.attr('y', function(d, i) {
var y0 = Math.floor(i / 1000), y1 = Math.floor(i % 169 / 13);
return groupSpacing * y0 + (cellSpacing + cellSize) * (y1 + y0 * 10);
})
.attr('width', 0)
.attr('height', 0);
join
.merge(enterSel)
.transition()
.attr('width', cellSize)
.attr('height', cellSize)
.attr('fillStyle', function(d) { return colourScale(d.value); })
var exitSel = join.exit()
.transition()
.attr('width', 0)
.attr('height', 0)
.remove();
} // databind()
// === Draw canvas === //
function draw() {
// clear canvas
context.fillStyle = '#fff';
context.fillRect(0, 0, width, height);
// draw each individual custom element with their properties
var elements = custom.selectAll('custom.rect') // this is the same as the join variable, but used here to draw
elements.each(function(d,i) {
// for each virtual/custom element...
var node = d3.select(this);
context.fillStyle = node.attr('fillStyle');
context.fillRect(node.attr('x'), node.attr('y'), node.attr('width'), node.attr('height'))
});
} // draw()
},
},
mounted () {
EventBus.$on('emittedEventCallingGrid', data => { this.GetResultsAll = data; })
EventBus.$on('emittedEventCallingGrid', this.Grid)
EventBus.$on('emittedEventCallingGridSelection', data => { this.GetResultsSelection = data; })
EventBus.$on('emittedEventCallingGridSelection', this.GridSelection)
EventBus.$on('Responsive', data => {
this.responsiveWidthHeight = data})
EventBus.$on('ResponsiveandChange', data => {
this.responsiveWidthHeight = data})
// reset the views
EventBus.$on('resetViews', this.reset)
}
}
</script>
<style type="text/css">
canvas {
border: 1px dotted #ccc;
}
</style>

@ -7,7 +7,7 @@ import * as Plotly from 'plotly.js'
import { EventBus } from '../main.js'
export default {
name: 'FinalResultsLinePlot',
name: 'VotingResults',
data () {
return {
FinalResultsforLinePlot: 0,

@ -615,12 +615,23 @@ def PreprocessingPred():
dfLR = pd.DataFrame.from_dict(dicLR)
df_concatProbs = pd.concat([dfKNN, dfLR])
predictionsKNN = []
for column, content in dfKNN.items():
el = [sum(x)/len(x) for x in zip(*content)]
predictionsKNN.append(el)
predictionsLR = []
for column, content in dfLR.items():
el = [sum(x)/len(x) for x in zip(*content)]
predictionsLR.append(el)
predictions = []
for column, content in df_concatProbs.items():
el = [sum(x)/len(x) for x in zip(*content)]
predictions.append(el)
return predictions
return [predictionsKNN, predictionsLR, predictions]
def PreprocessingParam():
dicKNN = allParametersPerformancePerModel[1]

Loading…
Cancel
Save