-
Notifications
You must be signed in to change notification settings - Fork 0
/
bagging.py
44 lines (35 loc) · 913 Bytes
/
bagging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
===================================================
Introduction to Machine Learning (67577)
===================================================
Skeleton for classification with Bagging.
Author: Yoav Wald
"""
import numpy as np
class Bagging(object):
def __init__(self, L, B):
"""
Parameters
----------
L : the class of the base learner
T : the number of base learners to learn
"""
self.L = L
self.B = B
self.h = [None]*B # list of base learners
def train(self, X, y):
"""
Train this classifier over the sample (X,y)
"""
def predict(self, X):
"""
Returns
-------
y_hat : a prediction vector for X
"""
def error(self, X, y):
"""
Returns
-------
the error of this classifier over the sample (X,y)
"""