stanfordmlgroup / ngboost

Natural Gradient Boosting for Probabilistic Prediction
Apache License 2.0
1.63k stars 214 forks source link

Add set_params for sklearn compatibility. #284

Closed jckkvs closed 1 year ago

jckkvs commented 2 years ago

Add set_params, get_params for sklearn compatibility. This change makes it easier to use with optimization libraries such as optuna or GridSearchCV. https://scikit-learn.org/stable/modules/generated/sklearn.base.BaseEstimator.html

Here is the pseudo code.

model = NGBoost(Base=default_tree_learner, Dist=Normal, natural_gradient=True, verbose=False)
def objective(trial):
    return something

study = optuna.create_study()
study.optimize(objective, n_trials=10)
model.set_params(study.best_params)
ryan-wolbeck commented 2 years ago

@jckkvs It's still failing, I tried to push but I'd need permissions on the fork you have. You'll still need to run black for this to pass so, black ngboost/ngboost.py should do it.

jckkvs commented 2 years ago

@ryan-wolbeck I applied black to ngboost.py

ryan-wolbeck commented 2 years ago

@jckkvs can you pull/merge the current version of master into this PR? It should fix the f-string issue, @robertsont pushed a fix in that with the version bump https://github.com/stanfordmlgroup/ngboost/pull/286/files. So pulling master should make this PR pass

ryan-wolbeck commented 2 years ago

bumping this @jckkvs, is this clear or do you need additional support?

ryan-wolbeck commented 1 year ago

@jckkvs can you make the required updates here? I'll be closing this next week if it doesn't get resolved and pushing fixes on my own.

ryan-wolbeck commented 1 year ago

implemented and released in another PR