Task
if-condition in Python Task
What is the predicted variable classified in this tree?
What are the predictors used in this tree?
Example Data
| Outlook | Humidity | Wind | Play? |
|---|---|---|---|
| Sunny | High | - | No |
| Sunny | Normal | - | Yes |
| Overcast | - | - | Yes |
| Rain | - | Strong | No |
| Rain | - | Weak | Yes |
if outlook == "Sunny":
if humidity == "High"
play = "No"
elif humidity == "Normal"
play = "Yes"
elif outlook = "Overcast":
play = "Yes"
elif outlook = "Rain":
if wind == "Strong"
play = "No"
elif wind == "Weak"
play = "Yes"

1. Select the best attribute (feature in X) to split the data → A
2. Assign A as the decision attribute (test case) for the node
3. For each value (category) of A, create a new descendant of the node.
4. Sort the training examples to the appropriate descendant node leaf
5. If examples are perfectly classified, then stop else iterate over the new leaf nodes

of a random variable is the average level of information, surprise, or uncertainty inherent to the variable's possible outcomes
Given a discrete random variable
| Day | Weather | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 1 | Sunny | Hot | High | Weak | No |
| 2 | Cloudy | Hot | High | Weak | Yes |
| 3 | Sunny | Mild | Normal | Strong | Yes |
| 4 | Cloudy | Mild | High | Strong | Yes |
| 5 | Rainy | Mild | High | Strong | No |
| 6 | Rainy | Cool | Normal | Strong | No |
| 7 | Rainy | Mild | High | Weak | Yes |
| 8 | Sunny | Hot | High | Strong | No |
| 9 | Cloudy | Hot | Normal | Weak | Yes |
| 10 | Rainy | Mild | High | Strong | No |
| Day | Weather | Temperature | Humidity | Wind | |
|---|---|---|---|---|---|
| 1 | Sunny | Hot | High | Weak | No |
| 2 | Cloudy | Hot | High | Weak | Yes |
| 7 | Rainy | Mild | High | Weak | Yes |
| 9 | Cloudy | Hot | Normal | Weak | Yes |
| Day | Weather | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 3 | Sunny | Mild | Normal | Strong | Yes |
| 4 | Cloudy | Mild | High | Strong | Yes |
| 5 | Rainy | Mild | High | Strong | No |
| 6 | Rainy | Cool | Normal | Strong | No |
| 8 | Sunny | Hot | High | Strong | No |
| 10 | Rainy | Mild | High | Strong | No |
Weather instead?import math
math.log2(x)
10 minutes
Sunny
| Day | Weather | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 1 | Sunny | Hot | High | Weak | No |
| 3 | Sunny | Mild | Normal | Strong | Yes |
| 8 | Sunny | Hot | High | Strong | No |
Cloudy
| Day | Weather | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 2 | Cloudy | Hot | High | Weak | Yes |
| 4 | Cloudy | Mild | High | Strong | Yes |
| 9 | Cloudy | Hot | Normal | Weak | Yes |
Rainy
| Day | Weather | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 5 | Rainy | Mild | High | Strong | No |
| 6 | Rainy | Cool | Normal | Strong | No |
| 7 | Rainy | Mild | High | Weak | Yes |
| 10 | Rainy | Mild | High | Strong | No |
weather="Cloudy"
| Day | Weather | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 1 | Sunny | Hot | High | Weak | No |
| 2 | Cloudy | Hot | High | Weak | Yes |
| 3 | Sunny | Mild | Normal | Strong | Yes |
| 4 | Cloudy | Mild | High | Strong | Yes |
| 5 | Rainy | Mild | High | Strong | No |
| 6 | Rainy | Cool | Normal | Strong | No |
| 7 | Rainy | Mild | High | Weak | Yes |
| 8 | Sunny | Hot | High | Strong | No |
| 9 | Cloudy | Hot | Normal | Weak | Yes |
Examples:
You will be able to

How to create different learners?





```Mermaid graph TD A[Temperature] A ->|Hot| B[Wind] A ->|Mild| C[Wind] A ->|Cool| D[Wind] B ->|Weak| E(Yes: 2 \n No: 1 ) B ->|Strong| F(Yes: 0 \n No: 1 ) C ->|Weak| G(Yes: 1 \n No: 0) C ->|Strong| H( Yes: 2 \n No: 1) D ->|Weak| I(Yes: 0 \n No: 0) D ->|Strong| J(Yes: 0 \n No: 1 ) ```