StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
StackGenVis/frontend/src/components/PredictionsSpace.vue

368 lines
12 KiB

6 years ago
<template>
5 years ago
<div>
<b-row class="md-3">
<b-col cols="12">
5 years ago
<div>Projection Method: <select id="selectBarChartPred" @change="selectVisualRepresentationPred()">
<option value="mds" selected>MDS</option>
<option value="tsne">t-SNE</option>
<option value="umap">UMAP</option>
5 years ago
</select>
<div id="OverviewPredPlotly" class="OverviewPredPlotly"></div>
</div>
</b-col>
</b-row>
</div>
6 years ago
</template>
<script>
import * as Plotly from 'plotly.js'
import { EventBus } from '../main.js'
export default {
name: 'PredictionsSpace',
data () {
return {
PredictionsData: '',
UpdatedData: '',
representationDef: 'mds',
representationSelection: 'mds',
5 years ago
RetrieveDataSet: 'HeartC',
5 years ago
colorsValues: ['#808000','#008080','#bebada','#fccde5','#d9d9d9','#bc80bd','#ccebc5'],
WH: [],
onlyOnce: true,
6 years ago
}
},
methods: {
selectVisualRepresentationPred () {
const representationSelectionDocum = document.getElementById('selectBarChartPred')
this.representationSelection = representationSelectionDocum.options[representationSelectionDocum.selectedIndex].value
EventBus.$emit('RepresentationSelectionPred', this.representationSelection)
},
5 years ago
reset () {
Plotly.purge('OverviewPredPlotly')
},
5 years ago
clean(obj) {
var propNames = Object.getOwnPropertyNames(obj);
for (var i = 0; i < propNames.length; i++) {
var propName = propNames[i];
if (obj[propName] === null || obj[propName] === undefined) {
delete obj[propName];
}
}
},
ScatterPlotPredView () {
5 years ago
Plotly.purge('OverviewPredPlotly')
5 years ago
5 years ago
// responsive visualization
5 years ago
var width = this.WH[0]*6.5 // interactive visualization
var height = this.WH[1]*1.22 // interactive visualization
5 years ago
var XandYCoordinatesMDS
5 years ago
var target_names = JSON.parse(this.PredictionsData[4])
5 years ago
if (this.UpdatedData.length != 0) {
XandYCoordinatesMDS = JSON.parse(this.UpdatedData[0])
} else {
XandYCoordinatesMDS = JSON.parse(this.PredictionsData[8])
}
5 years ago
const DataSet = JSON.parse(this.PredictionsData[14])
const originalDataLabels = JSON.parse(this.PredictionsData[15])
//const originalDataLabels = JSON.parse(this.PredictionsData[16])
5 years ago
var DataSetParse = JSON.parse(DataSet)
5 years ago
var stringParameters = []
for (let i = 0; i < DataSetParse.length; i++) {
this.clean(DataSetParse[i])
5 years ago
5 years ago
stringParameters.push(JSON.stringify(DataSetParse[i]).replace(/,/gi, '<br>'))
}
const XandYCoordinatesTSNE = JSON.parse(this.PredictionsData[18])
const XandYCoordinatesUMAP= JSON.parse(this.PredictionsData[19])
var result = [];
var IDs = [];
var Xaxs = [];
var Yaxs = [];
5 years ago
var beautifyLabels = []
if (this.RetrieveDataSet == 'StanceC') {
beautifyLabels.push('Absence of Hypotheticality')
beautifyLabels.push('Presence of Hypotheticality')
}
else if (this.RetrieveDataSet == 'HeartC') {
beautifyLabels.push('< 50% Diameter Narrowing / Healthy')
beautifyLabels.push('> 50% Diameter Narrowing / Diseased')
5 years ago
} else {
target_names.forEach(element => {
beautifyLabels.push(element)
});
}
if (this.representationDef == 'mds') {
for (let i = 0; i < XandYCoordinatesMDS[0].length; i++) {
Xaxs.push(XandYCoordinatesMDS[0][i])
Yaxs.push(XandYCoordinatesMDS[1][i])
IDs.push(i)
}
result.Xax = Xaxs
result.Yax = Yaxs
result.ID = IDs
var traces = []
var layout = []
for (let i = 0; i < target_names.length; i++) {
const aux_X = result.Xax.filter((item, index) => originalDataLabels[index] == target_names[i]);
const aux_Y = result.Yax.filter((item, index) => originalDataLabels[index] == target_names[i]);
const aux_ID = result.ID.filter((item, index) => originalDataLabels[index] == target_names[i]);
var Text = aux_ID.map((item, index) => {
5 years ago
let popup = 'Data Point ID: ' + item + '<br> Details: ' + stringParameters[item]
return popup;
});
5 years ago
traces.push({
x: aux_X,
y: aux_Y,
mode: 'markers',
5 years ago
name: beautifyLabels[i],
5 years ago
marker: { color: this.colorsValues[i], line: { color: 'rgb(0, 0, 0)', width: 3 }, opacity: 1, size: 12 },
hovertemplate:
"<b>%{text}</b><br><br>" +
"<extra></extra>",
text: Text,
})
}
5 years ago
layout = {font: { family: 'Helvetica', size: 14, color: '#000000' },
5 years ago
xaxis: {
visible: false
},
yaxis: {
visible: false
},
dragmode: 'lasso',
hovermode: "closest",
autosize: true,
width: width,
height: height,
5 years ago
legend: {orientation: 'h', xanchor: 'center', x: 0.5},
5 years ago
margin: {
l: 50,
r: 0,
b: 30,
t: 40,
pad: 0
},
}
} else if (this.representationDef == 'tsne') {
result = XandYCoordinatesTSNE.reduce(function(r, a) {
var id = 0
5 years ago
a.forEach(function(s, i) {
var key = i === 0 ? 'Xax' : 'Yax'
5 years ago
r[key] || (r[key] = []) // if key not found on result object, add the key with empty array as the value
r[key].push(s)
5 years ago
})
return r
}, {})
5 years ago
for (let i = 0; i < result.Xax.length; i++) {
IDs.push(i)
}
result.ID = IDs
5 years ago
var traces = []
5 years ago
for (let i = 0; i < target_names.length; i++) {
5 years ago
const aux_X = result.Xax.filter((item, index) => originalDataLabels[index] == target_names[i]);
const aux_Y = result.Yax.filter((item, index) => originalDataLabels[index] == target_names[i]);
const aux_ID = result.ID.filter((item, index) => originalDataLabels[index] == target_names[i]);
5 years ago
var Text = aux_ID.map((item, index) => {
5 years ago
let popup = 'Data Point ID: ' + item + '<br> Details: ' + stringParameters[item]
return popup;
});
5 years ago
traces.push({
5 years ago
x: aux_X,
y: aux_Y,
mode: 'markers',
5 years ago
name: beautifyLabels[i],
5 years ago
marker: { color: this.colorsValues[i], line: { color: 'rgb(0, 0, 0)', width: 3 }, opacity: 1, size: 12 },
hovertemplate:
"<b>%{text}</b><br><br>" +
"<extra></extra>",
5 years ago
text: Text,
})
}
5 years ago
layout = {font: { family: 'Helvetica', size: 14, color: '#000000' },
5 years ago
xaxis: {
visible: false
},
yaxis: {
visible: false
},
dragmode: 'lasso',
hovermode: "closest",
autosize: true,
width: width,
height: height,
5 years ago
legend: {orientation: 'h', xanchor: 'center', x: 0.5},
5 years ago
margin: {
l: 50,
r: 0,
b: 30,
t: 40,
pad: 0
},
}
} else {
for (let i = 0; i < XandYCoordinatesUMAP[0].length; i++) {
Xaxs.push(XandYCoordinatesUMAP[0][i])
Yaxs.push(XandYCoordinatesUMAP[1][i])
IDs.push(i)
}
result.Xax = Xaxs
result.Yax = Yaxs
result.ID = IDs
var traces = []
for (let i = 0; i < target_names.length; i++) {
const aux_X = result.Xax.filter((item, index) => originalDataLabels[index] == target_names[i]);
const aux_Y = result.Yax.filter((item, index) => originalDataLabels[index] == target_names[i]);
const aux_ID = result.ID.filter((item, index) => originalDataLabels[index] == target_names[i]);
var Text = aux_ID.map((item, index) => {
5 years ago
let popup = 'Data Point ID: ' + item + '<br> Details: ' + stringParameters[item]
return popup;
});
traces.push({
x: aux_X,
y: aux_Y,
mode: 'markers',
5 years ago
name: beautifyLabels[i],
5 years ago
marker: { color: this.colorsValues[i], line: { color: 'rgb(0, 0, 0)', width: 3 }, opacity: 1, size: 12 },
hovertemplate:
"<b>%{text}</b><br><br>" +
"<extra></extra>",
text: Text,
})
}
5 years ago
layout = {font: { family: 'Helvetica', size: 14, color: '#000000' },
5 years ago
xaxis: {
visible: false
},
yaxis: {
visible: false
},
5 years ago
legend: {orientation: 'h', xanchor: 'center', x: 0.5},
dragmode: 'lasso',
hovermode: "closest",
autosize: true,
width: width,
height: height,
5 years ago
margin: {
l: 50,
r: 0,
b: 30,
t: 40,
pad: 0
},
}
5 years ago
}
5 years ago
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', traces, layout, config)
5 years ago
//if (this.onlyOnce) {
this.selectedPointsOverview()
// }
// this.onlyOnce = false
},
5 years ago
// UpdateScatterPlot () {
// const XandYCoordinates = JSON.parse(this.UpdatedData[0])
// const aux_X = result.Xax.filter((item, index) => originalDataLabels[index] == target_names[i]);
// const aux_Y = result.Yax.filter((item, index) => originalDataLabels[index] == target_names[i]);
// const aux_ID = result.ID.filter((item, index) => originalDataLabels[index] == target_names[i]);
// var Text = aux_ID.map((item, index) => {
// let popup = 'Data Point ID: ' + item + '<br> Details: ' + stringParameters[item]
// return popup;
// });
// Plotly.animate('OverviewPredPlotly', {
// data: [
// {x: XandYCoordinates[0], y: XandYCoordinates[1]}
// ],
// traces: [0],
// layout: {}
// }, {
// transition: {
// duration: 1000,
// easing: 'cubic-in-out'
// },
// frame: {
// duration: 1000
// }
// })
// //this.selectedPointsOverview()
// },
selectedPointsOverview () {
const OverviewPlotly = document.getElementById('OverviewPredPlotly')
OverviewPlotly.on('plotly_selected', function (evt) {
if (typeof evt !== 'undefined') {
const DataPoints = []
5 years ago
console.log(evt)
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])
}
}
5 years ago
console.log(DataPoints)
if (DataPoints != '') {
EventBus.$emit('SendSelectedDataPointsToServerEvent', DataPoints)
} else {
EventBus.$emit('SendSelectedDataPointsToServerEvent', '')
}
}
})
},
6 years ago
},
mounted() {
EventBus.$on('onlyOnce', data => { this.onlyOnce = data })
EventBus.$on('updatePredictionsSpace', data => { this.UpdatedData = data })
5 years ago
EventBus.$on('updatePredictionsSpace', this.ScatterPlotPredView)
6 years ago
EventBus.$on('emittedEventCallingPredictionsSpacePlotView', data => {
this.PredictionsData = data})
EventBus.$on('emittedEventCallingPredictionsSpacePlotView', this.ScatterPlotPredView)
EventBus.$on('Responsive', data => {
this.WH = data})
EventBus.$on('ResponsiveandChange', data => {
this.WH = data})
5 years ago
EventBus.$on('RepresentationSelectionPred', data => {this.representationDef = data})
EventBus.$on('RepresentationSelectionPred', this.ScatterPlotPredView)
5 years ago
// reset the views
EventBus.$on('resetViews', this.reset)
5 years ago
EventBus.$on('SendToServerDataSetConfirmation', data => { this.RetrieveDataSet = data })
6 years ago
}
}
</script>