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(forest): use hparams in predict_proba #2181

Merged
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
15 changes: 12 additions & 3 deletions onedal/ensemble/forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def _predict(self, X, module, queue, hparams=None):
y = from_table(result.responses)
return y

def _predict_proba(self, X, module, queue):
def _predict_proba(self, X, module, queue, hparams=None):
_check_is_fitted(self)
X = _check_array(
X, dtype=[np.float64, np.float32], force_all_finite=True, accept_sparse=False
Expand All @@ -376,7 +376,11 @@ def _predict_proba(self, X, module, queue):
params["infer_mode"] = "class_probabilities"

model = self._onedal_model
result = module.infer(policy, params, model, to_table(X))
if hparams is not None and not hparams.is_default:
result = module.infer(policy, params, hparams.backend, model, to_table(X))
else:
result = module.infer(policy, params, model, to_table(X))

y = from_table(result.probabilities)
return y

Expand Down Expand Up @@ -472,8 +476,13 @@ def predict(self, X, queue=None):
return np.take(self.classes_, pred.ravel().astype(np.int64, casting="unsafe"))

def predict_proba(self, X, queue=None):
hparams = get_hyperparameters("decision_forest", "infer")

return super()._predict_proba(
X, self._get_backend("decision_forest", "classification", None), queue
X,
self._get_backend("decision_forest", "classification", None),
queue,
hparams,
)


Expand Down
Loading