简体   繁体   中英

How do I fix this “line_search_wolfe2” error when using sci-kit learn?

I am getting an error when trying to run a Python script that implements Sci-Kit Learn. Here is my code:

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]

And here is the error I get when running "python scidigits.py" in my terminal:

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

Could anybody please shed light on this issue?

I guess this is a version / deprecation problem.

So you should update your scikit-learn package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM