代码:
from sklearn import datasets, cross_validation
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier
from sklearn import metrics
# create a classification dataset
dataset = datasets.make_classification(n_samples=1000, n_features=10,n_informative=2, n_redundant=2, n_repeated=0, n_classes=2)
data = dataset[0]
target = dataset[1]
# Split the dataset using 10-fold cross validation
kf = cross_validation.KFold(len(data), n_folds=10, shuffle=True)
acc = {"GaussianNB":[], "SVC":[], "RandomForest":[]}
f1 = {"GaussianNB":[], "SVC":[], "RandomForest":[]}
auc = {"GaussianNB":[], "SVC":[], "RandomForest":[]}
for train_index, test_index in kf: