Exemplo n.º 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)))
Exemplo n.º 2
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)
Exemplo n.º 3
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))