@ -479,7 +483,7 @@ function init(data, results_all, fields) {
d3.selectAll("#costHist > *").remove();
d3.select("#starPlot").selectAll('g').remove();
MainVisual();
StarplotInitialize();
//StarplotInitialize();
d3.select("#hider").style("z-index",2);
d3.select("#knnBarChart").style("z-index",1);
@ -524,7 +528,6 @@ function init(data, results_all, fields) {
opt.epsilon=document.getElementById("param-learningrate-value").value;// Epsilon is learning rate (10 = default)
opt.perplexity=document.getElementById("param-perplexity-value").value;// Roughly how many neighbors each point influences (30 = default)
// Put the input variables into more properly named variables and store them.
final_dataset=data;
dataFeatures=results_all;
@ -532,7 +535,7 @@ function init(data, results_all, fields) {
}else{
tsne=newtsnejs.tSNE(opt);// Set new t-SNE with specific perplexity.
dists=[];
dists=computeDistances(final_dataset,document.getElementById("param-distance").value,document.getElementById("param-transform").value);// Compute the distances in the high-dimensional space.
dists=computeDistances(data,document.getElementById("param-distance").value,document.getElementById("param-transform").value);// Compute the distances in the high-dimensional space.
InitialFormDists.push(dists);
tsne.initDataDist(dists);// Init t-SNE with dists.
for(vari=0;i<final_dataset.length;i++){final_dataset[i].beta=tsne.beta[i];beta_all[i]=tsne.beta[i];}// Calculate beta and bring it back from the t-SNE algorithm.
@ -744,7 +747,6 @@ function binTrans(data) {
// Compute the distances by applying the chosen distance functions and transformation functions.
@ -753,7 +755,7 @@ function computeDistances(data, distFunc, transFunc) {
// Function that updates embedding
functionupdateEmbedding(AnalysisResults){
inside=0;
points=[];
points2d=[];
@ -774,10 +776,49 @@ function updateEmbedding(AnalysisResults) {
x_position[i]=x(Y[i][0]);// x points position
y_position[i]=y(Y[i][1]);// y points position
points[i]={id:i,x:x_position[i],y:y_position[i],beta:final_dataset[i].beta,cost:final_dataset[i].cost,selected:true,schemaInv:false,DimON:null,starplot:false};// Create the points and points2D (2 dimensions)
points2d[i]={id:i,x:x_position[i],y:y_position[i],selected:true};// and add everything that we know about the points (e.g., selected = true, starplot = false in the beginning and so on)
points2d[i]={x:x_position[i],y:y_position[i]};// and add everything that we know about the points (e.g., selected = true, starplot = false in the beginning and so on)
@ -1469,13 +1519,13 @@ function click(){ // This is the click of the Schema Investigation scenario
d3.event.preventDefault();
flagForSchema=true;// Schema is activated.
CalculateCorrel();// Calculate the correlations
CalculateCorrel(flagForSchema);// Calculate the correlations
}
});
}
functionCalculateCorrel(){// Calculate the correlation is a function which has all the computations for the schema ordering (investigation).
functionCalculateCorrel(flagForSchema){// Calculate the correlation is a function which has all the computations for the schema ordering (investigation).
if(flagForSchema==false){
alert("Please, draw a schema first!");// If no Schema is drawn then ask the user!
@ -1655,6 +1705,7 @@ function CalculateCorrel(){ // Calculate the correlation is a function which has
functionBetatSNE(points){// Run the main visualization
inside=inside+1;
@ -2229,10 +2324,11 @@ if (points.length) { // If points exist (at least 1 point)
selectedPoints=[];
varfindNearestTable=[];
varhowManyPoints=0;
for(letm=0;m<points.length;m++){
if(points[m].selected==true){
selectedPoints.push(points[m]);// Add the selected points in to a new variable
howManyPoints=howManyPoints+1;
selectedPoints.push(points[m]);// Add the selected points in to a new variable
}
}
@ -2248,18 +2344,18 @@ if (points.length) { // If points exist (at least 1 point)
varvh=viewport[1]*0.042;
varmaxKNN=document.getElementById("param-perplexity-value").value;// Specify the amount of k neighborhoods that we are going to calculate. According to "perplexity."
//var maxKNN = 3;
selectedPoints.sort(function(a,b){// Sort the points according to ID.
returnparseFloat(a.id)-parseFloat(b.id);
});
for(k=maxKNN;k>0;k--){// Start from the maximum k value and go to the minimum (k=2).
findNearest=0;
varfindNearest=[];
varindexOrderSliced=[];
varindexOrderSliced2d=[];
varcount=[];
varsumIntersectionAvg=0;
varsumUnionAvg=0;
varfindNearestAVG=0;
varsumIntersection=[];
varsumUnion=[];
for(vari=0;i<selectedPoints.length;i++){
@ -2306,6 +2402,7 @@ if (points.length) { // If points exist (at least 1 point)
indexOrderSliced2d[i]=indexOrder2d[i].slice(0,k);
for(varm=0;m<indexOrderSliced2d[i].length;m++){
if(indexOrderSliced[i].includes(indexOrderSliced2d[i][m])){// Union
count[i]=count[i]+1;
}
}
@ -2315,21 +2412,16 @@ if (points.length) { // If points exist (at least 1 point)
findNearest=0;// If kNN is fully uncorrelated then we say that the value is 0.
}
findNearestTable.push(findNearest.toFixed(2));// These values are multiplied by the height of the viewport because we need to draw the bins of the barchart representation
findNearestAVG=0;// If kNN is fully uncorrelated then we say that the value is 0.
}
findNearestTable.push(findNearestAVG.toFixed(2));// These values are multiplied by the height of the viewport because we need to draw the bins of the barchart representation
}
findNearestTable.reverse();
@ -2346,6 +2438,7 @@ if (points.length) { // If points exist (at least 1 point)
if(inside==1){
StoreInitialFindNearestTable=findNearestTable;
}
vartrace1={
x:kValuesLegend,
y:StoreInitialFindNearestTable,
@ -2368,18 +2461,28 @@ if (points.length) { // If points exist (at least 1 point)
data=[trace1,trace2];
layout={
barmode:'group',autosize:false,
width:dimensions*0.99,
height:vh*2.1,
width:dimensions*0.97,
height:vh*1.38,
margin:{
l:30,
l:50,
r:30,
b:25,
t:20,
b:30,
t:5,
pad:4
},
xaxis:{range:[0,LimitXaxis]},
yaxis:{range:[0,1]}};
xaxis:{range:[0,LimitXaxis],
title:'K Values for K-NN',
titlefont:{
size:12,
color:'black'
}},
yaxis:{
title:'Clu. Purity',
titlefont:{
size:12,
color:'black'
}}};
$("#knnBarChartDetails").html("(Number of Selected Points: "+howManyPoints+"/"+dataFeatures.length+")");
@ -2394,7 +2497,7 @@ if (points.length) { // If points exist (at least 1 point)
}
if(selectedPoints.length<=10&&coun>0){// If points > 10 then do not draw! If points = 0 then do not draw!
varFeatureWise=[];
for(varj=0;j<Object.values(dataFeatures[0]).length;j++){// Get the features of the data set.
for(vari=0;i<dataFeatures.length;i++){
@ -2435,6 +2538,9 @@ if (points.length) { // If points exist (at least 1 point)
varindices=newArray(len);
for(vari=0;i<len;++i)indices[i]=i;
indices=indices.sort(function(a,b){returnPCASelVec[a]<PCASelVec[b]?-1:PCASelVec[a]>PCASelVec[b]?1:0;});// Get the most important features first! Clockwise ordering
if(len>10){
indices=indices.slice(0,9);
}
varwrapData=[];
varIDS=[];
@ -2443,10 +2549,10 @@ if (points.length) { // If points exist (at least 1 point)
data.push({axis:ArrayContainsDataFeaturesClearedwithoutNullKeys[selectedPoints[i].id][m],value:Math.abs((ArrayContainsDataFeaturesClearedwithoutNull[selectedPoints[i].id][m]-min[m])/(max[m]-min[m]))});// Push the values into the starplot
Object.assign(data,{[ArrayContainsDataFeaturesClearedwithoutNullKeys[selectedPoints[i].id][m]]:parseFloat(ArrayContainsDataFeaturesClearedwithoutNull[selectedPoints[i].id][m]).toFixed(1)});// Push the values into the starplot
}
}
}
}
wrapData.push(data);// Wrap everything together
IDS.push(selectedPoints[i].id);// Push all the IDs of the selected points
}
@ -2459,6 +2565,24 @@ if (points.length) { // If points exist (at least 1 point)
.domain(IDS)
.range(colors);
varcolor=function(d){returncolors(d.group);};
varparcoords=d3v3.parcoords()("#starPlot")
.data(wrapData)
.alpha(0.75)
.composite("darken")
.margin({top:20,left:0,bottom:5,right:0})
.mode("queue")
.color(function(d,i){returncolorScl(IDS[i]);})
.render()
.brushMode("1D-axes")// enable brushing
.reorderable();
parcoords.svg.selectAll("text")
.style("font","14px");
/*
varradarChartOptions={// Starplot options
w:width,
h:height,
@ -2468,7 +2592,7 @@ if (points.length) { // If points exist (at least 1 point)
};
//Call function to draw the Radar chart (starplot)