new transformation

master
parent c15b556c82
commit b38659682a
  1. BIN
      __pycache__/run.cpython-37.pyc
  2. 103
      frontend/src/components/FeatureSpace1.vue
  3. 2
      frontend/src/components/FeatureSpace2.vue
  4. 2
      frontend/src/components/FeatureSpace3.vue
  5. 2
      frontend/src/components/FeatureSpace4.vue
  6. 5
      frontend/src/components/Main.vue
  7. 49
      run.py

Binary file not shown.

@ -17,6 +17,7 @@ export default {
data () {
return {
dataFS1: [],
dataFS1Trans: [],
jsonData: [],
}
},
@ -25,9 +26,102 @@ export default {
var listofNodes = this.dataFS1[0]
var dataLoc = JSON.parse(this.dataFS1[2])
var pushEachFinal = []
var pushEach
var oldVal
var newVal
var outcome
var countLoc
this.dataFS1Trans.forEach(function(element, index) {
var round = element.round
round = JSON.parse(round[0])
oldVal = 0
newVal = 0
outcome = 0
countLoc = 0
pushEach = []
Object.entries(round).forEach(
function ([feature, value]) {
var key = Object.keys(value)
var search = Object.values(dataLoc[key])
oldVal = Math.abs(search[countLoc]) + oldVal
newVal = Math.abs(Object.values(value)[0]) + newVal
countLoc++
})
oldVal = oldVal / listofNodes.length
newVal = newVal / listofNodes.length
outcome = oldVal - newVal
pushEach.push({keyIns: "round", valueIns: outcome})
var roundLogE = element.roundLogE
roundLogE = JSON.parse(roundLogE[0])
oldVal = 0
newVal = 0
outcome = 0
countLoc = 0
Object.entries(roundLogE).forEach(
function ([feature, value]) {
var key = Object.keys(value)
var search = Object.values(dataLoc[key])
oldVal = Math.abs(search[countLoc]) + oldVal
newVal = Math.abs(Object.values(value)[0]) + newVal
countLoc++
})
oldVal = oldVal / listofNodes.length
newVal = newVal / listofNodes.length
outcome = oldVal - newVal
pushEach.push({keyIns: "roundLogE", valueIns: outcome})
var roundLog2 = element.roundLog2
roundLog2 = JSON.parse(roundLog2[0])
oldVal = 0
newVal = 0
outcome = 0
countLoc = 0
Object.entries(roundLog2).forEach(
function ([feature, value]) {
var key = Object.keys(value)
var search = Object.values(dataLoc[key])
oldVal = Math.abs(search[countLoc]) + oldVal
newVal = Math.abs(Object.values(value)[0]) + newVal
countLoc++
})
oldVal = oldVal / listofNodes.length
newVal = newVal / listofNodes.length
outcome = oldVal - newVal
pushEach.push({keyIns: "roundLog2", valueIns: outcome})
var roundLog10 = element.roundLog10
roundLog10 = JSON.parse(roundLog10[0])
oldVal = 0
newVal = 0
outcome = 0
countLoc = 0
Object.entries(roundLog10).forEach(
function ([feature, value]) {
var key = Object.keys(value)
var search = Object.values(dataLoc[key])
oldVal = Math.abs(search[countLoc]) + oldVal
newVal = Math.abs(Object.values(value)[0]) + newVal
countLoc++
})
oldVal = oldVal / listofNodes.length
newVal = newVal / listofNodes.length
outcome = oldVal - newVal
pushEach.push({keyIns: "roundLog10", valueIns: outcome})
pushEachFinal.push({key: listofNodes[index], value: pushEach})
})
var nodes = []
listofNodes.forEach(element => nodes.push({"name": element}))
listofNodes.forEach( function(element) {
nodes.push({"name": element, "children": [
{"name": element+"_round"},
{"name": element+"_roundLogE"},
{"name": element+"_roundLog2"},
{"name": element+"_roundLog10"},
]})
})
var links = []
@ -36,9 +130,7 @@ export default {
Object.entries(value).forEach( function ([featureInside, value]) {
if (feature != featureInside) {
if (value >= 0) {
links.push({"source": listofNodes.indexOf(feature), "target": listofNodes.indexOf(featureInside), "value": Math.abs(value) * 30, "group": 1})
} else {
links.push({"source": listofNodes.indexOf(feature), "target": listofNodes.indexOf(featureInside), "value": Math.abs(value) * 30, "group": 2})
links.push({"source": listofNodes.indexOf(feature), "target": listofNodes.indexOf(featureInside), "value": Math.abs(value) * 30})
}
}
})
@ -117,7 +209,7 @@ export default {
var colorsScaleNodes = d3.scaleLinear()
.domain([MIMin, MIMax])
.range(['#6baed6','#4292c6','#2171b5','#08519c','#08306b']);
.range(['#a6bddb','#74a9cf','#3690c0','#0570b0','#045a8d','#023858']);
var svg = d3.select("#FeatureGraph1");
svg.selectAll("*").remove();
@ -465,6 +557,7 @@ export default {
},
},
mounted () {
EventBus.$on('quadTrans1', data => { this.dataFS1Trans = data })
EventBus.$on('quad1', data => { this.dataFS1 = data })
EventBus.$on('quad1', this.initializeNetwork)
}

@ -117,7 +117,7 @@ export default {
var colorsScaleNodes = d3.scaleLinear()
.domain([MIMin, MIMax])
.range(['#6baed6','#4292c6','#2171b5','#08519c','#08306b']);
.range(['#a6bddb','#74a9cf','#3690c0','#0570b0','#045a8d','#023858']);
var svg = d3.select("#FeatureGraph2");
svg.selectAll("*").remove();

@ -117,7 +117,7 @@ export default {
var colorsScaleNodes = d3.scaleLinear()
.domain([MIMin, MIMax])
.range(['#6baed6','#4292c6','#2171b5','#08519c','#08306b']);
.range(['#a6bddb','#74a9cf','#3690c0','#0570b0','#045a8d','#023858']);
var svg = d3.select("#FeatureGraph3");
svg.selectAll("*").remove();

@ -117,7 +117,7 @@ export default {
var colorsScaleNodes = d3.scaleLinear()
.domain([MIMin, MIMax])
.range(['#6baed6','#4292c6','#2171b5','#08519c','#08306b']);
.range(['#a6bddb','#74a9cf','#3690c0','#0570b0','#045a8d','#023858']);
var svg = d3.select("#FeatureGraph4");
svg.selectAll("*").remove();

@ -520,7 +520,10 @@ export default Vue.extend({
.then(response => {
console.log('Server successfully send the correlation matrices!')
this.correlResulTranformed = response.data.correlResulTranformed
console.log(this.correlResulTranformed)
EventBus.$emit('quadTrans1', this.correlResulTranformed)
EventBus.$emit('quadTrans2', this.correlResulTranformed)
EventBus.$emit('quadTrans3', this.correlResulTranformed)
EventBus.$emit('quadTrans4', this.correlResulTranformed)
this.returnCorrel()
})
.catch(error => {

@ -484,7 +484,7 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4):
global packCorrTransformed
packCorrTransformed = []
for i in columns:
for count, i in enumerate(columns):
dicTransf = {}
@ -495,7 +495,7 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4):
quadrantVariable = str('quadrant%s' % number)
illusion = locals()[quadrantVariable]
d["DataRows{0}".format(number)] = XDataNumericCopy.iloc[illusion, :]
dicTransf["round"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4)
dicTransf["round"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4, i, count)
d={}
XDataNumericCopy = XDataNumeric.copy()
@ -505,7 +505,7 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4):
quadrantVariable = str('quadrant%s' % number)
illusion = locals()[quadrantVariable]
d["DataRows{0}".format(number)] = XDataNumericCopy.iloc[illusion, :]
dicTransf["roundLogE"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4)
dicTransf["roundLogE"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4, i, count)
d={}
XDataNumericCopy = XDataNumeric.copy()
@ -515,7 +515,7 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4):
quadrantVariable = str('quadrant%s' % number)
illusion = locals()[quadrantVariable]
d["DataRows{0}".format(number)] = XDataNumericCopy.iloc[illusion, :]
dicTransf["roundLog2"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4)
dicTransf["roundLog2"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4, i, count)
d={}
XDataNumericCopy = XDataNumeric.copy()
@ -525,13 +525,13 @@ def Transformation(quadrant1, quadrant2, quadrant3, quadrant4):
quadrantVariable = str('quadrant%s' % number)
illusion = locals()[quadrantVariable]
d["DataRows{0}".format(number)] = XDataNumericCopy.iloc[illusion, :]
dicTransf["roundLog10"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4)
dicTransf["roundLog10"] = NewComputationTransf(d['DataRows1'], d['DataRows2'], d['DataRows3'], d['DataRows4'], quadrant1, quadrant2, quadrant3, quadrant4, i, count)
packCorrTransformed.append(dicTransf)
return 'Everything Okay'
def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1, quadrant2, quadrant3, quadrant4):
def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1, quadrant2, quadrant3, quadrant4, feature, count):
# Main Features
corrMatrix1 = DataRows1.corr()
@ -543,6 +543,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
corrMatrix4 = DataRows4.corr()
corrMatrix4 = corrMatrix4.abs()
corrMatrix1 = corrMatrix1.loc[[feature]]
corrMatrix2 = corrMatrix2.loc[[feature]]
corrMatrix3 = corrMatrix3.loc[[feature]]
corrMatrix4 = corrMatrix4.loc[[feature]]
DataRows1 = DataRows1.reset_index(drop=True)
DataRows2 = DataRows2.reset_index(drop=True)
DataRows3 = DataRows3.reset_index(drop=True)
@ -576,9 +581,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
VIF1 = pd.Series([variance_inflation_factor(X1.values, i)
for i in range(X1.shape[1])],
index=X1.columns)
VIF1 = VIF1.loc[[feature]]
if (len(targetRows1Arr) > 2):
MI1 = mutual_info_classif(DataRows1, targetRows1Arr)
MI1List = MI1.tolist()
MI1List = MI1List[count]
else:
MI1List = []
else:
@ -599,9 +606,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
VIF2 = pd.Series([variance_inflation_factor(X2.values, i)
for i in range(X2.shape[1])],
index=X2.columns)
VIF2 = VIF2.loc[[feature]]
if (len(targetRows2Arr) > 2):
MI2 = mutual_info_classif(DataRows2, targetRows2Arr)
MI2List = MI2.tolist()
MI2List = MI2List[count]
else:
MI2List = []
else:
@ -622,9 +631,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
VIF3 = pd.Series([variance_inflation_factor(X3.values, i)
for i in range(X3.shape[1])],
index=X3.columns)
VIF3 = VIF3.loc[[feature]]
if (len(targetRows3Arr) > 2):
MI3 = mutual_info_classif(DataRows3, targetRows3Arr)
MI3List = MI3.tolist()
MI3List = MI3List[count]
else:
MI3List = []
else:
@ -645,9 +656,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
VIF4 = pd.Series([variance_inflation_factor(X4.values, i)
for i in range(X4.shape[1])],
index=X4.columns)
VIF4 = VIF4.loc[[feature]]
if (len(targetRows4Arr) > 2):
MI4 = mutual_info_classif(DataRows4, targetRows4Arr)
MI4List = MI4.tolist()
MI4List = MI4List[count]
else:
MI4List = []
else:
@ -655,6 +668,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
VIF4 = pd.Series()
MI4List = []
corrMatrixComb1 = corrMatrixComb1.loc[[feature]]
corrMatrixComb2 = corrMatrixComb2.loc[[feature]]
corrMatrixComb3 = corrMatrixComb3.loc[[feature]]
corrMatrixComb4 = corrMatrixComb4.loc[[feature]]
targetRows1ArrDF = pd.DataFrame(targetRows1Arr)
targetRows2ArrDF = pd.DataFrame(targetRows2Arr)
targetRows3ArrDF = pd.DataFrame(targetRows3Arr)
@ -674,6 +692,15 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
corrMatrixCombTotal4 = concatAllDF4.corr()
corrMatrixCombTotal4 = corrMatrixCombTotal4.abs()
corrMatrixCombTotal1 = corrMatrixCombTotal1.loc[[feature]]
corrMatrixCombTotal1 = corrMatrixCombTotal1.iloc[:,-1]
corrMatrixCombTotal2 = corrMatrixCombTotal2.loc[[feature]]
corrMatrixCombTotal2 = corrMatrixCombTotal2.iloc[:,-1]
corrMatrixCombTotal3 = corrMatrixCombTotal3.loc[[feature]]
corrMatrixCombTotal3 = corrMatrixCombTotal3.iloc[:,-1]
corrMatrixCombTotal4 = corrMatrixCombTotal4.loc[[feature]]
corrMatrixCombTotal4 = corrMatrixCombTotal4.iloc[:,-1]
corrMatrixCombTotal1 = pd.concat([corrMatrixCombTotal1.tail(1)])
corrMatrixCombTotal2 = pd.concat([corrMatrixCombTotal2.tail(1)])
corrMatrixCombTotal3 = pd.concat([corrMatrixCombTotal3.tail(1)])
@ -696,11 +723,6 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
packCorrLoc.append(corrMatrixCombTotal3.to_json())
packCorrLoc.append(corrMatrixCombTotal4.to_json())
packCorrLoc.append(json.dumps(uniqueTarget1))
packCorrLoc.append(json.dumps(uniqueTarget2))
packCorrLoc.append(json.dumps(uniqueTarget3))
packCorrLoc.append(json.dumps(uniqueTarget4))
packCorrLoc.append(VIF1.to_json())
packCorrLoc.append(VIF2.to_json())
packCorrLoc.append(VIF3.to_json())
@ -711,6 +733,11 @@ def NewComputationTransf(DataRows1, DataRows2, DataRows3, DataRows4, quadrant1,
packCorrLoc.append(json.dumps(MI3List))
packCorrLoc.append(json.dumps(MI4List))
packCorrLoc.append(json.dumps(uniqueTarget1))
packCorrLoc.append(json.dumps(uniqueTarget2))
packCorrLoc.append(json.dumps(uniqueTarget3))
packCorrLoc.append(json.dumps(uniqueTarget4))
return packCorrLoc
@cross_origin(origin='localhost',headers=['Content-Type','Authorization'])

Loading…
Cancel
Save