Created
July 30, 2017 17:09
-
-
Save vaibhav-jain/adbb24a6afc7231505dda8baa74e4f66 to your computer and use it in GitHub Desktop.
Solving classical Iris problem using machine learning.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
from sklearn import tree | |
from sklearn.datasets import load_iris | |
iris = load_iris() | |
test_tdx = [0, 50, 100] | |
# training data | |
train_target = np.delete(iris.target, test_tdx) | |
train_data = np.delete(iris.data, test_tdx, axis=0) | |
# testing data | |
test_data = iris.data[test_tdx] | |
test_target = iris.target[test_tdx] | |
clf = tree.DecisionTreeClassifier() | |
clf = clf.fit(train_data, train_target) | |
print test_target | |
print clf.predict(test_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment