You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
def get_params(self, deep):
return {'n_tree': self.n_tree}
def predict(self, X):
res = np.array([tree.predict(X) for tree in self.trees])
return res.mean(axis=0)
class MondrianTreeRegressor(object):
def init(self):
MondrianTree.init(self)
self.stat_factory = RegressorFactory()
def predict(self, X):
res = []
for x in X:
predicted = self._predict(x, self.root, 1.0).get()
res.append(predicted)
# res=map(lambda x : (self._predict(X, self.root, 1.0).get()),X)
return np.array(res)
class RegressorResult(object):
def init(self, avg):
self.avg = avg
@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
The text was updated successfully, but these errors were encountered: