相关疑难解决方法(0)

自定义sklearn管道转换器,提供“ pickle.PicklingError”

我正在尝试根据本教程的指导为Python sklearn管道创建自定义转换器:http ://danielhnyk.cz/creating-your-own-estimator-scikit-learn/

现在,我的自定义类/变压器看起来像这样:

class SelectBestPercFeats(BaseEstimator, TransformerMixin):
    def __init__(self, model=RandomForestRegressor(), percent=0.8,
                 random_state=52):
        self.model = model
        self.percent = percent
        self.random_state = random_state


    def fit(self, X, y, **fit_params):
        """
        Find features with best predictive power for the model, and
        have cumulative importance value less than self.percent
        """
        # Check parameters
        if not isinstance(self.percent, float):
            print("SelectBestPercFeats.percent is not a float, it should be...")
        elif not isinstance(self.random_state, int):
            print("SelectBestPercFeats.random_state is not a int, it should be...")

        # If checks are good proceed with …
Run Code Online (Sandbox Code Playgroud)

python customization pipeline pickle scikit-learn

4
推荐指数
1
解决办法
2408
查看次数

标签 统计

customization ×1

pickle ×1

pipeline ×1

python ×1

scikit-learn ×1