Decision Tree classifier on Iris data Sets Using Python sklearn





 DataSet link :
https://en.wikipedia.org/wiki/Iris_flower_data_set#Use_of_the_data_set


from sklearn.datasets import load_iris
#iris flower data set available in sklearn 
#contain features and labels , like sapal length , sapal width , patellength
#this data set avlbl in sklearn so we import from sklearn 
from sklearn import tree
#to used decision tree classifier we need to import tree
import numpy as np
iris=load_iris()
# load the dataset
print(iris.feature_names)

#print the features name
print(iris.target_names)
#print labels (target name) 
print(iris.data[0])
# length width print of first flower 
print(iris.target[0])
#print label  of zero flower
removed = [0,50,100]
#removed this 3 rows from data set to find accuracy
new_target=np.delete(iris.target,removed)
new_data=np.delete(iris.data,removed,axis=0)
clf=tree.DecisionTreeClassifier()
clf = clf.fit(new_data,new_target)

//test prediction what is [0,50,100]
prediction=clf.predict(iris.data[removed])
print(iris.target[removed])
print(prediction)




Comments

Popular posts from this blog

Filter In Javafx

Kotlin with StandAlone Complier