README.md 1.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Python Package Example
=====================
Here is an example for LightGBM to use python package.

***You should install lightgbm (both c++ and python verion) first.***

For the installation, check the wiki [here](https://github.com/Microsoft/LightGBM/wiki/Installation-Guide).

You also need scikit-learn and pandas to run the examples, but they are not required for the package itself. You can install them with pip:
```
pip install -U scikit-learn
pip install -U pandas
```

Now you can run examples in this folder, for example:
```
python simple_example.py
```
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Examples including:
- [simple_example.py](https://github.com/Microsoft/LightGBM/blob/master/examples/python-guide/simple_example.py)
    - Construct Dataset
    - Basic train and predict
    - Eval during training 
    - Early stopping
    - Save model to file
    - Dump model to json format
    - Feature importances
- [sklearn_example.py](https://github.com/Microsoft/LightGBM/blob/master/examples/python-guide/sklearn_example.py)
    - Basic train and predict with sklearn interface
    - Feature importances with sklearn interface
- [advanced_example.py](https://github.com/Microsoft/LightGBM/blob/master/examples/python-guide/advanced_example.py)
    - Set feature names
    - Directly use categorical features without one-hot encoding
    - Load model file to continue training
    - Change learning rates during training
    - Self-defined objective function
    - Self-defined eval metric
    - Callback function