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
Getting different results by turning on/off sklearnex with ExtraTrees and RandomForest algorithms.
This issue occurs starting with version 2024.1. I found it with my own dataset, and it's also reproducible with the breast_cancerdataset, but not with the iris dataset.
To Reproduce
Setup 'scikit-learn==1.5.1' (any version from 1.2.1)
Setup 'scikit-learn-intelex==2024.1' (any version from 2024.1)
Run the following test code:
import pandas as pd
from sklearnex import patch_sklearn
patch_sklearn()
from xgboost import XGBClassifier
from sklearn.ensemble import ExtraTreesClassifier, RandomForestClassifier
from sklearn.metrics import multilabel_confusion_matrix, confusion_matrix
from sklearn.model_selection import cross_val_predict, train_test_split
from sklearn.preprocessing import LabelEncoder, StandardScaler, label_binarize
from sklearn.metrics import matthews_corrcoef, confusion_matrix
N_CORES = 16
# Toy Data
from sklearn.datasets import load_iris,load_breast_cancer
data = load_breast_cancer()
X = data['data']
y = data['target']
X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.3, random_state=1)
# ExtraTrees
classifier_cv = ExtraTreesClassifier(n_estimators=300, random_state=1, n_jobs=N_CORES)
classifier_test = ExtraTreesClassifier(n_estimators=300, random_state=1, n_jobs=N_CORES)
cv_results = cross_val_predict(classifier_cv, X_train, y_train, cv=10)
classifier_test.fit(X_train, y_train)
test_results = classifier_test.predict(X_test)
print("###CV###")
print(matthews_corrcoef(y_train, cv_results))
print(confusion_matrix(y_train,cv_results).ravel())
print("###TEST###")
print(matthews_corrcoef(y_test, test_results))
print(confusion_matrix(y_test,test_results).ravel())
Expected behavior
Same results between using sklearnex and original sklearn.
Not sure whether it's related but if I use Intelex, I got a warning UserWarning: X does not have valid feature names, but ExtraTreesClassifier was fitted with feature names. Maybe there is a glitch in terms of handling the feature names or their orders by Intelex?
@YoochanMyung About the results not matching exactly between scikit-learn and scikit-learn-intelex: this is expectable - these are randomized algorithms, and scikit-learn-intelex uses different random number generators than scikit-learn that are more performant.
Apart from the generated random numbers, the implementation here also differs in other ways such as usage of histogram-based methods instead of sorting-based methods, so they won't match exactly down to the last decimal in the numbers that they output, but as you found out the evaluation metrics on the two results are very similar.
About the second issue - I'm unable to reproduce the problematic behavior. You should see that warning if the estimator is fitted to data with column names (such as a pandas DataFrame) and then it is used to predict on data without names (such as a NumPy array).
Are you able to provide a reproducible example where the warning would be issued in a situation in which it shouldn't?
Describe the bug
Getting different results by turning on/off sklearnex with ExtraTrees and RandomForest algorithms.
This issue occurs starting with version 2024.1. I found it with my own dataset, and it's also reproducible with the
breast_cancer
dataset, but not with theiris
dataset.To Reproduce
Expected behavior
Same results between using sklearnex and original sklearn.
Output/Screenshots
Before patching sklearnex with ExtraTrees
After patching sklearnex with ExtraTrees
Environment:
The text was updated successfully, but these errors were encountered: