<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction to Scikit-learn
Step1:  Really Simple API
0) Import your model class
Step2:  1) Instantiate an object and set the parameters
Step3:  2) Fit the model
Step4:  3) Apply / evaluate
Step5:  And again
Step6:  Exercises
Load the iris dataset from the sklearn.datasets module using the load_iris function.
Split it into training and test set using train_test_split.
Then train an evaluate a classifier of your choice. Try sklearn.neighbors.KNeighborsClassifier for example.
<ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split
digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(
    digits.data, digits.target, random_state=0)
X_train.shape
np.bincount(y_train)
Explanation: Introduction to Scikit-learn
End of explanation
from sklearn.svm import LinearSVC
Explanation: Really Simple API
0) Import your model class
End of explanation
svm = LinearSVC()
Explanation: 1) Instantiate an object and set the parameters
End of explanation
svm.fit(X_train, y_train)
Explanation: 2) Fit the model
End of explanation
print(svm.predict(X_train))
print(y_train)
svm.score(X_train, y_train)
svm.score(X_test, y_test)
Explanation: 3) Apply / evaluate
End of explanation
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(n_estimators=50)
rf.fit(X_train, y_train)
rf.score(X_test, y_test)
Explanation: And again
End of explanation
# %load solutions/train_iris.py
Explanation: Exercises
Load the iris dataset from the sklearn.datasets module using the load_iris function.
Split it into training and test set using train_test_split.
Then train an evaluate a classifier of your choice. Try sklearn.neighbors.KNeighborsClassifier for example.
End of explanation
<END_TASK>