|
|
@ -81,12 +81,8 @@ def neighborhood_hit(X, y, k): |
|
|
|
knn = KNeighborsClassifier(n_neighbors=k) |
|
|
|
knn = KNeighborsClassifier(n_neighbors=k) |
|
|
|
knn.fit(X, y) |
|
|
|
knn.fit(X, y) |
|
|
|
neighbors = knn.kneighbors(X, return_distance=False) |
|
|
|
neighbors = knn.kneighbors(X, return_distance=False) |
|
|
|
y = np.array(y) |
|
|
|
yPred = knn.predict(X) |
|
|
|
neigh = y[neighbors] |
|
|
|
return np.mean(np.mean((yPred[neighbors] == np.tile(yPred.reshape((-1, 1)), k)).astype('uint8'), axis=1)) |
|
|
|
tile = np.tile(y.reshape((-1, 1)), k) |
|
|
|
|
|
|
|
equals = (neigh == tile) |
|
|
|
|
|
|
|
returnthis = np.mean(np.mean(equals).astype('uint8'), axis=1) |
|
|
|
|
|
|
|
return returnthis |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def trustworthiness(D_high, D_low, k): |
|
|
|
def trustworthiness(D_high, D_low, k): |
|
|
|
n = D_high.shape[0] |
|
|
|
n = D_high.shape[0] |
|
|
@ -277,8 +273,7 @@ def calculateGrid(): |
|
|
|
k = listofParamsAll[index][0] # k = perplexity |
|
|
|
k = listofParamsAll[index][0] # k = perplexity |
|
|
|
KeepKs.append(k) |
|
|
|
KeepKs.append(k) |
|
|
|
|
|
|
|
|
|
|
|
#resultNeigh = neighborhood_hit(np.array(projectionsAll[index]), convertLabels, k) |
|
|
|
resultNeigh = neighborhood_hit(np.array(projectionsAll[index]), convertLabels, k) |
|
|
|
resultNeigh = trustworthiness(D_highSpace, D_lowSpace, k) |
|
|
|
|
|
|
|
resultTrust = trustworthiness(D_highSpace, D_lowSpace, k) |
|
|
|
resultTrust = trustworthiness(D_highSpace, D_lowSpace, k) |
|
|
|
resultContinuity = continuity(D_highSpace, D_lowSpace, k) |
|
|
|
resultContinuity = continuity(D_highSpace, D_lowSpace, k) |
|
|
|
resultStress = normalized_stress(D_highSpace, D_lowSpace) |
|
|
|
resultStress = normalized_stress(D_highSpace, D_lowSpace) |
|
|
@ -309,8 +304,7 @@ def calculateGrid(): |
|
|
|
metricsMatrixEntire = [] |
|
|
|
metricsMatrixEntire = [] |
|
|
|
|
|
|
|
|
|
|
|
for index, data in enumerate(metricTrust): |
|
|
|
for index, data in enumerate(metricTrust): |
|
|
|
#valueNeigh = (metricNeigh[index] - min_value_neigh) / (max_value_neigh - min_value_neigh) |
|
|
|
valueNeigh = (metricNeigh[index] - min_value_neigh) / (max_value_neigh - min_value_neigh) |
|
|
|
valueNeigh = (metricTrust[index] - min_value_trust) / (max_value_trust - min_value_trust) |
|
|
|
|
|
|
|
valueTrust = (metricTrust[index] - min_value_trust) / (max_value_trust - min_value_trust) |
|
|
|
valueTrust = (metricTrust[index] - min_value_trust) / (max_value_trust - min_value_trust) |
|
|
|
valueCont = (metricCont[index] - min_value_cont) / (max_value_cont - min_value_cont) |
|
|
|
valueCont = (metricCont[index] - min_value_cont) / (max_value_cont - min_value_cont) |
|
|
|
valueStress = (metricStress[index] - min_value_stress) / (max_value_stress - min_value_stress) |
|
|
|
valueStress = (metricStress[index] - min_value_stress) / (max_value_stress - min_value_stress) |
|
|
@ -362,8 +356,7 @@ def OptimizeSelection(): |
|
|
|
metricShepCorr = [] |
|
|
|
metricShepCorr = [] |
|
|
|
|
|
|
|
|
|
|
|
for index, loop in enumerate(clusterIndex): |
|
|
|
for index, loop in enumerate(clusterIndex): |
|
|
|
#resultNeigh = neighborhood_hit(np.array(projectionsAll[index]), convertLabels, k) |
|
|
|
resultNeigh = neighborhood_hit(np.array(projectionsAll[index]), convertLabels, KeepKs[index]) |
|
|
|
resultNeigh = trustworthiness(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :], KeepKs[index]) |
|
|
|
|
|
|
|
resultTrust = trustworthiness(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :], KeepKs[index]) |
|
|
|
resultTrust = trustworthiness(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :], KeepKs[index]) |
|
|
|
resultContinuity = continuity(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :], KeepKs[index]) |
|
|
|
resultContinuity = continuity(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :], KeepKs[index]) |
|
|
|
resultStress = normalized_stress(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :]) |
|
|
|
resultStress = normalized_stress(D_highSpace[dataSelected, :], D_lowSpaceList[index][dataSelected, :]) |
|
|
@ -395,8 +388,7 @@ def OptimizeSelection(): |
|
|
|
metricsMatrixEntireSel = [] |
|
|
|
metricsMatrixEntireSel = [] |
|
|
|
|
|
|
|
|
|
|
|
for index, data in enumerate(metricTrust): |
|
|
|
for index, data in enumerate(metricTrust): |
|
|
|
#valueNeigh = (metricNeigh[index] - min_value_neigh) / (max_value_neigh - min_value_neigh) |
|
|
|
valueNeigh = (metricNeigh[index] - min_value_neigh) / (max_value_neigh - min_value_neigh) |
|
|
|
valueNeigh = (metricTrust[index] - min_value_trust) / (max_value_trust - min_value_trust) |
|
|
|
|
|
|
|
valueTrust = (metricTrust[index] - min_value_trust) / (max_value_trust - min_value_trust) |
|
|
|
valueTrust = (metricTrust[index] - min_value_trust) / (max_value_trust - min_value_trust) |
|
|
|
valueCont = (metricCont[index] - min_value_cont) / (max_value_cont - min_value_cont) |
|
|
|
valueCont = (metricCont[index] - min_value_cont) / (max_value_cont - min_value_cont) |
|
|
|
valueStress = (metricStress[index] - min_value_stress) / (max_value_stress - min_value_stress) |
|
|
|
valueStress = (metricStress[index] - min_value_stress) / (max_value_stress - min_value_stress) |
|
|
|