<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 K-Fold Cross Validation
Step1:  A single train/test split is made easy with the train_test_split function in the cross_validation library
Step2:  K-Fold cross validation is just as easy; let's use a K of 5
Step3:  Our model is even better than we thought! Can we do better? Let's try a different kernel (poly)
Step4:  No! The more complex polynomial kernel produced lower accuracy than a simple linear kernel. The polynomial kernel is overfitting. But we couldn't have told that with a single train/test split
<ASSISTANT_TASK:>
Python Code:
import numpy as np
from sklearn.model_selection import cross_val_score, train_test_split
from sklearn import datasets
from sklearn import svm
iris = datasets.load_iris()
Explanation: K-Fold Cross Validation
End of explanation
# Split the iris data into train/test data sets with 40% reserved for testing
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.4, random_state=0)
# Build an SVC model for predicting iris classifications using training data
clf = svm.SVC(kernel='linear', C=1).fit(X_train, y_train)
# Now measure its performance with the test data
clf.score(X_test, y_test)   
Explanation: A single train/test split is made easy with the train_test_split function in the cross_validation library:
End of explanation
# We give cross_val_score a model, the entire data set and its "real" values, and the number of folds:
scores = cross_val_score(clf, iris.data, iris.target, cv=5)
# Print the accuracy for each fold:
print(scores)
# And the mean accuracy of all 5 folds:
print(scores.mean())
Explanation: K-Fold cross validation is just as easy; let's use a K of 5:
End of explanation
clf = svm.SVC(kernel='poly', C=1).fit(X_train, y_train)
scores = cross_val_score(clf, iris.data, iris.target, cv=5)
print(scores)
print(scores.mean())
Explanation: Our model is even better than we thought! Can we do better? Let's try a different kernel (poly):
End of explanation
# Build an SVC model for predicting iris classifications using training data
clf = svm.SVC(kernel='poly', C=1).fit(X_train, y_train)
# Now measure its performance with the test data
clf.score(X_test, y_test)   
Explanation: No! The more complex polynomial kernel produced lower accuracy than a simple linear kernel. The polynomial kernel is overfitting. But we couldn't have told that with a single train/test split:
End of explanation
<END_TASK>