Exemplo n.º 1
0
import numpy as np
from rlscore.learner.mmc import MMC
from rlscore.utilities.reader import read_sparse
from rlscore.measure import auc
train_labels = np.loadtxt("./legacy_tests/data/class_train.labels")
test_labels = np.loadtxt("./legacy_tests/data/class_test.labels")
train_features = read_sparse("./legacy_tests/data/class_train.features")
test_features = read_sparse("./legacy_tests/data/class_test.features")
kwargs = {}
kwargs["Y"] = train_labels
kwargs["X"] = train_features
kwargs["regparam"] = 1
learner = MMC(**kwargs)
P = learner.predict(test_features)
test_perf = auc(test_labels, P)
print("test set performance: %f" %test_perf)
from rlscore.learner.mmc import MMC
from rlscore.reader import read_sparse

## Import the dataset
gene_data_na = read_sparse("./gene_data_na.txt")

## Build the model
kwargs = {}
kwargs["X"] = gene_data_na
kwargs["regparam"] = 1
kwargs["kernel"] = "GaussianKernel"
kwargs["number_of_clusters"] = 4    ## Set the number of clusters found with the eigengap method for this kernel
learner = MMC(**kwargs)
labels = learner.results

# Write the results in output file
# out = open("python_clustering.out","w")
# for label in labels["predicted_clusters_for_training_data"]:
#    out.write(str(label) + "\n")
# out.close()
Exemplo n.º 3
0
import numpy as np
from rlscore.learner.mmc import MMC
from rlscore.utilities.reader import read_sparse
from rlscore.measure import auc
train_labels = np.loadtxt("./legacy_tests/data/class_train.labels")
test_labels = np.loadtxt("./legacy_tests/data/class_test.labels")
train_features = read_sparse("./legacy_tests/data/class_train.features")
test_features = read_sparse("./legacy_tests/data/class_test.features")
kwargs = {}
kwargs["Y"] = train_labels
kwargs["X"] = train_features
kwargs["regparam"] = 1
learner = MMC(**kwargs)
P = learner.predict(test_features)
test_perf = auc(test_labels, P)
print "test set performance: %f" %test_perf
Exemplo n.º 4
0
import numpy as np
from rlscore.learner.mmc import MMC
from rlscore.reader import read_sparse
from rlscore.reader import read_sparse
from rlscore.measure import auc
train_labels = np.loadtxt("./examples/data/class_train.labels")
test_labels = np.loadtxt("./examples/data/class_test.labels")
train_features = read_sparse("./examples/data/class_train.features")
test_features = read_sparse("./examples/data/class_test.features")
kwargs = {}
kwargs["train_labels"] = train_labels
kwargs["train_features"] = train_features
kwargs["regparam"] = 1
learner = MMC.createLearner(**kwargs)
learner.train()
model = learner.getModel()
P = model.predict(test_features)
test_perf = auc(test_labels, P)
print "test set performance: %f" %test_perf