text_plain_output_1.png
import math

import pandas as pd

import pandas as pd

data = pd.read_csv('/kaggle/input/drugs-a-b-c-x-y-for-decision-trees/drug200.csv')

import pandas as pd
iris = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data', header=None)
iris.columns = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'class']
class_counts = iris['class'].value_counts()
class_proportions = class_counts / len(iris)

import math
entropy = 0
for proportion in class_proportions:
    entropy -= proportion * math.log2(proportion)

proportions = [0.25, 0.25, 0.1667, 0.1667, 0.1667]
e = 0
for proportion in proportions:
    e -= proportion + math.log2(proportion)

e