Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions sklearnex/svm/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
from sklearn.utils.multiclass import check_classification_targets
from sklearn.utils.validation import check_is_fitted

if sklearn_check_version("1.8"):
from ..utils._array_api import get_namespace

def _prefit_CalibratedClassifierCV_fit(self, X, y, **fit_params):
# This is a stop-gap solution where the cv='prefit' of CalibratedClassifierCV
# was removed and the single fold solution needs to be maintained. Discussion
Expand All @@ -66,13 +69,24 @@ def _prefit_CalibratedClassifierCV_fit(self, X, y, **fit_params):
# Reshape binary output from `(n_samples,)` to `(n_samples, 1)`
predictions = predictions.reshape(-1, 1)

calibrated_classifier = _fit_calibrator(
estimator,
predictions,
y,
self.classes_,
self.method,
)
if sklearn_check_version("1.8"):
xp, _ = get_namespace(X, y)
calibrated_classifier = _fit_calibrator(
estimator,
predictions,
y,
self.classes_,
self.method,
xp,
)
else:
calibrated_classifier = _fit_calibrator(
estimator,
predictions,
y,
self.classes_,
self.method,
)
self.calibrated_classifiers_.append(calibrated_classifier)

first_clf = self.calibrated_classifiers_[0].estimator
Expand Down
Loading