Skip to main content
Communityユーザーがトップに表示した
Communityユーザーがトップに表示した
タイトルを編集
リンク
htb
  • 2,027
  • 3
  • 15
  • 35

python初心者です。SVC SVCでload_wineのスコアを出したいのですが、エラーが出てしまいます。

ソース リンク

python初心者です。SVCでload_wineのスコアを出したいのですが、エラーが出てしまいます。

まだスケール変換をする前ですが、エラーが出る意味がわかりません。

from sklearn.datasets import load_wine
from sklearn.svm import SVC
import numpy as np
from sklearn.model_selection import train_test_split

wine = load_wine()

X_train, X_test, y_train, y_test = \
    train_test_split(wine.data, wine.target, stratify=wine.target, 
random_state=42)
svc = SVC()
svc.fit(X_train, y_train)
print(svc.score(X_train, y_train))
print(svc.score(X_test, y_test))

何度やってもこのようなエラーが出てしまいます。どなたかわかる方お願いします。

Traceback (most recent call last):
  File "homework18.py", line 3, in <module>
    from sklearn.datasets import load_wine
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/sklearn/__init__.py", line 134, in <module>
    from .base import clone
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/sklearn/base.py", line 10, in <module>
    import numpy as np
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/core/__init__.py", line 35, in <module>
    from . import _internal  # for freeze programs
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/core/_internal.py", line 18, in <module>
    from .numerictypes import object_
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/core/numerictypes.py", line 297, in <module>
    _add_types()
  File "/Users/iwasakiyoshinobu/Desktop/lesson18/.venv/lib/python3.6/site-packages/numpy/core/numerictypes.py", line 290, in _add_types
    allTypes[name] = info.type
AttributeError: 'tuple' object has no attribute 'type'