Skip to content

Commit

Permalink
fix coef_prior
Browse files Browse the repository at this point in the history
  • Loading branch information
csinva committed Mar 12, 2024
1 parent f3b5420 commit d0cc967
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions imodels/algebraic/gam_multitask.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def __init__(
linear_penalty='ridge',
onehot_prior=False,
renormalize_features=False,
random_state=42,
use_internal_classifiers=False,
random_state=42,
):
"""
Params
Expand All @@ -54,6 +54,8 @@ def __init__(
one_hot_prior: bool
If True and multitask, the linear model will be fit with a prior that the ebm
features predicting the target should have coef 1
renormalize_features: bool
If True, renormalize the features before fitting the linear model
use_internal_classifiers: bool
whether to use internal classifiers (as opposed to regressors)
"""
Expand Down Expand Up @@ -176,7 +178,7 @@ def _fit_linear_model(self, feats, y, sample_weight):
lin_model.fit(feats, y, sample_weight=sample_weight)
else:
coef_prior_ = np.zeros((feats.shape[1], ))
coef_prior_[:-len(self.term_names_list_)] = 1
coef_prior_[:-len(self.term_names_list_[-1])] = 1
preds_prior = feats @ coef_prior_
residuals = y - preds_prior
lin_model.fit(feats, residuals, sample_weight=sample_weight)
Expand Down

0 comments on commit d0cc967

Please sign in to comment.