0% found this document useful (0 votes)
28 views3 pages

Decision Tree Explanation

Uploaded by

saratabassum043
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Decision Tree Explanation

Uploaded by

saratabassum043
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Decision Tree: Step-by-Step Explanation

1. Dataset:

| Day | Outlook | Temperature | Humidity | Wind | Play Golf |

|-------|----------|-------------|-----------|--------|-----------|

| D1 | Sunny | Hot | High | Weak | No |

| D2 | Sunny | Hot | High | Strong | No |

| D3 | Overcast | Hot | High | Weak | Yes |

| D4 | Rain | Mild | High | Weak | Yes |

| D5 | Rain | Cool | Normal | Weak | Yes |

| D6 | Rain | Cool | Normal | Strong | No |

| D7 | Overcast | Cool | Normal | Strong | Yes |

| D8 | Sunny | Mild | High | Weak | No |

| D9 | Sunny | Cool | Normal | Weak | Yes |

| D10 | Rain | Mild | Normal | Weak | Yes |

| D11 | Sunny | Mild | Normal | Strong | Yes |

| D12 | Overcast | Mild | High | Strong | Yes |

| D13 | Overcast | Hot | Normal | Weak | Yes |

| D14 | Rain | Mild | High | Strong | No |

2. Dataset Entropy:

Entropy(S) = -p(Yes) * log2(p(Yes)) - p(No) * log2(p(No))

= 0.940

3. Information Gain Calculations:

- Outlook:
IG(Outlook) = 0.940 - 0.693 = 0.247

- Temperature:

IG(Temperature) = 0.940 - 0.910 = 0.030

- Humidity:

IG(Humidity) = 0.940 - 0.789 = 0.151

- Wind:

IG(Wind) = 0.940 - 0.893 = 0.047

4. Decision Tree Construction:

- Root Node: Outlook

- Sub-nodes:

- Sunny:

- Humidity:

- High -> No

- Normal -> Yes

- Overcast -> Yes

- Rain:

- Wind:

- Weak -> Yes

- Strong -> No

5. Final Decision Tree Representation (Manual):

Outlook

|-- Sunny

| |-- Humidity

| |-- High: No

| |-- Normal: Yes


|-- Overcast: Yes

|-- Rain

|-- Wind

|-- Weak: Yes

|-- Strong: No

6. Python Code:

See the attached Python code for implementing and visualizing the decision tree.

You might also like