LightGM Tools
Project description
LightGBM Tools
Usage
For a full example see here: https://github.com/telekom/lightgbm-tools/blob/main/examples/main_usage.py
Create own custom eval (metric) function:
from sklearn.metrics import balanced_accuracy_score
from lightgbm_tools.metrics import LightGbmEvalFunction
# create own custom eval (metric) function for balanced_accuracy_score
lgbm_balanced_accuracy = LightGbmEvalFunction(
name="balanced_accuracy",
function=balanced_accuracy_score,
is_higher_better=True,
needs_binary_predictions=True,
)
Create the callback function for LightGBM:
from lightgbm_tools.metrics import (
binary_eval_callback_factory,
lgbm_accuracy_score,
lgbm_average_precision_score,
lgbm_f1_score,
)
# use the factory function to create the callback
# add the predefined F1, accuracy and average precision metrics
# and the own custom eval (metric) function for balanced_accuracy_score
callback = binary_eval_callback_factory(
[lgbm_f1_score, lgbm_accuracy_score, lgbm_average_precision_score, lgbm_balanced_accuracy]
)
Use the callback:
import lightgbm as lgbm
bst = lgbm.train(
param,
train_data,
valid_sets=val_data,
num_boost_round=6,
verbose_eval=False,
evals_result=evals_result,
feval=callback, # here we pass the callback
)
Licensing
Copyright (c) 2022 Philip May, Deutsche Telekom AG
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License by reviewing the file LICENSE in the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lightgbm_tools-0.0.1rc2.tar.gz
.
File metadata
- Download URL: lightgbm_tools-0.0.1rc2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed2d352d0af904f7fe337ac32b32681144caface8b74588dd37b76b7fe1087cc |
|
MD5 | 92afedbce8092ef6a06d082d5d522fcb |
|
BLAKE2b-256 | ee0efc49705c7d1a10b6a01d84e375293354df5079278993c300415ce414f77c |
File details
Details for the file lightgbm_tools-0.0.1rc2-py3-none-any.whl
.
File metadata
- Download URL: lightgbm_tools-0.0.1rc2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60921d8e492418e0b26a39ae744cd423e7d51da6def06bd8ad827065933baf41 |
|
MD5 | de0290b8f3e585db44f288b4df4f2a7a |
|
BLAKE2b-256 | 27c3101b86fcdf0be2bdd616b289c9ad315bd93f2e533f7ca6569894eebac4ce |