K折交叉验证
1、什么叫K折交叉验证?
本例主要讲4折
2、如果不交叉验证
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
#load the classifying models
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
iris = datasets.load_iris()
X = iris.data[:, :2] #load the first two features of the iris data
y = iris.target #load the target of the iris data
#split the whole set one time 将整个数据集分成训练集和测试集
#Note random state is 7 now
X_train, X_test, y_train