首页 > 解决方案 > sktime 错误无法从“sklearn.utils.fixes”导入名称“_take_along_axis”

问题描述

当我尝试使用 sktime 文档中的示例时出现此错误。

MWE

from sktime.datasets import load_airline
from sktime.forecasting.model_selection import (
     ExpandingWindowSplitter,
     ForecastingGridSearchCV,
     ExpandingWindowSplitter)
from sktime.forecasting.naive import NaiveForecaster


y = load_airline()
fh = [1,2,3]
cv = ExpandingWindowSplitter(
     start_with_window=True,
     fh=fh)
forecaster = NaiveForecaster()
param_grid = {"strategy" : ["last", "mean", "drift"]}
gscv = ForecastingGridSearchCV(
     forecaster=forecaster,
     param_grid=param_grid,
     cv=cv)
gscv.fit(y)
y_pred = gscv.predict(fh)

我得到的错误是这样的:

cannot import name '_take_along_axis' from 'sklearn.utils.fixes' (/Users/xxxxx/opt/anaconda3/envs/Spyder_env/lib/python3.8/site-packages/sklearn/utils/fixes.py)

有关如何处理此错误的任何想法?

我尝试卸载然后再次安装 sklean 和 scikit-learn 但没有工作。

标签: python-3.xsktime

解决方案


推荐阅读