License
This notebook:
In [66]:
# plotting library
%matplotlib inline
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.model_selection import cross_val_score
# some classifiers
from sklearn import svm
from sklearn.neighbors import KNeighborsClassifier
from sklearn import tree
import numpy
In [67]:
# read the iris data set
data = datasets.load_breast_cancer()
In [68]:
c_svm = svm.SVC(kernel='linear', C=1)
scores1 = cross_val_score(c_svm, data.data, data.target, cv=10, scoring='f1_weighted')
print(scores1)
print("SVM -- mean: " + str(numpy.mean(scores1)) + ", standard deviation: " + str(numpy.std(scores1)))
In [69]:
c_knn = KNeighborsClassifier(3)
scores2 = cross_val_score(c_knn, data.data, data.target, cv=10, scoring='f1_weighted')
print(scores2)
print("3-NN -- mean: " + str(numpy.mean(scores2)) + ", standard deviation: " + str(numpy.std(scores2)))
In [70]:
c_dt = tree.DecisionTreeClassifier()
scores3 = cross_val_score(c_dt, data.data, data.target, cv=10, scoring='f1_weighted')
print(scores3)
print("DT -- mean: " + str(numpy.mean(scores3)) + ", standard deviation: " + str(numpy.std(scores3)))