Decision Tree Dengan Python

  Umum
from sklearn import tree
import pandas as pd
import numpy as np

iris = pd.read_csv("/home/mfahri/Documents/data mining/data/iris.csv")

Y = np.array(iris["species"])

semua = np.array(iris)

X = np.delete(semua,np.s_[4],1)


#X = sl,sw,pl,pw

#Y = species
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, Y)

coba = clf.predict([[1,2,3,4]])



print(coba)

Output

[‘virginica’]

LEAVE A COMMENT