def classifier_lda_modular (fm_train_real=traindat,fm_test_real=testdat,label_train_twoclass=label_traindat,gamma=3,num_threads=1):
	from shogun.Features import RealFeatures, Labels
	from shogun.Classifier import LDA

	feats_train=RealFeatures(fm_train_real)
	feats_test=RealFeatures(fm_test_real)

	labels=Labels(label_train_twoclass)

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

	lda.get_bias()
	lda.get_w()
	lda.set_features(feats_test)
	lda.apply().get_labels()
	return lda,lda.apply().get_labels()
def classifier_lda_modular(fm_train_real=traindat,
                           fm_test_real=testdat,
                           label_train_twoclass=label_traindat,
                           gamma=3,
                           num_threads=1):
    from shogun.Features import RealFeatures, Labels
    from shogun.Classifier import LDA

    feats_train = RealFeatures(fm_train_real)
    feats_test = RealFeatures(fm_test_real)

    labels = Labels(label_train_twoclass)

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

    lda.get_bias()
    lda.get_w()
    lda.set_features(feats_test)
    lda.apply().get_labels()
    return lda, lda.apply().get_labels()
Example #3
0
ROC_evaluation = ROCEvaluation()
ROC_evaluation.evaluate(svm.apply(), labels)
roc = ROC_evaluation.get_ROC()
print roc
plot(roc[0], roc[1])
fill_between(roc[0], roc[1], 0, alpha=0.1)
text(
    mean(roc[0]) / 2,
    mean(roc[1]) / 2, 'auROC = %.5f' % ROC_evaluation.get_auROC())
grid(True)
xlabel('FPR')
ylabel('TPR')
title('LibSVM (Gaussian kernel, C=%.3f) ROC curve' % svm.get_C1(), size=10)

# plot ROC for LDA
subplot(224)
ROC_evaluation.evaluate(lda.apply(), labels)
roc = ROC_evaluation.get_ROC()
plot(roc[0], roc[1])
fill_between(roc[0], roc[1], 0, alpha=0.1)
text(
    mean(roc[0]) / 2,
    mean(roc[1]) / 2, 'auROC = %.5f' % ROC_evaluation.get_auROC())
grid(True)
xlabel('FPR')
ylabel('TPR')
title('LDA (gamma=%.3f) ROC curve' % lda.get_gamma(), size=10)

connect('key_press_event', util.quit)
show()
Example #4
0
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
plot(roc[0], roc[1])
fill_between(roc[0],roc[1],0,alpha=0.1)
text(mean(roc[0])/2,mean(roc[1])/2,'auROC = %.5f' % ROC_evaluation.get_auROC())
grid(True)
xlabel('FPR')
ylabel('TPR')
title('LibSVM (Gaussian kernel, C=%.3f) ROC curve' % svm.get_C1(),size=10)

# plot ROC for LDA
subplot(224)
ROC_evaluation.evaluate(lda.apply(),labels)
roc = ROC_evaluation.get_ROC()
plot(roc[0], roc[1])
fill_between(roc[0],roc[1],0,alpha=0.1)
text(mean(roc[0])/2,mean(roc[1])/2,'auROC = %.5f' % ROC_evaluation.get_auROC())
grid(True)
xlabel('FPR')
ylabel('TPR')
title('LDA (gamma=%.3f) ROC curve' % lda.get_gamma(),size=10)

connect('key_press_event', util.quit)
show()