I want to score load_wine on SVC, but I get an error.

Asked 2 years ago, Updated 2 years ago, 76 views

It's still before scale conversion, but I don't understand why the error occurs.

 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, strictify=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))

No matter how many times I try, I get this kind of error.Anyone who knows, please.

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

python3 machine-learning

2022-09-30 15:43

1 Answers

There is no problem with the code, but there is an error when sklearn calls numpy in from sklearn.datasets import load_wine in the first line.This means that there is a problem with the sklearn and numpy packages.

sklearn is a package written with Cython to speed up the process, so it is likely that the binary compatibility problem occurred because the sklearn and numpy were compiled using different compilers and libraries.

numpy may be compiled to use Intel's MKL or Intel's Python for acceleration, but sklearn must be compiled in the same way.


2022-09-30 15:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.