Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
89824a6c
Unverified
Commit
89824a6c
authored
Apr 20, 2024
by
Parsiad Azimzadeh
Committed by
GitHub
Apr 20, 2024
Browse files
[docs] document how to use a custom objective function via the C API (#6396)
parent
1ce23571
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
docs/Parameters.rst
docs/Parameters.rst
+8
-0
include/LightGBM/config.h
include/LightGBM/config.h
+4
-0
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+1
-0
No files found.
docs/Parameters.rst
View file @
89824a6c
...
@@ -123,6 +123,14 @@ Core Parameters
...
@@ -123,6 +123,14 @@ Core Parameters
- label should be ``int`` type, and larger number represents the higher relevance (e.g. 0:bad, 1:fair, 2:good, 3:perfect)
- label should be ``int`` type, and larger number represents the higher relevance (e.g. 0:bad, 1:fair, 2:good, 3:perfect)
- custom objective function (gradients and hessians not computed directly by LightGBM)
- ``custom``
- **Note**: Not supported in CLI version
- must be passed through parameters explicitly in the C API
- ``boosting`` :raw-html:`<a id="boosting" title="Permalink to this parameter" href="#boosting">🔗︎</a>`, default = ``gbdt``, type = enum, options: ``gbdt``, ``rf``, ``dart``, aliases: ``boosting_type``, ``boost``
- ``boosting`` :raw-html:`<a id="boosting" title="Permalink to this parameter" href="#boosting">🔗︎</a>`, default = ``gbdt``, type = enum, options: ``gbdt``, ``rf``, ``dart``, aliases: ``boosting_type``, ``boost``
- ``gbdt``, traditional Gradient Boosting Decision Tree, aliases: ``gbrt``
- ``gbdt``, traditional Gradient Boosting Decision Tree, aliases: ``gbrt``
...
...
include/LightGBM/config.h
View file @
89824a6c
...
@@ -158,6 +158,10 @@ struct Config {
...
@@ -158,6 +158,10 @@ struct Config {
// descl2 = ``rank_xendcg``, `XE_NDCG_MART <https://arxiv.org/abs/1911.09798>`__ ranking objective function, aliases: ``xendcg``, ``xe_ndcg``, ``xe_ndcg_mart``, ``xendcg_mart``
// descl2 = ``rank_xendcg``, `XE_NDCG_MART <https://arxiv.org/abs/1911.09798>`__ ranking objective function, aliases: ``xendcg``, ``xe_ndcg``, ``xe_ndcg_mart``, ``xendcg_mart``
// descl2 = ``rank_xendcg`` is faster than and achieves the similar performance as ``lambdarank``
// descl2 = ``rank_xendcg`` is faster than and achieves the similar performance as ``lambdarank``
// descl2 = label should be ``int`` type, and larger number represents the higher relevance (e.g. 0:bad, 1:fair, 2:good, 3:perfect)
// descl2 = label should be ``int`` type, and larger number represents the higher relevance (e.g. 0:bad, 1:fair, 2:good, 3:perfect)
// desc = custom objective function (gradients and hessians not computed directly by LightGBM)
// descl2 = ``custom``
// descl2 = **Note**: Not supported in CLI version
// descl2 = must be passed through parameters explicitly in the C API
std
::
string
objective
=
"regression"
;
std
::
string
objective
=
"regression"
;
// [no-automatically-extract]
// [no-automatically-extract]
...
...
src/boosting/gbdt.cpp
View file @
89824a6c
...
@@ -344,6 +344,7 @@ bool GBDT::TrainOneIter(const score_t* gradients, const score_t* hessians) {
...
@@ -344,6 +344,7 @@ bool GBDT::TrainOneIter(const score_t* gradients, const score_t* hessians) {
hessians
=
hessians_pointer_
;
hessians
=
hessians_pointer_
;
}
else
{
}
else
{
// use customized objective function
// use customized objective function
// the check below fails unless objective=custom is provided in the parameters on Booster creation
CHECK
(
objective_function_
==
nullptr
);
CHECK
(
objective_function_
==
nullptr
);
if
(
data_sample_strategy_
->
IsHessianChange
())
{
if
(
data_sample_strategy_
->
IsHessianChange
())
{
// need to copy customized gradients when using GOSS
// need to copy customized gradients when using GOSS
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment