You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The bug occurs if a single sample in sparse-matrix format is given to a SVM classifier. The prediction made by the SVM classifier differs from batch prediction, which gives the correct prediction. Furthermore, the problem occurs for both predict and predict_proba.
To Reproduce
The following code gives a minimal example:
from sklearnex import patch_sklearn
patch_sklearn()
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.svm import SVC
X = np.array(['hello world there', 'hello planet earth'])
y = np.array([1, 0])
test_1 = ['earth']
test_2 = ['earth', 'earth']
svm = SVC(probability=True)
vectorizer = TfidfVectorizer()
svm.fit(vectorizer.fit_transform(X), y)
print(svm.predict_proba(vectorizer.transform(test_1)))
print(svm.predict_proba(vectorizer.transform(test_2)))
Expected behavior
The output gives different results for the probabilities of a sample predicted alone versus predicted as batch. This is not correct, instead, the probabilities should be the same. The problem vanishes if sklearnex is disabled.
Output/Screenshots
This is the output of the minimal example:
Simon2496
changed the title
Wrong predictions for single-processing sparse-matrix input to SVC
Wrong predictions for single-prediction sparse-matrix input to SVC
Jun 19, 2024
Simon2496
changed the title
Wrong predictions for single-prediction sparse-matrix input to SVC
Wrong results for single-prediction sparse-matrix input to SVC
Jun 19, 2024
Thank you @Simon2496 for the report!
In order to reproduce the issues, please share the version of daal4py and scikit-learn-intelex and more details about your env.
Describe the bug
The bug occurs if a single sample in sparse-matrix format is given to a SVM classifier. The prediction made by the SVM classifier differs from batch prediction, which gives the correct prediction. Furthermore, the problem occurs for both
predict
andpredict_proba
.To Reproduce
The following code gives a minimal example:
Expected behavior
The output gives different results for the probabilities of a sample predicted alone versus predicted as batch. This is not correct, instead, the probabilities should be the same. The problem vanishes if sklearnex is disabled.
Output/Screenshots
This is the output of the minimal example:
The text was updated successfully, but these errors were encountered: