def classifier_lda_modular (train_fname=traindat,test_fname=testdat,label_fname=label_traindat,gamma=3,num_threads=1):
	from modshogun import RealFeatures, BinaryLabels, LDA, CSVFile

	feats_train=RealFeatures(CSVFile(train_fname))
	feats_test=RealFeatures(CSVFile(test_fname))
	labels=BinaryLabels(CSVFile(label_fname))

	lda=LDA(gamma, feats_train, labels)
	lda.train()

	bias=lda.get_bias()
	w=lda.get_w()
	predictions = lda.apply(feats_test).get_labels()
	return lda,predictions
Beispiel #2
0
def classifier_lda_modular(train_fname=traindat,
                           test_fname=testdat,
                           label_fname=label_traindat,
                           gamma=3,
                           num_threads=1):
    from modshogun import RealFeatures, BinaryLabels, LDA, CSVFile

    feats_train = RealFeatures(CSVFile(train_fname))
    feats_test = RealFeatures(CSVFile(test_fname))
    labels = BinaryLabels(CSVFile(label_fname))

    lda = LDA(gamma, feats_train, labels)
    lda.train()

    bias = lda.get_bias()
    w = lda.get_w()
    predictions = lda.apply(feats_test).get_labels()
    return lda, predictions
Beispiel #3
0
import util

util.set_title('PRC example')
util.DISTANCE=0.5
subplots_adjust(hspace=0.3)

pos=util.get_realdata(True)
neg=util.get_realdata(False)
features=util.get_realfeatures(pos, neg)
labels=util.get_labels()

# classifiers
gk=GaussianKernel(features, features, 1.0)
svm = LibSVM(1000.0, gk, labels)
svm.train()
lda=LDA(1,features,labels)
lda.train()

## plot points
subplot(211)
plot(pos[0,:], pos[1,:], "r.")
plot(neg[0,:], neg[1,:], "b.")
grid(True)
title('Data',size=10)

# plot PRC for SVM
subplot(223)
PRC_evaluation=PRCEvaluation()
PRC_evaluation.evaluate(svm.apply(),labels)
PRC = PRC_evaluation.get_PRC()
plot(PRC[0], PRC[1])
Beispiel #4
0
import util

util.set_title('ROC example')
util.DISTANCE=0.5
subplots_adjust(hspace=0.3)

pos=util.get_realdata(True)
neg=util.get_realdata(False)
features=util.get_realfeatures(pos, neg)
labels=util.get_labels()

# classifiers
gk=GaussianKernel(features, features, 1.0)
svm = LibSVM(1000.0, gk, labels)
svm.train()
lda=LDA(1,features,labels)
lda.train()

## plot points
subplot(211)
plot(pos[0,:], pos[1,:], "r.")
plot(neg[0,:], neg[1,:], "b.")
grid(True)
title('Data',size=10)

# plot ROC for SVM
subplot(223)
ROC_evaluation=ROCEvaluation()
ROC_evaluation.evaluate(svm.apply(),labels)
roc = ROC_evaluation.get_ROC()
print roc