Open ryan102590 opened 5 years ago
@ryan102590 interesting idea. I guess you are referring to this repo: https://github.com/nel215/mondrianforest ?
@yubin-park correct! I just moved all of the classes into one file so that it would be easier for me to look at and learn. It's an interesting concept because of the pausing component of the algorithm when there isn't new information and it's efficient partial_fit capabilities.
overall I'm hoping to implement a partial_fit stochastic boosting descent version and trying to find the most efficient way. I have a version now but it's very slow.
Hi Yubin,
Very interesting work! I was wondering if you had any ideas on implementing a mondrian tree: I have some script from nel215 that looks to be in the most basic form using just numpy, do you think their is a way we could implement it in a find_split/is_leaf form that you present?
import numpy as np
class MondrianForestRegressor(object): def init(self, n_tree): self.n_tree = n_tree self.trees = [] for i in range(self.n_tree): self.trees.append(MondrianTreeRegressor()) def fit(self, X, y): for tree in self.trees: tree.fit(X, y) def partial_fit(self, X, y): for tree in self.trees: tree.partial_fit(X, y)
class Node(object): def init(self, min_list, max_list, tau, is_leaf, stat, parent=None, delta=None, xi=None): self.parent = parent self.tau = tau self.is_leaf = is_leaf self.min_list = min_list self.max_list = max_list self.delta = delta self.xi = xi self.left = None self.right = None self.stat = stat
class RegressorFactory(object): def create(self): return Regressor()
class MondrianTree(object): def init(self): self.root = None self.classes = set()
class MondrianTreeRegressor(object): def init(self): MondrianTree.init(self) self.stat_factory = RegressorFactory()
class RegressorResult(object): def init(self, avg): self.avg = avg
class Regressor(object): def init(self): self.sum = 0 self.count = 0 def add(self, x, y): (self.sum) += y (self.count) += 1 def merge(self, r): res = Regressor() res.sum = self.sum + r.sum res.count = self.count + r.count return res