使用sci-kit learn时如何修复这个"line_search_wolfe2"错误?



在尝试运行实现Sci-Kit Learn的Python脚本时出现错误。下面是我的代码:

import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn import svm
digits = datasets.load_digits()
print (digits.data)
print (digits.target)
print (digits.images[0])
clf = svm.SVC(gamma=0.001, C=100)
x, y = digits.data[:-1], digits.target[:-1]

下面是我在运行"python scidigits.py"时得到的错误在我的终端:

Traceback (most recent call last):
  File "Practice.py", line 6, in <module>
    from sklearn import svm
  File "/home/jdoe/.local/lib/python2.6/site-packages/sklearn/svm/__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC, 
  File "/home/jdoe/.local/lib/python2.6/site-packages/sklearn/svm/classes.py", line 6, in <module>
from ..linear_model.base import LinearClassifierMixin, SparseCoefMixin, 
  File "/home/jdoe/.local/lib/python2.6/site-packages/sklearn/linear_model/__init__.py", line 25, in <module>
from .logistic import (LogisticRegression, LogisticRegressionCV,
  File "/home/jdoe/.local/lib/python2.6/site-packages/sklearn/linear_model/logistic.py", line 25, in <module>
from ..utils.optimize import newton_cg
  File "/home/jdoe/.local/lib/python2.6/site-packages/sklearn/utils/optimize.py", line 18, in <module>
from scipy.optimize.linesearch import line_search_wolfe2, line_search_wolfe1
ImportError: cannot import name line_search_wolfe2
谁能解释一下这个问题?

我猜这是版本/弃用问题。

所以你应该更新你的scikit-learn包

相关内容

  • 没有找到相关文章

最新更新