22IZ023 Nikhil - Exercise 7 a_ Decision Trees
22IZ023 Nikhil - Exercise 7 a_ Decision Trees
Aim
To implement a Decision Tree Classifier for predicting the species of the Iris
flower based on its features using Python.
Logic Description
Decision Trees are a type of supervised learning algorithm used for classification
tasks. The algorithm splits the dataset into branches based on feature conditions,
forming a tree-like structure for decision-making.
Algorithm
Package/Tools Description
# Step 3: Split dataset into training and testing sets (80% train, 20%
test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=42)
Output:-
Test Cases
4 Sepal Length: 9.0, Sepal Width: 3.2, Petal Error: Input values are
Length: 5.8, Petal Width: 2.0 out of range
Inferences
● Decision Trees effectively classify Iris flower species based on petal and
sepal measurements.
● Proper input validation ensures meaningful predictions.
● Model accuracy depends on dataset size and quality.
Result