Step 2: Implement The ID3 Algorithm
Step 2: Implement The ID3 Algorithm
# PlayTennis dataset
data = {
'Outlook': ['Sunny', 'Sunny', 'Overcast', 'Rain', 'Rain', 'Rain', 'Overc
'Temperature': ['Hot', 'Hot', 'Hot', 'Mild', 'Cool', 'Cool', 'Cool', 'Mi
'Humidity': ['High', 'High', 'High', 'High', 'Normal', 'Normal', 'Normal
'Wind': ['Weak', 'Strong', 'Weak', 'Weak', 'Weak', 'Strong', 'Strong', '
'PlayTennis': ['No', 'No', 'Yes', 'Yes', 'Yes', 'No', 'Yes', 'No', 'Yes'
}
df = pd.DataFrame(data)
return tree
Conclusion
This implementation provides a basic ID3 algorithm that builds a decision tree
using information gain and can be used to predict the target variable
(PlayTennis) based on the features. The inductive bias of the ID3 algorithm is
revealed through its preference for attributes that maximize information gain,
which influences the structure of the tree and the model's generalization.
In [ ]: