---
# System prepended metadata

title: MLCV Assignment 2

---

# MLCV Assignment 2

## Exercise 1

### 1)

Entropy = $1$

### 2)
```graphviz
digraph {
    node [shape=rect]
    a1
    
    node [shape=ellipse]
    a1T[label="+=2    -=1"]
    a1F[label="+=1    -=2\n"]
    a1 -> a1T [label=T]
    a1 -> a1F [label=F]
}
```

\\[E_{a1_T}=E_{a1_F}=-\frac{2}{3}\cdot log_2({2\over3})-\frac{1}{3}\cdot log_2({1\over3})\\]
\\[E=-\frac{3}{6}E_{a1_T}+\frac{3}{6}E_{a1_F}=0.918\\]

\\[Gain=1.0-0.918=0.082\\]

```graphviz
digraph {
    node [shape=rect]
    a2
    
    node [shape=ellipse]
    a2T[label="+=2    -=2"]
    a2F[label="+=1    -=1\n"]
    a2 -> a2T [label=T]
    a2 -> a2F [label=F]
}
```

\\[E_{a2_T}=E_{a2_F}=-\frac{2}{4}\cdot log_2({2\over4})-\frac{1}{2}\cdot log_2({1\over2})\\]
\\[E=-\frac{3}{6}E_{a2_T}+\frac{3}{6}E_{a2_F}=1.0\\]

\\[Gain=1.0-1.0=0\\]

### 3)
1. Schritt: Nach a1 splitten, weil höherer Gain
```graphviz
digraph {
    node [shape=rect]
    a1
    
    node [shape=ellipse]
    a1T[label="+=2    -=1"]
    a1F[label="+=1    -=2\n"]
    a1 -> a1T [label=T]
    a1 -> a1F [label=F]
}
```

\\[E=0.918\\]

\\[Gain=1.0-0.918=0.082\\]
2. Nach a2 splitten, weil immer noch Gain vorhanden

```graphviz
digraph {
    node [shape=rect]
    a1
    a1Ta2 [label=a2]
    a1Fa2 [label=a2]
    
    node [shape=ellipse]
    a1 -> a1Ta2 [label=T]
    a1 -> a1Fa2 [label=F]
    
    a1Ta2 -> a1Ta2T [label=T]
    a1Ta2 -> a1Ta2F [label=F]
    a1Fa2 -> a1Fa2T [label=T]
    a1Fa2 -> a1Fa2F [label=F]
    
    
    a1Ta2T[label="+=2    -=0"]
    a1Ta2F[label="+=0    -=1\n"]
    a1Fa2T[label="+=0    -=2"]
    a1Fa2F[label="+=1    -=0\n"]
}
```

\\[Entropy = 0\\]
\\[Gain_{V1} = 0.918-0 = 0\\]
\\[Gain = 1-0 = 1\\]

