O'Reilly logo

Ensemble Machine Learning by Ankit Dixit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Marital status

The following table shows the summary of the calculations; here, 3 out of 4 married persons are investing somewhere and 50% of unmarried people are investing:

Values

Y

N

Attribute entropy

M

3

1

0.8112

UM

3

3

1

EMarital = 0.9244

IGMarital = 0.0465

Table 2.5: Summary of the Marital status attribute

Let's see the information gain and entropy calculated by our implemented function;

Ec = getClassEntropy(df["Class"])histTable = getHistTable(df,"Marital")Ig,Ea = getInformationGain(histTable,Ec)print("Information Gain for %s: %.2f and Entropy: %.2f"%("Salary",Ig,Ea))

Information gain and Entropy for Marital attribute will be:

 Information Gain for Marital: 0.05 and Entropy: 0.92

After performing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required