This is a simple yet effective machine learning model that predicts the species of an Iris flower (setosa, versicolor, or virginica) using four key features:
1from sklearn.datasets import load_iris
2from sklearn.tree import DecisionTreeClassifier
3
4# Load and train model
5iris = load_iris()
6X, y = iris.data, iris.target
7model = DecisionTreeClassifier()
8model.fit(X, y)
9
10# Predict
11sample = [[5.1, 3.5, 1.4, 0.2]]
12predicted_class = model.predict(sample)[0]
13print("Predicted species:", iris.target_names[predicted_class])