Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for SVC fit_proba not using class weights #5912

Merged
merged 7 commits into from
Jun 15, 2024
10 changes: 8 additions & 2 deletions python/cuml/svm/svc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class SVC(SVMBase,
self._fit_status_ = 0
return self

def _fit_proba(self, X, y, samle_weight) -> "SVC":
def _fit_proba(self, X, y, sample_weight) -> "SVC":
params = self.get_params()
params["probability"] = False

Expand All @@ -460,8 +460,14 @@ class SVC(SVMBase,
cv=5,
method='sigmoid')

# Apply class weights to sample weights, necessary so it doesn't crash when sample_weight is None
# could also be done in .fit()
sample_weight = apply_class_weight(self.handle, sample_weight, self.class_weight, y, self.verbose,
self.output_type, self.dtype)

with cuml.internals.exit_internal_api():
self.prob_svc.fit(X, y)
# .get() is necessary because sklearn requires explicit conversion to np array
self.prob_svc.fit(X, y, sample_weight=sample_weight.get())
pablotanner marked this conversation as resolved.
Show resolved Hide resolved
self._fit_status_ = 0
return self

Expand Down
Loading