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

Error when tuning NGBSurvival with GridSearchCV #270

Open
rhjohnstone opened this issue Jul 5, 2021 · 1 comment
Open

Error when tuning NGBSurvival with GridSearchCV #270

rhjohnstone opened this issue Jul 5, 2021 · 1 comment

Comments

@rhjohnstone
Copy link
Contributor

Minimal example:

from ngboost import NGBSurvival
import numpy.random as npr
from sklearn.model_selection import GridSearchCV

X = npr.randn(100, 5)
T = npr.rand(100)
E = npr.randint(2, size=100)

param_grid = {"learning_rate": [0.01, 0.1]}

ngb = NGBSurvival(n_estimators=50)

clf = GridSearchCV(ngb, param_grid=param_grid, cv=3)

clf.fit(X, fit_params={"T": T, "E": E})

(I'm not actually sure about the last line, since a standard sklearn estimator just takes (X, y) when fitting, but the current error occurs before that anyway.)

This raises the error
RuntimeError: Cannot clone object NGBSurvival(Dist=<class 'ngboost.distns.utils.SurvivalDistnClass<locals>.SurvivalDistn'>, n_estimators=50, random_state=RandomState(MT19937) at 0x7FA5683B1940), as the constructor either does not set or modifies parameter Dist

It does however work if I use NGBRegressor instead of NGBSurvival (and remove E).

Is there a way for me to fix this, or is this a problem with the NGBSurvival class? And if the latter, is it possible to fix?

@alejandroschuler
Copy link
Collaborator

Hmm, this is a problem with the way that NGBSurvival is implemented- specifically in the way that the abstractions for scores with and without survival data are designed. It's not an easy fix, unfortunately. I welcome suggestions, though. Related: #217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants