from sklearn.datasets import load_digits
digits = load_digits()

from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(digits.data,
                                                    digits.target)

"""
Explanation: Get some data to play with
End of explanation
"""


from sklearn.svm import LinearSVC

"""
Explanation: Really Simple API
0) Import your model class
End of explanation
"""


svm = LinearSVC(C=0.1)

"""
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)

%load https://raw.githubusercontent.com/scikit-learn/scikit-learn/master/examples/classification/plot_classifier_comparison.py

"""
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.
End of explanation
"""


