앙상블 학습

https://drive.google.com/uc?id=1_JxdvUfd7lQT8lCr8Gq72sqPV7SlmRF-

https://drive.google.com/uc?id=18Psab5A8YSmJXCvxx_QllR6TAiruci0d

$\hat{y} = mode \{ C_{1}(x), C_{2}(x), ... , C_{m}(x) \}$

$C(x) = sign [\sum_{j}^{m} C_{j}(x)] = \begin{cases} 1 & \sum_{i} C_{j}(x) \geq 0 \\ -1 & else \end{cases}$

$P(y \geq k) = \sum_{k}^{n} \varepsilon^{k} \left( \begin{array}{rr} n \\ k \end{array} \right) (1 - \varepsilon)^{n-k} = \varepsilon_{ensemble}$

$P(y \geq k) = \sum_{k = 6}^{11} 0.25^{k} (1 - 0.25)^{11-k} = 0.034$

from scipy.special import comb
import math

def ensemble_error(n_classifier, error):
    k_start = int(math.ceil(n_classifier / 2.))

    probs = [comb(n_classifier, k) * error**k * (1-error)**(n_classifier - k) for k in range(k_start, n_classifier + 1)]

    return sum(probs)