尝试运行实现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
请问有人可以解释这个问题吗?
答案 0 :(得分:0)
我想这是版本/弃用问题。
所以你应该更新你的scikit-learn包。