Questions tagged [lightgbm]

1

votes
0

answer
5

Views

LightGBM - sklearnAPI vs training and data structure API and lgb.cv vs gridsearchcv/randomisedsearchcv

What are the differences between the sklearnAPI(LGBMModel, LGBMClassifier etc) and default API(lgb.Dataset, lgb.cv, lgb.train) of lightgbm? Which one should I prefer using? Is it better to use lgb.cv or gridsearchcv/randomisedsearchcv of sklearn when using lightgbm?
Sift
5

votes
2

answer
1.9k

Views

lightgbm how to deal with No further splits with positive gain, best gain: -inf

how to deal with [Warning] No further splits with positive gain, best gain: -inf is there any parameters not suit?
ji jianye
7

votes
1

answer
4.7k

Views

Python: LightGBM cross validation. How to use lightgbm.cv for regression?

I want to do a cross validation for LightGBM model with lgb.Dataset and use early_stopping_rounds. The following approach works without a problem with XGBoost's xgboost.cv. I prefer not to use Scikit Learn's approach with GridSearchCV, because it doesn't support early stopping or lgb.Dataset. import...
Marius
4

votes
5

answer
4k

Views

Lightgbm OSError, Library not loaded

If I simply do: import lightgbm as lgb I'm getting python script.py Traceback (most recent call last): File "script.py", line 4, in import lightgbm as lgb File "/usr/local/lib/python2.7/site-packages/lightgbm/__init__.py", line 8, in from .basic import Booster, Dataset File "/usr/local/lib/python...
LampShade
1

votes
1

answer
3.8k

Views

Unable to import lightgbm after install

My operating system is macOS Sierra, 10.12.5, and I am using Anaconda and python 2.7. After install, and when I try: import lightgbm as lgb I got the following message: OSError Traceback (most recent call last) in () ----> 1 import lightgbm as lgb /Users/tenggao/an...
Mike Gao
1

votes
2

answer
1.4k

Views

Installing Lightgbm on Mac with OpenMP dependency

I'm new to python and would like to install lightgbm on my macbook. I did a pip install lightgbm and it said installation successful. However when I try to import that into my notebook I get the following error message: ../anaconda/envs/python3/lib/python3.6/ctypes/__init__.py in __init__(self, name...
H.Z.
3

votes
2

answer
4.1k

Views

Why ImportError: No module named lightgbm

My OS is Ubuntu, and I've followed the official installation guide to install lightgbm. However, when I import it, this error is raised: ImportError: No module named lightgbm How can I solve this? Do I also need to go to /python-package folder to run setup.py after running those linux commandlines?
Mark Krystal
1

votes
1

answer
1.6k

Views

f1_score metric in lightgbm

I want to train a lgb model with custom metric : f1_score with weighted average. I went through the advanced examples of lightgbm over here and found the implimentation of custom binary error function. I implemented as similiar functon to return f1_score as shown below. def f1_metric(preds, train_da...
Sreeram TP
2

votes
1

answer
430

Views

Load LightGBM/XGBoost model to sklearn

LightGBM and XGBoost models can be dumped to plain text files containing human-readable model structure. In the end, they are just tree ensembles. Is there any library to load these dumped models to the scikit-learn framework, e.g. construct sklearn ensembles with same splits and values? That could...
Denis Korzhenkov
2

votes
1

answer
648

Views

Disambiguating eval, obj (objective), and metric in LightGBM

I'm asking this in reference to the R library lightgbm but I think it applies equally to the Python and Multiverso versions. There are 3 parameters wherein you can choose statistics of interest for your model - metric, eval, and obj. I'm trying to clearly distinguish the different roles of these 3 i...
Hack-R
2

votes
1

answer
386

Views

How to set the frequency of metric output in lightGBM?

In the documents, it is said that we can set the parameter metric_freq to set the frequency. I have also tried the parameter verbose, the parameters are set as params = { 'task': 'train', 'boosting_type': 'gbdt', 'objective': 'binary', 'metric': { 'binary_logloss'}, 'metric_freq':10, 'num_leaves': 5...
Yu Gu
8

votes
3

answer
3.6k

Views

Cross-validation in LightGBM

After reading through LightGBM's documentation on cross-validation, I'm hoping this community can shed light on cross-validating results and improving our predictions using LightGBM. How are we supposed to use the dictionary output from lightgbm.cv to improve our predictions? Here's an example - we...
Nlind
2

votes
1

answer
358

Views

Why is the my plot_learning_curve of scikit learn not running faster on a google VM?

I am running a snippet that I borrowed from scikit-learn official website to plot the learning curve My code is pretty simple like following: import matplotlib.pyplot as plt from sklearn.model_selection import learning_curve from sklearn.model_selection import ShuffleSplit from sklearn.metrics impor...
Ghostintheshell
2

votes
0

answer
252

Views

Loading lightgbm model and using predict with parallel for loop freezes (Python)

I have the need to use my model to do predictions in batches and in parallel in python. If I load the model and create the data frames in a regular for loop and use the predict function it works with no issues. If I create disjoint data frames in parallel using multiprocessing in python and then use...
RDizzl3
0

votes
0

answer
2

Views

How Bagging in LightGBM works

In the lightGBM model, there are 2 parameters related to bagging bagging_fraction bagging_freq (frequency for bagging 0 means disable bagging; k means perform bagging at every k iteration Note: to enable bagging, bagging_fraction should be set to value smaller than 1.0 as well) I could find some m...
Kid
2

votes
1

answer
1.2k

Views

Grid search with LightGBM example

I am trying to find the best parameters for a lightgbm model using GridSearchCV from sklearn.model_selection. I have not been able to find a solution that actually works. I have managed to set up a partly working code: import numpy as np import pandas as pd import lightgbm as lgb from sklearn.model_...
bhaskarc
3

votes
2

answer
802

Views

LightGBM: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I was running lightgbm with categorical features: X_train, X_test, y_train, y_test = train_test_split(train_X, train_y, test_size=0.3) train_data = lgb.Dataset(X_train, label=y_train, feature_name=X_train.columns, categorical_feature=cat_features) test_data = lgb.Dataset(X_test, label=y_train, refe...
MJeremy
2

votes
1

answer
407

Views

How to write custom F1 score metric in light gbm python in Multiclass classification

Can someone help me how to write custom F1 score for multiclass classification in python??? Edit: I'm editing the question to give a better picture of what I want to do This is my function for a custom eval f1 score metric for multiclass problem with 5 classes. def evalerror(preds, dtrain): labels =...
Thanish
3

votes
3

answer
5.5k

Views

Multiclass Classification with LightGBM

I am trying to model a classifier for a multi-class Classification problem (3 Classes) using LightGBM in Python. I used the following parameters. params = {'task': 'train', 'boosting_type': 'gbdt', 'objective': 'multiclass', 'num_class':3, 'metric': 'multi_logloss', 'learning_rate': 0.002296, 'max_d...
Sreeram TP
2

votes
1

answer
305

Views

Accessing LightGBM model parameters

Sometimes I save a LightGBM model and later, upon reloading it, want to access some details about how the model was built. Is there a way to recover the fact that objective = "regression", for example? For convenience, here is brief code to play with: library(lightgbm) data(agaricus.train, package =...
zkurtz
5

votes
2

answer
3.8k

Views

Python - LightGBM with GridSearchCV, is running forever

Recently, I am doing multiple experiments to compare Python XgBoost and LightGBM. It seems that this LightGBM is a new algorithm that people say it works better than XGBoost in both speed and accuracy. This is LightGBM GitHub. This is LightGBM python API documents, here you will find python function...
Cherry Wu
2

votes
0

answer
338

Views

GridSearch LightGBM with GPU

How do you use a GPU to do GridSearch with LightGBM? If you just want to train a lgb model with default parameters, you can do: dataset = lgb.Dataset(X_train, y_train) lgb.train({'device': 'gpu'}, dataset) To do GridSearch, it would be great to do something like this: lgbm_classifier = lgb.LGBMClass...
tgordon18
2

votes
1

answer
128

Views

light gbm - python API vs Scikit-learn API

I was trying to apply lgbm in one of my problems. For that I was going through "http://lightgbm.readthedocs.io/en/latest/Python-API.html". However, I have a basic question. Is there any difference between Training API and Scikit-learn API? Can we use both the APIs to achieve same result for the sam...
DIPANJAN MITRA
3

votes
0

answer
182

Views

using lightgbm with average precision recall score

I am using LightGBM and would like to use average precision recall as a metric. I tried defining feval: cv_result = lgb.cv(params=params, train_set=lgb_train, feature_name=Rel_Feat_Names, feval=APS) where APS defined as: def APS(preds, train_data): y_pred_val = [] y_test_val = [] for i, stat in enum...
Yochai Edlitz
2

votes
2

answer
686

Views

Sentiment Analysis with Imbalanced Dataset in LightGBM

I am trying to perform sentiment analysis on a dataset of 2 classes (Binary Classification). Dataset is heavily imbalanced about 70% - 30%. I am using LightGBM and Python 3.6 for making the model and predicting the output. I think imbalance in dataset effect performance of my model. I get about 90%...
Sreeram TP
2

votes
2

answer
731

Views

During installation of lightgbm it says that you should install cmake first, while I have installed it

I want to install the GPU version of lightgbm on Ubuntu, based on the following command: pip install lightgbm --install-option=--gpu During installation, an error is occurred saying "Please install CMake first". After installing CMake, I get the same error again. To be sure that CMake is installed,...
Hossein
3

votes
1

answer
508

Views

High AUC but bad predictions with imbalanced data

I am trying to build a classifier with LightGBM on a very imbalanced dataset. Imbalance is in the ratio 97:3, i.e.: Class 0 0.970691 1 0.029309 Params I used and the code for training is as shown below. lgb_params = { 'boosting_type': 'gbdt', 'objective': 'binary', 'metric':'auc', 'learning_r...
Sreeram TP