Created
November 4, 2018 09:52
-
-
Save parmarsuraj99/8dc7c231015df6b1f1e23245f6214110 to your computer and use it in GitHub Desktop.
Decision tree Classifier (sklearn)
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
from sklearn.datasets import load_iris #load dataset from scikitlearn | |
#This is a function which will return X and Y | |
from sklearn import tree | |
iris = load_iris() #load_iris() returns iris.data (x) and iris.target (Y) | |
clf = tree.DecisionTreeClassifier() #we create a Decision Tree Classifier from sklearn.tree | |
clf.fit(iris.data, iris.target) #Training | |
print("input: ", [4.9, 3.4, 2, 0.4]) #predictions | |
print("Prrediction: ", clf.predict([[4.9, 3.4, 2, 0.4]])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment