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

[python-package] fix retrain on sequence dataset #6414

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
add test for seq_ds
eromoe committed Jul 15, 2024
commit 48f062caac777d55b5307789ff680cb298baea22
5 changes: 4 additions & 1 deletion tests/python_package_test/test_basic.py
Original file line number Diff line number Diff line change
@@ -223,6 +223,10 @@ def test_retrain_list_of_sequence():

seq_ds = lgb.Dataset(seqs, label=y, free_raw_data=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was free_raw_data=False necessary here? If it wasn't, please remove it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If free_raw_data=True, model2 cannot get the data, would raise Exception I remember .


assert sum([len(s) for s in seq_ds.get_data()]) == X.shape[0]
assert len(seq_ds.get_feature_name()) == X.shape[1]
assert seq_ds.get_data() == seqs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks should be moved after training, to avoid this test failure: https://github.com/microsoft/LightGBM/actions/runs/9935170010/job/27451324230?pr=6414

FAILED tests/python_package_test/test_basic.py::test_retrain_list_of_sequence - Exception: Cannot get data before construct Dataset

Please run the tests yourself before pushing another commit.

sh build-python.sh bdist_wheel install
pytest tests/python_package_tests/test_basic.py::test_retrain_list_of_sequence

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I only tested the code on jupyter notebook for this case.
Sorry I don't have env for sh , so can not build whell to run the pytest.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will push testing changes for you.


params = {
"objective": "binary",
"num_boost_round": 20,
@@ -249,7 +253,6 @@ def test_retrain_list_of_sequence():
assert model2.current_iteration() == 20
assert model2.num_trees() == 20

assert seq_ds.get_data() == seqs

def test_chunked_dataset():
X_train, X_test, y_train, y_test = train_test_split(