Learn practical skills, build real-world projects, and advance your career

ABISHEK A S - 18MIS1077

The decision trees are calculated using the concept of entropy and information gain.

import pandas as pd
import numpy as np
eps = np.finfo(float).eps
from numpy import log2 as log

Creating a dataset, which represents the Eating condition based on the Taste, Temperature, Texture

dataset = {
    'Taste': [
        'Salty', 'Spicy', 'Spicy', 'Spicy', 'Spicy', 'Sweet', 'Salty', 'Sweet',
        'Spicy', 'Salty'
    ],
    'Temperature':
    ['Hot', 'Hot', 'Hot', 'Cold', 'Hot', 'Cold', 'Cold', 'Hot', 'Cold', 'Hot'],
    'Texture': [
        'Soft', 'Soft', 'Hard', 'Hard', 'Hard', 'Soft', 'Soft', 'Soft', 'Soft',
        'Hard'
    ],
    'Eat': ['No', 'No', 'Yes', 'No', 'Yes', 'Yes', 'No', 'Yes', 'Yes', 'Yes']
}