diff --git a/__pycache__/run.cpython-38.pyc b/__pycache__/run.cpython-38.pyc index cb5f182..668336b 100644 Binary files a/__pycache__/run.cpython-38.pyc and b/__pycache__/run.cpython-38.pyc differ diff --git a/frontend/src/components/FeatureSpaceDetail.vue b/frontend/src/components/FeatureSpaceDetail.vue index 5d9b4d7..e89c595 100644 --- a/frontend/src/components/FeatureSpaceDetail.vue +++ b/frontend/src/components/FeatureSpaceDetail.vue @@ -9,17 +9,17 @@
- - + +
-
+
-
+

Fs COR (>)

@@ -95,6 +95,7 @@ export default { this.KeepIDs = [] this.keepNumberOfCompareNodes = 0 this.graphVizualization() + EventBus.$emit('storeGeneration') }, setLayerCompare() { this.mode = 1 @@ -491,8 +492,9 @@ export default { var svg = d3.select('#chartID') svg.selectAll("*").remove() - var width = 819; - var height = 819; + var marginNodes = {top: 0, right: 0, bottom: 0, left: 0}; + var width = 819 - marginNodes.right - marginNodes.left; + var height = 819 - marginNodes.top - marginNodes.bottom; var numTicks = 200; @@ -503,7 +505,8 @@ export default { svg = d3.select("#FeatureGraph").append("svg") .attr("width", width) - .attr("height", height); + .attr("height", height) + .attr('transform', `translate(${marginNodes.left}, ${marginNodes.top})`); var graph = this.jsonData @@ -635,6 +638,11 @@ export default { EventBus.$emit('UpdateIDs', IDsGather) if (selectionCounter == 1) { EventBus.$emit('Default') + } else if (selectionCounter == 2) { + EventBus.$emit('UpdateIDs', IDsGather) + EventBus.$emit('CompareTwo', IDsGather) + } else { + } } } @@ -647,7 +655,7 @@ export default { items.forEach( function (it) { it.childNodes[0].style.visibility = "hidden"; it.childNodes[1].setAttribute("transform", "translate(50,50) scale(0.28) rotate(180)"); - it.childNodes[1].childNodes[0].style.fill = "white"; + it.childNodes[1].childNodes[0].style.fill = "#D3D3D3"; it.childNodes[2].style.visibility = "hidden"; }) } @@ -679,9 +687,9 @@ export default { node.append('title').text(function (d) { return d.name; }); EventBus.$emit('brushLink', -1) }); - var chartWidth = 350; + var chartWidth = 310; var chartHeight = 65; - var margin = {left: 25, right: 25, top: 10, bottom: 40}; + var margin = {left: 8, right: 15, top: 10, bottom: 40}; var chartSvg = d3.select('svg.chart') .attr('width', chartWidth) .attr('height', chartHeight) @@ -704,7 +712,7 @@ export default { .attr("y", chartHeight + 10) .attr("dy", "0.71em") .attr("text-anchor", "middle") - .text("Graph readability (%)"); + .text("Weighted graph readability (%)"); var readabilityCircles = chartSvg.append('g').selectAll('circle'); // 48 parameters @@ -1021,6 +1029,7 @@ export default { zoom_handler(svg); + for (let i = 0; i < listofNodes.length; i++) { var numb = graph.nodes[i]['group'].match(/\d/g) numb = parseInt(numb.join("")) @@ -1190,7 +1199,7 @@ export default { var textLine = d3.select('#legendText').append("svg").attr('width', 170).attr('height', 90) - var marginBorder = 18 + var marginBorder = 16 var marginBorderX = 10 textLine.append('line') .style("stroke", "black") @@ -1208,7 +1217,7 @@ export default { textLine.append('line') .style("stroke", "black") .style("stroke-width", 3) - .attr("x1", 42 + marginBorderX) + .attr("x1", 44 + marginBorderX) .attr("y1", 31 - marginBorder) .attr("x2", 53 + marginBorderX) .attr("y2", 31 - marginBorder) @@ -1281,8 +1290,8 @@ export default { yDistance = yDistance[1] - yDistance[0]; graph.nodes.forEach(function (n, i) { - n.x = (height - 10) * (n.x - xMin) / Math.max(xDistance, yDistance); - n.y = (height - 10) * (n.y - yMin) / Math.max(xDistance, yDistance); + n.x = (height - 105) * (n.x - xMin) / Math.max(xDistance, yDistance); // Margin for Nodes + n.y = (height - 105) * (n.y - yMin) / Math.max(xDistance, yDistance); // Margin for Nodes }); xDistance = d3.extent(graph.nodes, function (n) { return n.x; }); @@ -1449,7 +1458,7 @@ table td { #chartID { position: absolute; - transform: translate(-390px, 840px); + transform: translate(-354px, 840px); } .chart circle { diff --git a/frontend/src/components/FeatureSpaceOverview.vue b/frontend/src/components/FeatureSpaceOverview.vue index 9875280..258976f 100644 --- a/frontend/src/components/FeatureSpaceOverview.vue +++ b/frontend/src/components/FeatureSpaceOverview.vue @@ -44,7 +44,7 @@
Labels
-
+
@@ -367,7 +367,7 @@ export default { if(d.name == 'Data') { return d.selected ? 0 : 0; } else if (d.name == 'All' || d.name == 'Best' || d.name == 'Good' || d.name == 'Bad' || d.name == 'Worst'){ - return d.selected ? 2 : 2; + return d.selected ? 3 : 3; } else { return d.selected ? 0 : 0; } diff --git a/frontend/src/components/Heatmap.vue b/frontend/src/components/Heatmap.vue index 115af56..351deac 100644 --- a/frontend/src/components/Heatmap.vue +++ b/frontend/src/components/Heatmap.vue @@ -40,6 +40,7 @@ export default { dataFI: [], featureData: [], generKey: [], + featureGenGlobal: [] } }, methods: { @@ -82,17 +83,16 @@ export default { var FeaturesAccuracy = JSON.parse(this.dataFI[2]) if (Object.entries(this.generKey).length == 0) { - var Features = this.featureData[0] + var Features = JSON.parse(this.featureData[0]) } else { - console.log(this.generKey) var Features = this.generKey } - + console.log(Features) let arr = Object.values(featureUni.Score); let minUni = Math.min(...arr); let maxUni = Math.max(...arr); - let len = Features.length + var len = Features.length let indicesYAxis = [] for (let i = 0; i < len; i++) { indicesYAxis[i] = [Features[i]] @@ -120,16 +120,25 @@ export default { } else if (algorithms[j] == "Accuracy-based FI") { values[j] = FeaturesAccuracy[i][0] } else if (algorithms[j] == "Average") { - values[j] = ((((Object.values(featureUni.Score)[i]-minUni)/(maxUni-minUni)))+(PermImpEli[i][0])+(FeaturesAccuracy[i][0]))/(len-2) + values[j] = ((((Object.values(featureUni.Score)[i]-minUni)/(maxUni-minUni)))+(PermImpEli[i][0])+(FeaturesAccuracy[i][0]))/(len2-2) } else { if (Object.entries(this.generKey).length == 0) { values[j] = -2 } else { - if (i == 0 || i == 1) { - values[j] = -3 + if (Object.entries(this.generKey).length == 7) { + if (i == 0 || i == 1) { + values[j] = -3 + } + else { + values[j] = -4 + } + } else { + if (i == 0 || i == 1 || i == 2) { + values[j] = -3 + } + else { + values[j] = -4 } - else { - values[j] = -4 } } } @@ -145,8 +154,17 @@ export default { }, heatmap_display(data, heatmapId) { + if (Object.entries(this.generKey).length == 0) { + var Features = JSON.parse(this.featureData[0]) + } else { + var Features = this.generKey + } + + var len = Features.length + + var featuresAddRem = [] - var featuresGen = [] + var featuresGen = this.featureGenGlobal var cellSize = this.cellSize //########################################################################## // Patrick.Brockmann@lsce.ipsl.fr @@ -237,7 +255,7 @@ export default { }) .attr("x", 0) .attr("y", function(d, i) { - return (i * cellSize); + return (i * cellSize); }) .style("text-anchor", "end") .attr("transform", function(d, i) { @@ -306,7 +324,7 @@ export default { }) .attr("class", "row"); svg.append("text").attr("x", 10).attr("y", -65).text("Technique").style("font-size", "16px").attr("alignment-baseline","top") - svg.append("text").attr("transform", "rotate(-90)").attr("x", -33).attr("y", -75).style("text-anchor", "middle").style("font-size", "16px").text("Feature"); // -130 before for HeartC + svg.append("text").attr("transform", "rotate(-90)").attr("x", (-1)*(cellSize*(len/2))).attr("y", -75).style("text-anchor", "middle").style("font-size", "16px").text("Feature"); // -130 before for HeartC var heatMap = row.selectAll(".cell") .data(function(d) { return d; @@ -381,9 +399,19 @@ export default { return colorScale(d) } } else { - featuresAddRem.push(k) - EventBus.$emit('removeFeatures', featuresAddRem) - return "url(#diagonalHatch)" + if (d == -4) { + const index = featuresGen.indexOf(k); + console.log(index) + if (index > -1) { + featuresGen.splice(index, 1); + } + EventBus.$emit('removeFeaturesGen', featuresGen) + return "url(#diagonalHatch)" + } else { + featuresAddRem.push(k) + EventBus.$emit('removeFeatures', featuresAddRem) + return "url(#diagonalHatch)" + } } } else { if (d == -3) { @@ -587,6 +615,10 @@ export default { } }, mounted () { + + EventBus.$on('removeFeaturesGen', data => { this.featureGenGlobal = data }) + EventBus.$on('addFeatureGen', data => { this.featureGenGlobal = data }) + EventBus.$on('Generation', data => { this.generKey = data }) EventBus.$on('HeatmapCall', data => { this.dataFI = data }) diff --git a/frontend/src/components/Main.vue b/frontend/src/components/Main.vue index 4abbfda..3c1cd00 100755 --- a/frontend/src/components/Main.vue +++ b/frontend/src/components/Main.vue @@ -459,6 +459,7 @@ export default Vue.extend({ .then(response => { console.log('Server successfully send the importances!') this.Importance = response.data.Importance + console.log(this.Importance) this.featureNames = [] EventBus.$emit('Generation', this.featureNames) EventBus.$emit('HeatmapCall', this.Importance) @@ -533,6 +534,28 @@ export default Vue.extend({ console.log(error) }) }, + storeGenFun () { + const path = `http://127.0.0.1:5000/data/storeGeneratedFeatures` + const postData = { + } + 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('Store newly generated features!') + EventBus.$emit('updateFeatureImp') + EventBus.$emit('Default') + }) + .catch(error => { + console.log(error) + }) + }, Compare () { const path = `http://127.0.0.1:5000/data/compareFun` const postData = { @@ -581,6 +604,7 @@ export default Vue.extend({ }, }, created () { + // does the browser support the Navigation Timing API? if (window.performance) { console.info("window.performance is supported"); @@ -594,6 +618,8 @@ export default Vue.extend({ }, mounted() { + EventBus.$on('storeGeneration', this.storeGenFun) + var modal = document.getElementById('myModal') window.onclick = function(event) { //alert(event.target) @@ -619,6 +645,7 @@ export default Vue.extend({ EventBus.$on('CompareThree', this.Compare) EventBus.$on('Default', this.returnImportance) + EventBus.$on('updateFeatureImp', this.returnCorrel) EventBus.$on('ReturningBrushedPointsIDs', data => { this.modelsUpdate = data }) //EventBus.$on('ReturningBrushedPointsIDs', this.UpdateBarChartFeatures ) @@ -674,6 +701,8 @@ export default Vue.extend({ EventBus.$on('addFeature', this.ManipulFeature) EventBus.$on('removeFeatures', this.ManipulFeature) + EventBus.$on('removeFeaturesGen', data => { this.featureAddRemGen = data }) + EventBus.$on('removeFeaturesGen', this.ManipulFeatureGen) EventBus.$on('addFeatureGen', data => { this.featureAddRemGen = data }) EventBus.$on('addFeatureGen', this.ManipulFeatureGen) diff --git a/frontend/src/components/Results.vue b/frontend/src/components/Results.vue index 2839830..951c5cb 100644 --- a/frontend/src/components/Results.vue +++ b/frontend/src/components/Results.vue @@ -47,7 +47,7 @@ export default { .attr('width', width + margin.left + margin.right) .attr('height', height + margin.top + margin.bottom) .append('g') - .attr('transform', 'translate(' + -5 + ',' + 0 + ')') + .attr('transform', 'translate(' + 0 + ',' + 0 + ')') var border = chart.append('rect') .attr('x', yLabelWidth) @@ -62,7 +62,7 @@ export default { var data = [] var features = this.featuresReceived[33] - var labelsX = ['Add', 'Remove', 'Combine', 'Round'] + var labelsX = ['Add', 'Remove', 'Transform', 'Generate'] for (let i=0; i< features.length; i++) { data.push({ label: features[i], diff --git a/run.py b/run.py index 6703740..31eaaf0 100644 --- a/run.py +++ b/run.py @@ -119,6 +119,10 @@ def reset(): global columnsKeep columnsKeep = [] + + global columnsNewGen + columnsNewGen = [] + return 'The reset was done!' # retrieve data from client and select the correct data set @@ -219,6 +223,9 @@ def retrieveFileName(): global columnsKeep columnsKeep = [] + global columnsNewGen + columnsNewGen = [] + DataRawLength = -1 DataRawLengthTest = -1 data = json.loads(fileName) @@ -399,6 +406,7 @@ def dataSetSelection(): global keepOriginalFeatures keepOriginalFeatures = XData.copy() keepOriginalFeatures.columns = [str(col) + ' (F'+str(idx+1)+')' for idx, col in enumerate(keepOriginalFeatures.columns)] + columnsNewGen = keepOriginalFeatures.columns.values.tolist() XData.columns = ['F'+str(idx+1) for idx, col in enumerate(XData.columns)] @@ -433,9 +441,18 @@ def executeModel(exeCall, flagEx): global XData global XDataStored global previousState + global columnsNewGen scores = [] - XData = XDataStored.copy() + if (len(exeCall) == 0): + if (flagEx == 3): + XDataStored = XData.copy() + else: + XData = XDataStored.copy() + else: + XData = XDataStored.copy() + columnsNewGen = keepOriginalFeatures.columns.values.tolist() + # Bayesian Optimization for 150 iterations if (keyFirstTime): create_global_function() @@ -444,20 +461,23 @@ def executeModel(exeCall, flagEx): svc_bayesopt.maximize(init_points=130, n_iter=20, acq='ucb') bestParams = svc_bayesopt.max['params'] estimator = SVC(C=bestParams.get('C'), gamma=bestParams.get('gamma'), probability=True, random_state=RANDOM_SEED) - featureImportanceData = estimatorFeatureSelection(XData, estimator) if (len(exeCall) != 0): if (flagEx == 1): XData = XData.drop(XData.columns[exeCall], axis=1) - else: + elif (flagEx == 2): columnsKeepNew = [] columns = XDataGen.columns.values.tolist() for indx, col in enumerate(columns): if indx in exeCall: columnsKeepNew.append(col) + columnsNewGen.append(col) + XDataTemp = XDataGen[columnsKeepNew] XData[columnsKeepNew] = XDataTemp.values + print(XDataStored) print(XData) + featureImportanceData = estimatorFeatureSelection(XData, estimator) estimator.fit(XData, yData) yPredict = estimator.predict(XData) yPredictProb = cross_val_predict(estimator, XData, yData, cv=crossValidation, method='predict_proba') @@ -1104,7 +1124,7 @@ def Seperation(): global packCorr packCorr = [] - packCorr.append(list(keepOriginalFeatures.columns.values.tolist())) + packCorr.append(json.dumps(columnsNewGen)) packCorr.append(json.dumps(target_names)) packCorr.append(json.dumps(probabilityPredictions)) @@ -1226,7 +1246,7 @@ def CompareFunPy(): feat2 = XDataGen.iloc[:,1] XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]] = feat1 + feat2 XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|'] = abs(feat1 - feat2) - XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]] = feat1 + feat2 + XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]] = feat1 * feat2 XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat1 / feat2 XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat2 / feat1 columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]) @@ -1235,8 +1255,66 @@ def CompareFunPy(): columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) elif (compareMode == 2): - pass + XDataGen = XData[columnsKeepNonOrig] + feat1 = XDataGen.iloc[:,0] + feat2 = XDataGen.iloc[:,1] + feat3 = XDataGen.iloc[:,2] + XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]] = feat1 + feat2 + XDataGen['F'+columnsKeepID[1]+'+F'+columnsKeepID[2]] = feat2 + feat3 + XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[2]] = feat1 + feat3 + XDataGen['F'+columnsKeepID[0]+'+F'+columnsKeepID[1]+'+F'+columnsKeepID[2]] = feat1 + feat2 + feat3 + XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|'] = abs(feat1 - feat2) + XDataGen['|F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|'] = abs(feat2 - feat3) + XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[2]+'|'] = abs(feat1 - feat3) + XDataGen['|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|'] = abs(feat1 - feat2 - feat3) + XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]] = feat1 * feat2 + XDataGen['F'+columnsKeepID[1]+'xF'+columnsKeepID[2]] = feat2 * feat3 + XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[2]] = feat1 * feat3 + XDataGen['F'+columnsKeepID[0]+'xF'+columnsKeepID[1]+'xF'+columnsKeepID[2]] = feat1 * feat2 * feat3 + XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat1 / feat2 + XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat2 / feat1 + XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[2]] = feat2 / feat3 + XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[1]] = feat3 / feat2 + XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[2]] = feat1 / feat3 + XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[0]] = feat3 / feat1 + XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[2]] = feat1 / feat2 / feat3 + XDataGen['F'+columnsKeepID[0]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[1]] = feat1 / feat3 / feat2 + XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[0]] = feat2 / feat3 / feat1 + XDataGen['F'+columnsKeepID[1]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[2]] = feat2 / feat1 / feat3 + XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[1]] = feat3 / feat1 / feat2 + XDataGen['F'+columnsKeepID[2]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[0]] = feat3 / feat2 / feat1 + + columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]) + columnsKeep.append('F'+columnsKeepID[1]+'+F'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[0]+'+F'+columnsKeepID[1]+'+F'+columnsKeepID[2]) + columnsKeep.append('|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'|') + columnsKeep.append('|F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|') + columnsKeep.append('|F'+columnsKeepID[0]+'-F'+columnsKeepID[2]+'|') + columnsKeep.append('|F'+columnsKeepID[0]+'-F'+columnsKeepID[1]+'-F'+columnsKeepID[2]+'|') + columnsKeep.append('F'+columnsKeepID[0]+'xF'+columnsKeepID[1]) + columnsKeep.append('F'+columnsKeepID[1]+'xF'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[0]+'xF'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[0]+'xF'+columnsKeepID[1]+'xF'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) + columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) + columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[1]) + columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[0]) + columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[0]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[1]) + columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[2]+'/F'+columnsKeepID[0]) + columnsKeep.append('F'+columnsKeepID[1]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[2]) + columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[0]+'/F'+columnsKeepID[1]) + columnsKeep.append('F'+columnsKeepID[2]+'/F'+columnsKeepID[1]+'/F'+columnsKeepID[0]) else: pass featureCompareData = estimatorFeatureSelection(XDataGen, estimator) + return 'Okay' + +@cross_origin(origin='localhost',headers=['Content-Type','Authorization']) +@app.route('/data/storeGeneratedFeatures', methods=["GET", "POST"]) +def storeGeneratedFeat(): + executeModel([], 3) return 'Okay' \ No newline at end of file