我使用的模型訓練的一組數據的分類與1000次迭代:蟒蛇sklearn GradientBoostingClassifier熱啓動錯誤
clf = GradientBoostingClassifier(n_estimators=1000, learning_rate=0.05, subsample=0.1, max_depth=3)
clf.fit(X, y, sample_weight=train_weight)
現在我想增加迭代次數至2000所以我:
clf.set_params(n_estimators=2000, warm_start=True)
clf.fit(X, y, sample_weight=train_weight)
,但我得到了以下錯誤:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-13-49cfdfd6c024> in <module>()
1 start = time.clock()
2 clf.set_params(n_estimators=2000, warm_start=True)
----> 3 clf.fit(X, y, sample_weight=train_weight)
4 ...
C:\Anaconda3\lib\site-packages\sklearn\ensemble\gradient_boosting.py in fit(self, X, y, sample_weight, monitor)
1002 self.estimators_.shape[0]))
1003 begin_at_stage = self.estimators_.shape[0]
-> 1004 y_pred = self._decision_function(X)
1005 self._resize_state()
1006
C:\Anaconda3\lib\site-packages\sklearn\ensemble\gradient_boosting.py in _decision_function(self, X)
1120 # not doing input validation.
1121 score = self._init_decision_function(X)
-> 1122 predict_stages(self.estimators_, X, self.learning_rate, score)
1123 return score
1124
sklearn/ensemble/_gradient_boosting.pyx in sklearn.ensemble._gradient_boosting.predict_stages (sklearn\ensemble\_gradient_boosting.c:2564)()
ValueError: ndarray is not C-contiguous
什麼我錯在這裏做什麼?
然後參數'warm_start'的用途是什麼?我認爲這就是它的原因。 – breezymri
剛剛看到你的'set_params'調用。如果您獲得更多培訓數據,我認爲目的是更新現有的分類器。 –
是的,warm_start是更多的訓練數據/更新舊的解決方案,但不改變其結構 – lejlot