示例#1
0
def main():
    data_name = "CALFW_29v2"
    data_path = "D:/DATA/"
    if "29v2" in data_name:
        X, y_true, N, dim, c_true = Ifuns.load_mat(data_path + "FaceData/" + data_name)
    else:
        X, y_true, N, dim, c_true = Ifuns.load_mat(data_path + data_name)

    print("hh")
    Y = Ifuns.kmeans(X, c_true, rep=10, init="random", par=1)
    acc = np.array([Ifuns.accuracy(y_true, y) for y in Y])
    ari = np.array([Ifuns.ari(y_true, y) for y in Y])
    ami = np.array([Ifuns.ami(y_true, y) for y in Y])
    nmi = np.array([Ifuns.nmi(y_true, y) for y in Y])
    print("{}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}".format(data_name,
                                                                                      np.mean(acc), np.std(acc),
                                                                                      np.mean(ari), np.std(ari),
                                                                                      np.mean(ami), np.std(ami),
                                                                                      np.mean(nmi), np.std(nmi)))
示例#2
0
import numpy as np
import IDEAL_NPU.funs as Ifuns
from IDEAL_NPU.cluster import SSC


X, y_true, N, dim, c_true = Ifuns.load_USPS()
print("USPS", N, dim, c_true)

obj = SSC(X=X, c_true=c_true)
y = obj.clu(km_rep=10, way="NJW")

acc = Ifuns.accuracy(y_true, y)
print(acc)

# paper: USPS, ACC, 67.52 %
示例#3
0
# abandon
import numpy as np
import IDEAL_NPU.funs as Ifuns
from backup import ISR

data_name = "srbct"
X, y_true, N, dim, c_true = Ifuns.load_mat("D:/DATA/" + data_name)

print(data_name, N, dim, c_true)

obj = ISR(X, c_true)

knn_list = [10, 20, 30, 40, 50]
acc = np.zeros(len(knn_list))
for i, knn in enumerate(knn_list):
    y = obj.clu(graph_knn=knn, sr_ITER=10)
    acc[i] = Ifuns.accuracy(y_true, y)

print(acc)
print(np.mean(acc))

# paper: USPS, ACC, 67.52 %
示例#4
0
import numpy as np
import IDEAL_NPU.funs as Ifuns
from IDEAL_NPU.cluster import EEBC, EEBCX

data_name = "mpeg7"
X, y_true, N, dim, c_true = Ifuns.load_mat("D:/DATA/" + data_name)
print(N, dim, c_true)

# EEBC
knn = 20
D = Ifuns.EuDist2(X, X, squared=True)
ind_M = np.argsort(D, axis=1)
NN = ind_M[:, :knn]
NND = Ifuns.matrix_index_take(D, NN)

obj = EEBC(NN.astype(np.int32), NND, c_true)
obj.clu()
y_pred = obj.y_pre

acc = Ifuns.accuracy(y_true=y_true, y_pred=y_pred)
print(acc)

# EEBC-X
obj = EEBCX(X, c_true)
obj.clu()

y_pred = obj.y
acc = Ifuns.accuracy(y_true=y_true, y_pred=y_pred)
print(acc)
示例#5
0
import numpy as np
from IDEAL_NPU.cluster import FCDMF
from IDEAL_NPU import funs as Ifuns

X, y_true, N, dim, c_true = Ifuns.load_mat("D:/DATA/face94_256.mat")
X = Ifuns.normalize_fea(X, 0)
print(N, dim, c_true)

obj = FCDMF(X, c_true)
Y = obj.clu(KTIMES=5)

ret = [Ifuns.accuracy(y_true, y) for y in Y]
print(ret)
print(np.mean(ret))