Esempio n. 1
0
def main():
    # load matlab data
    mat = scipy.io.loadmat('../data/COIL20.mat')
    X = mat['X']    # data
    y = mat['Y']    # label
    y = y[:, 0]
    X = X.astype(float)
    n_samples, n_features = X.shape

    # construct affinity matrix
    kwargs_W = {"metric": "euclidean", "neighbor_mode": "knn", "weight_mode": "heat_kernel", "k": 5, 't': 1}
    W = construct_W.construct_W(X, **kwargs_W)

    # feature selection
    score = lap_score.lap_score(X, W = W)

    idx = lap_score.feature_ranking(score)

    # evaluation
    num_fea = 100
    selected_features = X[:, idx[0:num_fea]]
    ari, nmi, acc = unsupervised_evaluation.evaluation(X_selected=selected_features, n_clusters=20, y=y)
    print 'ARI:', ari
    print 'NMI:', nmi
    print 'ACC:', acc
Esempio n. 2
0
def main():
    # load data
    mat = scipy.io.loadmat('../data/gisette.mat')
    X = mat['X']
    y = mat['Y']
    y = y[:, 0]
    X = X.astype(float)


    # feature selection
    kwargs = {'style': 0}
    score = SPEC.spec(X, **kwargs)
    idx = SPEC.feature_ranking(score, **kwargs)

    # evaluation
    num_fea = 100
    selected_features = X[:, idx[0:num_fea]]
    ari, nmi, acc = unsupervised_evaluation.evaluation(selected_features=selected_features, n_clusters=2, y=y)
    print 'ARI:', ari
    print 'NMI:', nmi
    print 'ACC:', acc
Esempio n. 3
0
def main():
    # load matlab data
    mat = scipy.io.loadmat('../data/COIL20.mat')
    X = mat['X']
    X = X.astype(float)
    y = mat['Y']
    y = y[:, 0]

    # construct W
    kwargs = {"metric": "euclidean", "neighborMode": "knn", "weightMode": "heatKernel", "k": 5, 't': 1}
    W = construct_W.construct_W(X, **kwargs)

    # mcfs feature selection
    n_selected_features = 100
    S = MCFS.mcfs(X, n_selected_features, W=W, n_clusters=20)
    idx = MCFS.feature_ranking(S)

    # evaluation
    X_selected = X[:, idx[0:n_selected_features]]
    ari, nmi, acc = unsupervised_evaluation.evaluation(X_selected=X_selected, n_clusters=20, y=y)
    print 'ARI:', ari
    print 'NMI:', nmi
    print 'ACC:', acc
Esempio n. 4
0
def main():
    # load data
    mat = scipy.io.loadmat('../data/COIL20.mat')
    X = mat['X']    # data
    X = X.astype(float)
    y = mat['Y']    # label
    y = y[:, 0]

    kwargs = {"metric": "euclidean", "neighbor_mode": "knn", "weight_mode": "heat_kernel", "k": 5, 't': 1}
    W = construct_W.construct_W(X, **kwargs)

    # NDFS feature selection
    W = NDFS.ndfs(X, W=W, n_clusters=20, verbose=False)
    idx = feature_ranking(W)

    # evaluation
    n_selected_features = 100
    X_selected = X[:, idx[0:n_selected_features]]
    ari, nmi, acc = evaluation(X_selected=X_selected, n_clusters=20, y=y)

    print 'ARI:', ari
    print 'NMI:', nmi
    print 'ACC:', acc