BagLearner.py - _author ='ANM import numpy as np import RTLearner from random import randint class BagLearner(object N_PRIME_PERCENT = 0.6 def_init(self

BagLearner.py - _author ='ANM import numpy as np import...

This preview shows page 1 out of 1 page.

__author__ = 'ANM' import numpy as np import RTLearner from random import randint class BagLearner(object): N_PRIME_PERCENT = 0.6 def __init__(self, learner=RTLearner, kwargs={"leaf_size": 1}, bags=20, boost=False, verbose=False): self.learners = [] for i in xrange(bags): self.learners.append(learner(**kwargs)) @staticmethod def get_random_indices(n, n_prime_percent): indices = [] for i in xrange(int(n_prime_percent * n)): indices.append(randint(0, n - 1)) return indices def addEvidence(self, Xtrain, Ytrain): for learner in self.learners: indices = BagLearner.get_random_indices(Xtrain.shape[0],
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Fall '10
  • BOB
  • random import randint, def __init__, xrange, @staticmethod, def get_random_indices

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes