You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

sktime与pycaret兼容报错:AttributeError: 'NoneType'无copy属性

问题求助:PyCaret适配最新sktime版本时出现AttributeError错误

我正在给PyCaret提交PR以支持最新版sktime,但遇到无法解决的AttributeError: 'NoneType' object has no attribute 'copy'错误,联系PyCaret和sktime官方团队暂未得到回复,特来寻求帮助。

报错场景

测试用例为test_pipeline_works_exo[ets],核心代码逻辑如下:

@pytest.mark.parametrize("model_name", _model_names_for_missing_data)
def test_pipeline_works_exo(load_uni_exo_data_target_missing, model_name):
    """Tests that the pipeline works for various operations for Univariate
    forecasting with exogenous variables"""
    data, target = load_uni_exo_data_target_missing

    exp = TSForecastingExperiment()
    FH = 12
    exp.setup(
        data=data,
        target=target,
        fh=FH,
        numeric_imputation_target="drift",
        numeric_imputation_exogenous="drift",
        enforce_exogenous=False,
    )

    assert exp.get_config("y").isna().sum() > 0
    assert exp.get_config("X").isna().sum().sum() > 0
    assert exp.get_config("y_transformed").isna().sum() == 0
    assert exp.get_config("X_transformed").isna().sum().sum() == 0

    model = exp.create_model(model_name)
    preds = exp.predict_model(model)  # 报错发生在此行

完整报错栈

_______________________ test_pipeline_works_exo[ets] _________________________

load_uni_exo_data_target_missing = (     Consumption    Income  Production   Savings  Unemployment
0       0.615986  0.972261   -2.452700  4.810312      ...01          -0.1
186     0.729598  0.644701    0.474918 -0.572858           0.0

[187 rows x 5 columns], 'Consumption')
model_name = 'ets'

   @pytest.mark.parametrize("model_name", _model_names_for_missing_data)
   def test_pipeline_works_exo(load_uni_exo_data_target_missing, model_name):
       """Tests that the pipeline works for various operations for Univariate
       forecasting with exogenous variables"""
       data, target = load_uni_exo_data_target_missing

       exp = TSForecastingExperiment()
       FH = 12
       exp.setup(
           data=data,
           target=target,
           fh=FH,
           numeric_imputation_target="drift",
           numeric_imputation_exogenous="drift",
           enforce_exogenous=False,
       )

       assert exp.get_config("y").isna().sum() > 0
       assert exp.get_config("X").isna().sum().sum() > 0
       assert exp.get_config("y_transformed").isna().sum() == 0
       assert exp.get_config("X_transformed").isna().sum().sum() == 0

       model = exp.create_model(model_name)
>       preds = exp.predict_model(model)

c:\Users\celes\pycaret\tests\test_time_series_preprocess.py:342: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\Users\celes\pycaret\pycaret\time_series\forecasting\oop.py:4576: in predict_model
   result = get_predictions_with_intervals(
c:\Users\celes\pycaret\pycaret\utils\time_series\forecasting\__init__.py:110: in get_predictions_with_intervals
   y_pred = forecaster.predict(fh=fh, X=X)
c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\forecasting\base\_base.py:448: in predict
   y_pred = self._predict(fh=fh, X=X_inner)
c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\forecasting\compose\_pipeline.py:533: in _predict
   X = self._transform(X=X, y=fh)
c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\forecasting\compose\_pipeline.py:705: in _transform
   X = transformer.transform(X=X, y=y)
c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\transformations\base.py:612: in transform
   Xt = self._transform(X=X_inner, y=y_inner)
c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\transformations\compose\_pipeline.py:313: in _transform
   Xt = transformer.transform(X=Xt, y=y)
c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\transformations\base.py:612: in transform
   Xt = self._transform(X=X_inner, y=y_inner)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = Imputer(random_state=1797), X = None, y = None

   def _transform(self, X, y=None):
       """Transform X and return a transformed version.

       private _transform containing the core logic, called from transform

       Parameters
       ----------
       X : pd.Series or pd.DataFrame
           Data to be transformed
       y : ignored argument for interface compatibility
           Additional data, e.g., labels for transformation

       Returns
       -------
       X : pd.Series or pd.DataFrame, same type as X
           transformed version of X
       """
>       X = X.copy()
E       AttributeError: 'NoneType' object has no attribute 'copy'

c:\Users\celes\pycaret\.venv\Lib\site-packages\sktime\transformations\series\impute.py:217: AttributeError

内容的提问来源于stack exchange,提问作者CelestinoXP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 13:32:09