README.rst 3.57 KB
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
LightGBM Python Package
=======================

Guolin Ke's avatar
Guolin Ke committed
4
5
6
|PyPI version|


Guolin Ke's avatar
Guolin Ke committed
7
8
9
Installation
------------

Guolin Ke's avatar
Guolin Ke committed
10
11
12
Preparation
'''''''''''

Guolin Ke's avatar
Guolin Ke committed
13
`setuptools <https://pypi.python.org/pypi/setuptools>`_ is needed. 
Guolin Ke's avatar
Guolin Ke committed
14
15
16
17
18
19
20
21

For Mac OS X users, gcc with OpenMP support must be installed first. Refer to `wiki <https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#osx>`_ for installing gcc with OpenMP support.

Note: 32-bit python is not supported. Please install 64-bit version.

Install from pip
''''''''''''''''

Guolin Ke's avatar
Guolin Ke committed
22
23
24
Install `wheel <http://pythonwheels.com>`_ via ``pip install wheel`` first. For windows user, `VC runtime <https://go.microsoft.com/fwlink/?LinkId=746572>`_ is needed if Visual Studio(2015 or 2017) is not installed.


Guolin Ke's avatar
Guolin Ke committed
25
26
``pip install lightgbm``

Guolin Ke's avatar
Guolin Ke committed
27
28
29

Install source package from pip
*******************************
Guolin Ke's avatar
Guolin Ke committed
30
31
32
33

``pip install --no-binary :all: lightgbm``


Guolin Ke's avatar
Guolin Ke committed
34
35
36
37
Note: Installation from source package require installing `cmake <https://cmake.org/>`_ first.

For Windows user, Visual Studio (or `MS Build <https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017>`_) is needed, and `cmake <https://cmake.org/>`_ must be version 3.8 or higher.

Guolin Ke's avatar
Guolin Ke committed
38
39
For OSX user, you need to run ```export CXX=g++-7 CC=gcc-7``` before running ```pip install ... ```.

Guolin Ke's avatar
Guolin Ke committed
40
Install GPU version:
41
42
43
44
45

``pip install lightgbm --install-option=--gpu``

Note: Boost and OpenCL are needed: details for installation can be found in `gpu-support <https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#with-gpu-support>`_. Need to add OpenCL_INCLUDE_DIR to PATH and export BOOST_ROOT before installation.

Guolin Ke's avatar
Guolin Ke committed
46
Install with MinGW on Windows:
47
48

``pip install lightgbm --install-option=--mingw``
Guolin Ke's avatar
Guolin Ke committed
49

Guolin Ke's avatar
Guolin Ke committed
50
51
Install from GitHub
'''''''''''''''''''
Guolin Ke's avatar
Guolin Ke committed
52

Guolin Ke's avatar
Guolin Ke committed
53
54
55
Installation from GitHub require installing `cmake <https://cmake.org/>`_ first. 

For Windows user, Visual Studio (or `MS Build <https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017>`_) is needed, and `cmake <https://cmake.org/>`_ must be version 3.8 or higher.
Guolin Ke's avatar
Guolin Ke committed
56

Guolin Ke's avatar
Guolin Ke committed
57
58
59
60
.. code:: sh

    git clone --recursive https://github.com/Microsoft/LightGBM
    cd LightGBM/python-package
Guolin Ke's avatar
Guolin Ke committed
61
    # export CXX=g++-7 CC=gcc-7 # for OSX
Guolin Ke's avatar
Guolin Ke committed
62
63
    python setup.py install

Guolin Ke's avatar
Guolin Ke committed
64
``sudo`` (or administrator rights in Windows) may is needed to perform ``python setup.py install``.
Guolin Ke's avatar
Guolin Ke committed
65
66
67

Use ``python setup.py install --mingw`` to use MinGW in Windows.

Guolin Ke's avatar
Guolin Ke committed
68
Use ``python setup.py install --gpu`` to enable GPU support. Boost and OpenCL are needed: details for installation can be found in `gpu-support <https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#with-gpu-support>`_.
Guolin Ke's avatar
Guolin Ke committed
69
70
71
72

Examples
--------

Guolin Ke's avatar
Guolin Ke committed
73
Refer to the walk through examples in `python-guide folder <https://github.com/Microsoft/LightGBM/tree/master/examples/python-guide>`_
wxchan's avatar
wxchan committed
74
75
76


Troubleshooting
Guolin Ke's avatar
Guolin Ke committed
77
---------------
wxchan's avatar
wxchan committed
78

Guolin Ke's avatar
Guolin Ke committed
79
Refer to `FAQ <https://github.com/Microsoft/LightGBM/tree/master/docs/FAQ.md>`_ 
wxchan's avatar
wxchan committed
80
81

Developments
Guolin Ke's avatar
Guolin Ke committed
82
------------
wxchan's avatar
wxchan committed
83

Guolin Ke's avatar
Guolin Ke committed
84
The code style of python package follows `pep8 <https://www.python.org/dev/peps/pep-0008/>`_. If you would like to make a contribution and not familiar with pep-8, please check the pep8 style guide first. Otherwise, the check won't pass. You should be careful about:
wxchan's avatar
wxchan committed
85

86
- E1 Indentation (check pep8 link above)
wxchan's avatar
wxchan committed
87
88
89
90
91
92
93
- E202 whitespace before and after brackets
- E225 missing whitespace around operator
- E226 missing whitespace around arithmetic operator
- E261 at least two spaces before inline comment
- E301 expected 1 blank line in front of and at the end of a method
- E302 expected 2 blank lines in front of and at the end of a function or a class

Guolin Ke's avatar
Guolin Ke committed
94
E501 can be ignored (line too long).
Guolin Ke's avatar
Guolin Ke committed
95
96
97

.. |PyPI version| image:: https://badge.fury.io/py/lightgbm.svg
    :target: https://badge.fury.io/py/lightgbm