DWM Exp4
DWM Exp4
Introduction:
Procedure:
Program Codes:
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.tree import DecisionTreeClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score, classification_report
# Load dataset
data = load_iris()
X, y = data.data, data.target
# Split data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=42)
# Evaluate models
print("Decision Tree Accuracy:", accuracy_score(y_test, dt_predictions))
print("Decision Tree Classification Report:\n",
classification_report(y_test, dt_predictions))
● Root Node: Represents the entire dataset and the first feature split.
● Internal Nodes: Represent decision rules applied to split the data.
● Leaf Nodes: Represent the final class labels.
Ans.