I'm trying to overcome some errors being thrown by the following snippet:
import os
from libsvm.svmutil import *
from scipy.io import loadmat
data = loadmat(os.path.join('Data','ex6data1.mat'))
X,y = data['X'],data['y'][:,0]
model = svm_train(y,X,'-s 0 -t 2 -c 0.2 -g 2.8')
print(model)
Which produces this error:
Traceback (most recent call last):
File "E:\Pythonlean\machine\venv\lib\site-packages\scipy\__init__.py", line 214, in __getattr__
return globals()[name]
KeyError: 'ctypeslib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Pythonlean\machine\Exercise6\test2.py", line 7, in <module>
model = svm_train(y,X,'-s 0 -t 2 -c 0.2 -g 2.8')
File "E:\Pythonlean\machine\venv\lib\site-packages\libsvm\svmutil.py", line 92, in svm_train
prob = svm_problem(y, x, isKernel=(param.kernel_type == PRECOMPUTED))
File "E:\Pythonlean\machine\venv\lib\site-packages\libsvm\svm.py", line 218, in __init__
scipy.ctypeslib.as_array(self.y, (self.l,))[:] = y
File "E:\Pythonlean\machine\venv\lib\site-packages\scipy\__init__.py", line 216, in __getattr__
raise AttributeError(
AttributeError: Module 'scipy' has no attribute 'ctypeslib'
All package versions:
libsvm-official(3.25.0)scipy(1.9.0)numpy(1.23.1)