Experiment 8 ML Vtu
Experiment 8 ML Vtu
Information Gain
Advantages of Decision Trees
• Easy to interpret – Mimics human decision-making.
• Handles both numerical & categorical data.
• Requires little data preprocessing – No need for feature scaling.
• Works well with missing values
Sample Program
import pandas as pd
from sklearn.tree import DecisionTreeClassifier, plot_tree
from sklearn.preprocessing import LabelEncoder
import matplotlib.pyplot as plt
print("Dataset Loaded:\n")
print(df)
Lab experiment
Develop a program to demonstrate the working of the decision tree algorithm. Use
Breast Cancer Data set for building the decision tree and apply this knowledge to
classify a new sample.
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score
from sklearn import tree