Skip to content

Commit 915befa

Browse files
authored
Merge pull request #922 from Kaggle/upgrade-lightgbm
Upgrade LightGBM to v3.1.1
2 parents 226be97 + 702d5ac commit 915befa

File tree

7 files changed

+220
-7
lines changed

7 files changed

+220
-7
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ RUN apt-get install -y libfreetype6-dev && \
7979
pip install wordcloud && \
8080
pip install xgboost && \
8181
# Pinned to match GPU version. Update version together.
82-
pip install lightgbm==2.3.1 && \
82+
pip install lightgbm==3.1.1 && \
8383
pip install keras && \
8484
pip install keras-tuner && \
8585
pip install flake8 && \

gpu.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ RUN pip uninstall -y lightgbm && \
6969
cd /usr/local/src && \
7070
git clone --recursive https://github.com/microsoft/LightGBM && \
7171
cd LightGBM && \
72-
git checkout tags/v2.3.1 && \
72+
git checkout tags/v3.1.1 && \
7373
mkdir build && cd build && \
7474
cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ .. && \
7575
make -j$(nproc) && \

tests/data/lgb_test.bin

-1.49 KB
Binary file not shown.

tests/data/lgb_test.csv

Lines changed: 100 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/lgb_train.bin

-1.86 KB
Binary file not shown.

tests/data/lgb_train.csv

Lines changed: 100 additions & 0 deletions
Large diffs are not rendered by default.

tests/test_lightgbm.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import unittest
22

33
import lightgbm as lgb
4+
import pandas as pd
45

56
from common import gpu_test
67

78
class TestLightgbm(unittest.TestCase):
89
# Based on the "simple_example" from their documentation:
910
# https://github.com/Microsoft/LightGBM/blob/master/examples/python-guide/simple_example.py
1011
def test_cpu(self):
11-
lgb_train = lgb.Dataset('/input/tests/data/lgb_train.bin')
12-
lgb_eval = lgb.Dataset('/input/tests/data/lgb_test.bin', reference=lgb_train)
12+
lgb_train, lgb_eval = self.load_datasets()
1313

1414
params = {
1515
'task': 'train',
@@ -35,9 +35,8 @@ def test_cpu(self):
3535

3636
@gpu_test
3737
def test_gpu(self):
38-
lgb_train = lgb.Dataset('/input/tests/data/lgb_train.bin')
39-
lgb_eval = lgb.Dataset('/input/tests/data/lgb_test.bin', reference=lgb_train)
40-
38+
lgb_train, lgb_eval = self.load_datasets()
39+
4140
params = {
4241
'boosting_type': 'gbdt',
4342
'objective': 'regression',
@@ -59,3 +58,17 @@ def test_gpu(self):
5958
early_stopping_rounds=1)
6059

6160
self.assertEqual(1, gbm.best_iteration)
61+
62+
def load_datasets(self):
63+
df_train = pd.read_csv('/input/tests/data/lgb_train.csv', header=None, sep='\t')
64+
df_test = pd.read_csv('/input/tests/data/lgb_test.csv', header=None, sep='\t')
65+
66+
y_train = df_train[0]
67+
y_test = df_test[0]
68+
X_train = df_train.drop(0, axis=1)
69+
X_test = df_test.drop(0, axis=1)
70+
71+
lgb_train = lgb.Dataset(X_train, y_train)
72+
lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_train)
73+
74+
return (lgb_train, lgb_eval)

0 commit comments

Comments
 (0)