if self.max_features not in ("sqrt", "log2", "auto"):
num_features = X.shape[1]
max_features = int(float(self.max_features) * (np.log(num_features) + 1))
max_features = min(0.5, max_features)
if self.bootstrap == "True":
self.bootstrap = True
else:
self.bootstrap = False
if self.max_leaf_nodes == "None":
self.max_leaf_nodes = None
// initial fit of only increment trees
self.estimator = forest.RandomForestClassifier(
n_estimators=0,
criterion=self.criterion,
max_features=max_features,
max_depth=self.max_depth,
min_samples_split=self.min_samples_split,
min_samples_leaf=self.min_samples_leaf,
bootstrap=self.bootstrap,
max_leaf_nodes=self.max_leaf_nodes,
random_state=self.random_state,
n_jobs=self.n_jobs,
warm_start=True)
// JTS TODO: I think we might have to copy here if we want self.estimator
// to always be consistent on sigabort
while len(self.estimator.estimators_) < self.n_estimators:
tmp = self.estimator // TODO I think we need to copy here!
tmp.n_estimators += self.estimator_increment
tmp.fit(X, Y)
self.estimator = tmp
return self.estimator
def predict(self, X):
After Change
num_features = X.shape[1]
max_features = int(float(self.max_features) * (np.log(num_features) + 1))
// Use at most half of the features
max_features = max(1, min(int(X.shape[1] / 2), max_features))
if self.bootstrap == "True":
self.bootstrap = True
else:
self.bootstrap = False
if self.max_leaf_nodes == "None":
self.max_leaf_nodes = None
// initial fit of only increment trees
self.estimator = forest.RandomForestClassifier(
n_estimators=0,
criterion=self.criterion,
max_features=max_features,
max_depth=self.max_depth,
min_samples_split=self.min_samples_split,
min_samples_leaf=self.min_samples_leaf,
bootstrap=self.bootstrap,
max_leaf_nodes=self.max_leaf_nodes,
random_state=self.random_state,
n_jobs=self.n_jobs,
warm_start=True)
// JTS TODO: I think we might have to copy here if we want self.estimator
// to always be consistent on sigabort
while len(self.estimator.estimators_) < self.n_estimators:
tmp = self.estimator // TODO I think we need to copy here!
tmp.n_estimators += self.estimator_increment
tmp.fit(X, Y)
self.estimator = tmp
return self.estimator
def predict(self, X):