def mcfs_ours(train, test, K, debug=True):
    W = mcfs(train[0], n_selected_features=K, verbose=debug)
    bindices = mcfs_ranking(W)[:K]
    if debug:
        print(bindices)
    return train[0][:, bindices], test[0][:, bindices]
Beispiel #2
0
def my_mcfs(X, y):
    result = mcfs(copy.deepcopy(X), X.shape[1])
    new_result = result.max(1)
    return new_result
Beispiel #3
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import numpy as np
import scipy.io
from ConstructPairwiseDistance import ConstructPairwiseDistance
from sklearn.metrics.pairwise import pairwise_distances
import datetime
import construct_W
from skfeature.function.sparse_learning_based.MCFS import mcfs

mat = scipy.io.loadmat("COIL20.mat")
X = mat['X']
kwrags_W = {
    "metric": "euclidean",
    "neighbor_mode": "knn",
    "weight_mode": "heat_kernel",
    "k": 5,
    "t": 1
}
W = construct_W.construct_W(X, **kwrags_W)
print W
weightMat = mcfs(X, 10, **{"W": W, "n_clusters": 20})
print weightMat
print weightMat.shape
np.savetxt("a.txt", weightMat, fmt='%.5f')