import pandas as pd
from sklearn.tree import DecisionTreeClassifier
df=pd.read_csv('/home/aiktc/Desktop/exp2.csv')
print(df)
tree=DecisionTreeClassifier(criterion='entropy')
tree.fit(df[['wind','Humidity']],df.temperature)
print("prediction for HIGH wind and HIGH Humidity",tree.predict([[1,1]]))
Output:
/ML$ python decision.py
temperature wind Humidity
0 hot 0 0
1 hot 1 1
2 Mild 0 0
3 Mild 1 1
4 Cool 0 0
5 Mild 1 0
6 Mild 0 1
7 hot 1 0
8 Mild 1 0
9 cool 1 0
prediction for HIGH wind and HIGH humidity ['Mild']
No comments:
Post a Comment