为什么创建自定义sklearn估算器分数会下降?

时间:2019-10-07 07:25:11

标签: python scikit-learn

from sklearn.base import BaseEstimator
class random(BaseEstimator):
    def __init__(self):
        self.model=xgboost.XGBClassifier()
    def fit(self,x,y):
        self.model.fit(x,y)
        return self.model
    def predict(self,x):
        return self.model.predict(x)
rfc=random()
val=cross_val_score(rfc,train_x_array[:,x.astype(bool)],train_y_array,scoring='accuracy',cv=10,n_jobs=-1)
val.mean()
  

0.7609086695594499

得分下降?

val=cross_val_score(xgboost.XGBClassifier(),train_x_array[:,x.astype(bool)],train_y_array,scoring='accuracy',cv=10,n_jobs=-1)
val.mean()
  

0.8668378762815749

是BaseEstimator的问题吗?

0 个答案:

没有答案