scikit-learn-intelex
scikit-learn-intelex copied to clipboard
SVM models trained with sparse matrix cannot be serialized (pickled)
Describe the bug SVC model trained with a scipy sparse matrix cannot be serialized (pickled).
To Reproduce
#!/usr/bin/env python
import sklearn.svm
from sklearn import datasets
import scipy.sparse
import pickle
X, y = datasets.load_iris(return_X_y=True)
## with numpy array
clf = sklearn.svm.SVC()
clf.fit(X, y)
## OK. no problem
s = pickle.dumps(clf)
## with Sparse matrix
X = scipy.sparse.csr_matrix(X)
clf = sklearn.svm.SVC()
clf.fit(X, y)
# Error
s = pickle.dumps(clf)
Traceback (most recent call last):
File "**.py", line 24, in <module>
s = pickle.dumps(clf)
ValueError: Object is not serializable
Environment:
- Intel distribution for Python 2022.2.0 (installed via dnf).
Hi @yappyjp Thanks for pointing out this issue. I'll check what could be the cause and get back as soon as I can
It appears that internal oneDAL model with sparse data usage is the reason.
Trying to serialize clf._onedal_estimator._onedal_model will fail with same error.
Same error without https://github.com/oneapi-src/oneDAL/pull/2122 fix will appear for any patched SVM model - NuSVC/NuSVR/SVC/SVR.
Hi! Is there any update on this one? I saw the PR is approved but not merged yet?
Hi @doganMemory, PR is waiting for additional approval and check
@Alexsandruss The above PR is merged it seems. When can it be merged into the intelex package?
@arijit-s - this have been released already - you can look for latest package on pypi/conda