-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Staged predict function as in scikit-learn #5031
Comments
Thanks for using LightGBM! I see the following description at the link you provided
Could you explain a bit more why you think LightGBM would benefit from adding this method to You can already achieve "determine error on testing set after each stage" by providing validation sets: import lightgbm as lgb
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
X, y = make_regression(n_samples=10_000, n_features=8, n_informative=5)
X_train, X_test, y_train, y_test = train_test_split(
X,
y,
test_size=0.1,
random_state=42
)
reg = lgb.LGBMRegressor(
num_boost_round=10,
metric=["l2", "mae", "mape"]
)
reg.fit(X_train, y_train, eval_set=[(X_test, y_test)])
# show metrics evaluated at each iteration
reg.evals_result_
And if you want to get the predictions at each iteration, LightGBM allows you to provide an iteration number to its various # examples: get models' predictions of the target from training data based on only the first 3 trees
reg.predict(X_train, num_iteration=2) |
Thanks for your answer. 1- 2-
I get that the predictions can be obtained using the num_iteration kwarg inside a for loop, but AFAIU, to get the whole prediction sequence, this quickly becomes inefficient as thee number of trees grow, and unusable for 100+ trees. |
Gentle ping @jameslamb, is there any update about the issue? |
@egemenzeytinci , save the prediction of each iteration could be a walkaround.
|
Sorry for the delay, this project is really struggling from a lack of maintainer availability at the moment. If this is something that's standard in If you're very interested in seeing this in LightGBM, the best way to make that happen soon is probably to contribute it yourself. If you're interested in attempting a pull request, we'd be happy to help with reviews and answers to any questions you have. |
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one. Thank you for taking the time to improve LightGBM! |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, this was locked accidentally. Just unlocked it. We'd still love help with this feature! |
In
scikit-learn
, thestaged_predict
function allows to see the regression targets at each stage. This is important because it allows to monitoring the model after each step. Here is the link for the function as I determined above: staged_predictAs far as I see, there is no implementation like this function in
LightGBM
for the each step.The text was updated successfully, but these errors were encountered: