基本模式(取自Miriam的回答):
clf = RandomForestClassifier(warm_start=True)
clf.fit(get_data())
clf.fit(get_more_data())
将是API正确的用法.
但这里有一个问题.
正如文档所说:
When set to True, reuse the solution of the previous call to fit and add more estimators to the ensemble, otherwise, just fit a whole new forest.
这意味着,warm_start唯一可以为你做的就是添加新的DecisionTree.所有以前的树木似乎都没有受到影响!
n_more_estimators = self.n_estimators - len(self.estimators_)
if n_more_estimators < 0:
raise ValueError('n_estimators=%d must be larger or equal to '
'len(estimators_)=%d when warm_start==True'
% (self.n_estimators, len(self.estimators_)))
elif n_more_estimators == 0:
warn("Warm-start fitting without increasing n_estimators does not "
"fit new trees.")
这基本上告诉我们,在接近新的合适之前,您需要增加估算器的数量!
我不知道sklearn在这里的用途是什么.我不确定,如果适合,增加内部变量和再次拟合是正确的用法,但我不知何故怀疑它(特别是因为n_estimators不是公共类变量).
你的基本方法(关于这个库和这个分类器)对你的核心学习可能不是一个好主意!我不会进一步追求这一点.