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] Expose ObjectiveFunction class #6586

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

neNasko1
Copy link
Contributor

@neNasko1 neNasko1 commented Aug 1, 2024

Provides a way to invoke the builtin functions outside of training. Implements access to gradient computations and output conversion methods.

This is a minimal implementation of #6585.

@neNasko1
Copy link
Contributor Author

neNasko1 commented Aug 5, 2024

@jameslamb, I'm reaching out to you as I noticed that you've tagged this as 'in progress'. I would appreciate it if you could share your thoughts on this change and its relevance to the project. If there is anything more to be done for this PR, I will be happy to contribute further.

@jameslamb
Copy link
Collaborator

You will have to be patient with us... there is a small group of mostly-volunteer maintainers overseeing this project.

This is quite a significant PR, as it greatly expands the public API of the Python package and the C API. It will be a while before I personally am able to provide a thoughtful review. Maybe others like @shiyu1994 or @guolinke will be able to help.

],
)
@pytest.mark.parametrize("num_boost_round", [5, 15])
@pytest.mark.skipif(getenv("TASK", "") == "cuda", reason="Skip due to ObjectiveFunction not exposed for cuda devices.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why couldn't this also be exposed for the CUDA implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It segfaults on the CI tests, and I cannot build the CUDA version on MacOS.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Where exactly does it segfault? 🤔 it seems like this should work 😅

@neNasko1
Copy link
Contributor Author

neNasko1 commented Aug 5, 2024

You will have to be patient with us... there is a small group of mostly-volunteer maintainers overseeing this project.

Thank you for the response and sorry for the over-eagerness. I was just opening the door to discussion.

@jameslamb
Copy link
Collaborator

No problem, we're happy to have you here contributing!

In the interim, you might also consider picking up something smaller and more contained, like #6361. Once you have 1 commit merged to master, you'll then no longer be considered "new" contributor and you won't have to wait for one of us to manually trigger CI on every push.

@neNasko1 neNasko1 changed the title Expose ObjectiveFunction class to the Python API [python-package] Expose ObjectiveFunction class Aug 16, 2024
Copy link
Collaborator

@borchero borchero left a comment

Choose a reason for hiding this comment

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

Thanks! This looks very promising already :)

include/LightGBM/objective_function.h Show resolved Hide resolved
include/LightGBM/objective_function.h Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
],
)
@pytest.mark.parametrize("num_boost_round", [5, 15])
@pytest.mark.skipif(getenv("TASK", "") == "cuda", reason="Skip due to ObjectiveFunction not exposed for cuda devices.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where exactly does it segfault? 🤔 it seems like this should work 😅

tests/python_package_test/utils.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Show resolved Hide resolved
@StrikerRUS
Copy link
Collaborator

@neNasko1 Please add ObjectiveFunction class to the https://github.com/microsoft/LightGBM/blob/master/docs/Python-API.rst#data-structure-api and some usage example to the https://github.com/microsoft/LightGBM/tree/master/examples/python-guide with the aim to

... add some documentation on how this class should be used

as it was suggested by @borchero .

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

Successfully merging this pull request may close these issues.

4 participants