- Hands-On Machine Learning with Microsoft Excel 2019
- Julio Cesar Rodriguez Martino
- 466字
- 2021-06-24 15:11:03
Comparing the entropy differences (information gain)
To know which variable to choose for the first split, we calculate the information gain G when going from the original data to the corresponding subset as the difference between the entropy values:

Here, S(f1) is the entropy of the target variable and S(f1,f2) is the entropy of each feature with respect to the target variable. The entropy values were calculated in the previous subsections, so we use them here:
- If we choose Outlook as the first variable to split the tree, the information gain is as follows:
G(Train outside,Outlook) = S(Train outside) - S(Train outside,Outlook)
= 0.94-0.693=0.247
- If we choose Temperature, the information gain is as follows:
G(Train outside,Temperature) = S(Train outside) - S(Train outside,Temperature)
= 0.94-0.911=0.029
- If we choose Humidity, the information gain is as follows:
G(Train outside,Humidity) = S(Train outside) - S(Train outside,Humidity)
= 0.94-0.788=0.152
- Finally, choosing Windy gives the following information gain:
G(Train outside,Windy) = S(Train outside) - S(Train outside,Windy)
= 0.94-0.892=0.048
The variable to choose for the first splitting of the tree is the one showing the largest information gain, that is, Outlook. If we do this, we will notice that one of the resulting subsets after the splitting has zero entropy, so we don't need to split it further.
To continue building the tree following a similar procedure, the steps to take are as follows:
- Calculate S(Sunny), S(Sunny,Temperature), S(Sunny,Humidity), and S(Sunny,Windy).
- Calculate G(Sunny,Temperature), G(Sunny,Humidity), and G(Sunny,Windy).
- The larger value will tell us what feature to use to split Sunny.
- Calculate other gains, using S(Rainy), S(Rainy,Temperature), S(Rainy,Humidity), and S(Rainy,Windy).
- The larger value will tell us what feature to use to split Rainy.
- Continue iterating until there are no features left to use.
As we will see later in this book, trees are never built by hand. It is important to understand how they work and which calculations are involved. Using Excel, it is easy to follow the full process and each step. Following the same principle, we will work through an unsupervised learning example in the next section.
- 程序員修煉之道:從小工到專家
- App+軟件+游戲+網站界面設計教程
- SQL查詢:從入門到實踐(第4版)
- PySpark大數據分析與應用
- R數據科學實戰:工具詳解與案例分析(鮮讀版)
- Hadoop 3.x大數據開發實戰
- 智能數據分析:入門、實戰與平臺構建
- INSTANT Apple iBooks How-to
- 視覺大數據智能分析算法實戰
- 中文版Access 2007實例與操作
- 智慧城市中的大數據分析技術
- Scratch 2.0 Game Development HOTSHOT
- 從Lucene到Elasticsearch:全文檢索實戰
- Practical Convolutional Neural Networks
- 一類智能優化算法的改進及應用研究