pycaret.time_series.TSForecastingExperiment ImportError: cannot import name '_check_param_grid' from 'sklearn.model_selection._search'

pycaret.time_series.TSForecastingExperiment ImportError: cannot import name '_check_param_grid' from 'sklearn.model_selection._search'

我在数据块中导入 Pycaret 时间序列(测试版) 模块时出现以下错误(我们之前 运行 成功)。请求您帮助解决问题。

正在使用的 pycaret 版本:

import pycaret
pycaret.__version__  # Out[1]: '3.0.0'

python 正在使用的版本:

import sys
sys.version #Out[9]: '3.8.10 (default, Mar 15 2022, 12:22:08) \n[GCC 9.4.0]'

下面是问题的堆栈跟踪。

from pycaret.time_series import TSForecastingExperiment

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    160             # Import the desired module. If you’re seeing this while debugging a failed import,
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 
    164             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/pycaret/time_series/__init__.py in <module>
----> 1 from pycaret.time_series.forecasting.oop import TSForecastingExperiment
      2 from pycaret.time_series.forecasting.functional import (
      3     setup,
      4     create_model,
      5     compare_models,

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    160             # Import the desired module. If you’re seeing this while debugging a failed import,
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 
    164             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/pycaret/time_series/forecasting/oop.py in <module>
     14 from sklearn.base import clone
     15 from sktime.forecasting.base import ForecastingHorizon
---> 16 from sktime.forecasting.model_selection import (
     17     temporal_train_test_split,
     18     ExpandingWindowSplitter,

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    160             # Import the desired module. If you’re seeing this while debugging a failed import,
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 
    164             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/sktime/forecasting/model_selection/__init__.py in <module>
     20 from sktime.forecasting.model_selection._split import SlidingWindowSplitter
     21 from sktime.forecasting.model_selection._split import temporal_train_test_split
---> 22 from sktime.forecasting.model_selection._tune import ForecastingGridSearchCV
     23 from sktime.forecasting.model_selection._tune import ForecastingRandomizedSearchCV

/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py in import_patch(name, globals, locals, fromlist, level)
    160             # Import the desired module. If you’re seeing this while debugging a failed import,
    161             # look at preceding stack frames for relevant error information.
--> 162             original_result = python_builtin_import(name, globals, locals, fromlist, level)
    163 
    164             is_root_import = thread_local._nest_level == 1

/databricks/python/lib/python3.8/site-packages/sktime/forecasting/model_selection/_tune.py in <module>
     11 from sklearn.base import clone
     12 from sklearn.model_selection import ParameterGrid, ParameterSampler, check_cv
---> 13 from sklearn.model_selection._search import _check_param_grid
     14 from sklearn.utils.metaestimators import if_delegate_has_method

这是由于在 sktime 依赖项中使用了 sklearn 的私有方法。自从 sklearn 更新到 1.1.0,这个私有方法是 removed/moved,因此它被破坏了。 sktime 团队正在努力解决这个问题。同时,您可以通过强制安装 sklearn 1.0.2 来解决此问题。

请参阅 GitHub 回购中的详细信息:https://github.com/pycaret/pycaret/issues/2542