Граф коммитов

412 Коммитов

Автор SHA1 Сообщение Дата
Guolin Ke 87d46489f3
feature importance type in saved model file (#3220)
* feature importance type in saved model file

* fix nullptr

* fixed formatting

* fix python/R

* Update src/c_api.cpp

* Apply suggestions from code review

Co-authored-by: James Lamb <jaylamb20@gmail.com>

* fix c_api test

* fix swig

* minor docs improvements and added defines for importance types

Co-authored-by: StrikerRUS <nekit94-12@hotmail.com>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2020-07-15 22:18:53 +03:00
Germán Ramírez-Espinoza 7b8b51518c
[python][scikit-learn] Fixes a bug that prevented using multiple eval_metrics in LGBMClassifier (#3222)
* Fixes a bug that prevented using multiple eval_metrics in LGBMClassifier

* Move bug-fix test to the test_metrics unit-test

* Fix test to avoid issues with existing tests

* Fix coding-style error

Co-authored-by: German I Ramirez-Espinoza <gire@home>
2020-07-14 19:56:45 +03:00
Guolin Ke aef50f8614
[python] fix early_stopping_round = 0 (#3211)
* Update engine.py

* Update sklearn.py
2020-07-07 19:48:08 +03:00
Ilya Matiach 9f367d11ad
adding sparse support to TreeSHAP in lightgbm (#3000)
* adding sparse support to TreeSHAP in lightgbm

* updating based on comments

* updated based on comments, used fromiter instead of frombuffer

* updated based on comments

* fixed limits import order

* fix sparse feature contribs to work with more than int32 max rows

* really fixed int64 max error and build warnings

* added sparse test with >int32 max rows

* fixed python side reshape check on sparse data

* updated based on latest comments

* fixed comments

* added CSC INT32_MAX validation to test, fixed comments
2020-06-28 19:19:19 +03:00
Alex 7284946614
[python][scikit-learn] new stacking tests and make number of features a property (#3173)
* modify attribute and include stacking tests

* backwards compatibility

* check sklearn version

* move stacking import

* Number of input features (#3173)

* Number of input features (#3173)

* Number of input features (#3173)

* Number of input features (#3173)

Split number of features and stacking tests.

* Number of input features (#3173)

Modify test name.

* Number of input features (#3173)

Update stacking tests for review comments.

* Number of input features (#3173)

* Number of input features (#3173)

* Number of input features (#3173)

* Number of input features (#3173)

Modify classifier test.

* Number of input features (#3173)

* Number of input features (#3173)

Check score.
2020-06-27 21:26:13 +03:00
Belinda Trotta bca2da9728
Interaction constraints (#3126)
* Add interaction constraints functionality.

* Minor fixes.

* Minor fixes.

* Change lambda to function.

* Fix gpu bug, remove extra blank lines.

* Fix gpu bug.

* Fix style issues.

* Try to fix segfault on MACOS.

* Fix bug.

* Fix bug.

* Fix bugs.

* Change parameter format for R.

* Fix R style issues.

* Change string formatting code.

* Change docs to say R package not supported.

* Remove R functionality, moving to separate PR.

* Keep track of branch features in tree object.

* Only track branch features when feature interactions are enabled.

* Fix lint error.

* Update docs and simplify tests.
2020-06-23 16:39:48 +03:00
Nikita Titov fa2de89bb6
[docs][scikit-learn] removed duplicated docstrings (#3164)
* Revert "[ci][docs] temporarily pin Sphinx version (#3157)"

This reverts commit b3a84df5af.

* removed duplicated docstrings
2020-06-23 00:06:46 +03:00
Nikita Titov f30e0bb3d9
refactor LGBM_DatasetGetFeatureNames (#3022) 2020-06-11 03:05:01 +03:00
Alex a2a38b6cd5
[python][scikit-learn] add new attribute for used number of features (#3129)
* update number of features attribute

Fixes issue related to https://github.com/scikit-learn/scikit-learn/issues/17353 (see SLEP010 https://scikit-learn-enhancement-proposals.readthedocs.io/en/latest/slep010/proposal.html).

* Update sklearn.py

* set public attribute in fit method

Reverted ```n_features``` property, and inserted the public attribute ```n_features_in_```.

* Update documentation

* Update python-package/lightgbm/sklearn.py

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2020-06-02 21:09:58 +03:00
Guolin Ke dea2391b21
redirect log to python console (#3090)
* redir log to python console

* fix pylint

* Apply suggestions from code review

* Update basic.py

* Apply suggestions from code review

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>

* Update c_api.h

* Apply suggestions from code review

* Apply suggestions from code review

* super-minor: better wording

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: StrikerRUS <nekit94-12@hotmail.com>
2020-05-20 21:50:58 +03:00
Nikita Titov b60294b81d
removed deprecated code (#3073) 2020-05-12 04:47:04 +03:00
James Lamb 1b4cddfbb2
[python-package] Use set for OS check (#3059) 2020-05-09 14:22:53 +09:00
Nikita Titov 796ba80332
[docs] updated docs about output values (#3037) 2020-05-05 16:05:26 +03:00
Nikita Titov 6c19539e93
[python][ci] start to support Python 3.8 (#2713)
* start to support Python 3.8

* update configs

* hotfix
2020-04-14 01:08:15 +03:00
OMOTO Tsukasa 44a9120197
Support UTF-8 characters in feature name again (#2976)
* Support UTF-8 characters in feature name again

This commit reverts 0d59859c67.
Also see:
- https://github.com/microsoft/LightGBM/issues/2226
- https://github.com/microsoft/LightGBM/issues/2478
- https://github.com/microsoft/LightGBM/pull/2229

I reproduced the issue and as @kidotaka gave us a great survey in #2226,
I don't conclude that the cause is UTF-8, but "an empty string (character)".
Therefore, I revert "throw error when meet non ascii (#2229)" whose commit hash
is 0d59859c67, and add support feture names as UTF-8 again.

* add tests

* fix check-docs tests

* update

* fix tests

* update .travis.yml

* fix tests

* update test_r_package.sh

* update test_r_package.sh

* update test_r_package.sh

* add a test for R-package

* update test_r_package.sh

* update test_r_package.sh

* update test_r_package.sh

* fix test for R-package

* update test_r_package.sh

* update test_r_package.sh

* update test_r_package.sh

* update test_r_package.sh

* update

* updte

* update

* remove unneeded comments
2020-04-10 12:54:01 +09:00
Nikita Titov c633c6c2af
[python] Re-enable scikit-learn 0.22+ support (#2949)
* Revert "specify the last supported version of scikit-learn (#2637)"

This reverts commit d100277649.

* ban scikit-learn 0.22.0 and skip broken test

* fix updated test

* fix lint test

* Revert "fix lint test"

This reverts commit 8b4db0805f.
2020-04-10 12:53:21 +09:00
Alberto Ferreira 91185c3aa4
Fix SWIG methods that return char** (#2850)
* [swig] Fix SWIG methods that return char** with StringArray.

+ [new] Add StringArray class to manage and manipulate arrays of fixed-length strings:

  This class is now used to wrap any char** parameters, manage memory and
  manipulate the strings.

  Such class is defined at swig/StringArray.hpp and wrapped in StringArray.i.

+ [API+fix] Wrap LGBM_BoosterGetFeatureNames it resulted in segfault before:

  Added wrapper LGBM_BoosterGetFeatureNamesSWIG(BoosterHandle) that
  only receives the booster handle and figures how much memory to allocate
  for strings and returns a StringArray which can be easily converted to String[].

+ [API+safety] For consistency, LGBM_BoosterGetEvalNamesSWIG was wrapped as well:

  * Refactor to detect any kind of errors and removed all the parameters
    besides the BoosterHandle (much simpler API to use in Java).
  * No assumptions are made about the required string space necessary (128 before).
  * The amount of required string memory is computed internally

+ [safety] No possibility of undefined behaviour

  The two methods wrapped above now compute the necessary string storage space
  prior to allocation, as the low-level C API calls would crash the process
  irreversibly if they write more memory than which is passed to them.

* Changes to C API and wrappers support char**

To support the latest SWIG changes that enable proper char**
return support that is safe, the C API was changed.

The respecive wrappers in R and Python were changed too.

* Cleanup indentation in new lightgbm_R.cpp code

* Adress review code-style comments.

* Update swig/StringArray.hpp

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update python-package/lightgbm/basic.py

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update src/lightgbm_R.cpp

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

Co-authored-by: alberto.ferreira <alberto.ferreira@feedzai.com>
Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2020-03-20 04:05:38 +03:00
Lukas Pfannschmidt cf0a992eda
[python] handle RandomState object in Scikit-learn Api (#2904)
* Add handling of RandomState object, which is standard for sklearn methods.

LightGBM expects an integer seed instead of an object.
If passed object is RandomState, we choose random integer based on its state to seed the underlying low level code.
While chosen random integer is only in the range between 1 and 1e10 I expect it to have enough entropy (?) to not matter in practice.

* Add RandomState object to random_state docstring.

* remove blank line

* Use property to handle setting random_state.
This enables setting cloned estimators with the set_params method in sklearn.

* Add docstring to attribute.

* Fix and simplify docstring.

* Add test case.

* Use maximal int for datatype in seed derivation.

* Replace random_state property with interfacing in fit method.
Derives int seed for C code only when fitting and keeps RandomState object as param.

* Adapt unit test to property change.

* Extended test case and docstring

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Add more equality checks (feature importance, best iteration/score).

* Add equality comparison of boosters represented by strings.
Remove useless best_iteration_ comparison (we do not use early_stopping).

* fix whitespace

* Test if two subsequent fits produce different models

* Apply suggestions from code review

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2020-03-20 03:38:22 +03:00
Guolin Ke fc0f132f77
[python] Fix continued train by reusing the same dataset (#2906)
* fix

* fix return

* fix test

* fix test

* fix predictor is none

* Apply suggestions from code review

* Update basic.py

* Update basic.py

* Apply suggestions from code review

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2020-03-16 21:54:34 +03:00
Guolin Ke 399b746b36
[python] fix the bug when use different params with reference (#2907)
* fix the bug when use different params with reference

* fix

* Update basic.py

* Apply suggestions from code review

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update basic.py

* add test

* Apply suggestions from code review

* added asserts in test

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: StrikerRUS <nekit94-12@hotmail.com>
2020-03-16 18:34:42 +03:00
Nikita Titov ba15a16abd
[python] save all param values into model file (#2589)
* save all param values into model file

* revert storing predict params

* do not save params for predict and convert tasks

* fixed test: 10 is found successfully for default 100

* specify more params as no-save
2020-03-06 15:42:49 +03:00
Nikita Titov 9d76066562
[ci] bump Azure image versions (#2822)
* bump Azure image versions

* fixed Windows builds
2020-02-26 11:53:50 +08:00
Joan Fontanals 18e7de4f5d
Add capability to get possible max and min values for a model (#2737)
* Add capability to get possible max and min values for a model

* Change implementation to have return value in tree.cpp, change naming to upper and lower bound, move implementation to gdbt.cpp

* Update include/LightGBM/c_api.h

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Change iteration to avoid potential overflow, add bindings to R and Python and a basic test

* Adjust test values

* Consider const correctness and multithreading protection

* Update test values

* Update test values

* Add test to check that model is exactly the same in all platforms

* Try to parse the model to get the expected values

* Try to parse the model to get the expected values

* Fix implementation, num_leaves can be lower than the leaf_value_ size

* Do not check for num_leaves to be smaller than actual size and get back to test with hardcoded value

* Change test order

* Add gpu_use_dp option in test

* Remove helper test method

* Update src/c_api.cpp

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update src/io/tree.cpp

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update src/io/tree.cpp

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update tests/python_package_test/test_basic.py

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Remoove imports

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2020-02-20 09:42:36 +08:00
Guolin Ke 9f79e8402c
[python] [R-package] refine the parameters for Dataset (#2594)
* reset

* fix a bug

* fix test

* Update c_api.h

* support to no filter features by min_data

* add warning in reset config

* refine warnings for override dataset's parameter

* some cleans

* clean code

* clean code

* refine C API function doxygen comments

* refined new param description

* refined doxygen comments for R API function

* removed stuff related to int8

* break long line in warning message

* removed tests which results cannot be validated anymore

* added test for warnings about unchangeable params

* write parameter from dataset to booster

* consider free_raw_data.

* fix params

* fix bug

* implementing R

* fix typo

* filter params in R

* fix R

* not min_data

* refined tests

* fixed linting

* refine

* pilint

* add docstring

* fix docstring

* R lint

* updated description for C API function

* use param aliases in Python

* fixed typo

* fixed typo

* added more params to test

* removed debug print

* fix dataset construct place

* fix merge bug

* Update feature_histogram.hpp

* add is_sparse back

* remove unused parameters

* fix lint

* add data random seed

* update

* [R-package] centrallized Dataset parameter aliases and added tests on Dataset parameter updating (#2767)

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
Co-authored-by: James Lamb <jaylamb20@gmail.com>
2020-02-19 09:20:03 +08:00
Nikita Titov 923226b12c
[python] in sklearn wrapper pass cat features to Dataset constructor (#2763) 2020-02-15 15:34:59 +03:00
zhangqibot 87b6396d2d
[python] add property: feature_name_ in lgb sklearn api (#2740)
* add property: feature_name_ in lgb sklearn api

* modify the comments

* fix linting errors and add info about new attribute: feature_name_
2020-02-06 22:24:23 +03:00
Nikita Titov d92d844447
[python][R-package][docs] fix support of XE_NDCG_MART obj in language wrappers and docs (#2726) 2020-02-03 13:19:17 +08:00
Nikita Titov bef83598b9
[python][R-package] removed duplicated code from language wrappers (#2606)
* removed duplicated code from language wrappers

* removed check for resetting metric
2020-02-03 05:57:05 +03:00
Nikita Titov b588cae2a5 [ci] indicate support only for the last 3 macOS versions in wheel name (#2691)
* indicate support only for the last 3 macOS versions in wheel name

* document support only for 3 newest macOS versions
2020-01-15 22:16:55 -06:00
Nikita Titov b161f33406
[python] fix trees_to_dataframe and enhance test (#2690)
* transfer and enhance test for trees_to_dataframe

* fixed bug in Python 2
2020-01-14 16:11:53 +03:00
Guolin Ke 82886ba644
[python] [R-package] Use the same address when updated label/weight/query (#2662)
* Update metadata.cpp

* add version for training set, for efficiently update label/weight/... during training.

* Update lgb.Booster.R
2020-01-14 18:44:57 +08:00
Nikita Titov 8944b5e6b9
removed OpenMP ugly fix for Mojave (#2674)
* removed OpenMP ugly fix for Mojave as it's fixed in latest CMake

* test: switch compilers

* switch compilers back
2020-01-12 16:51:27 +03:00
Patrick Ford 301402c83b [python] Output model to a pandas DataFrame (#2592)
* trees_to_df method and unit test added. PEP 8 fixes for integration.

* Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

Post-review changes

* changes from second round of reviews from striker

* third round of review. formatting and added 2 more tests

* replaced pandas dot attribute accessor with string attribute accessor

* dealt with single tree edge case and minor refactor of tests

* slight refactor for checking if tree is a single node
2020-01-10 23:50:00 +03:00
Nikita Titov 5e36167dfd
[python] allow to specify orientation of a tree (#2605) 2020-01-02 16:58:14 +03:00
Guolin Ke 7b411bddec
warning for init_score in save_binary (#2649)
* warning for init_score in save_binary

fix #2639

* Update metadata.cpp

* added info into docs

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
2019-12-29 13:01:02 +08:00
Nikita Titov d100277649 specify the last supported version of scikit-learn (#2637) 2019-12-19 19:00:29 +08:00
Nikita Titov eec60731be
[python][sklearn] do not modify args in fit function and minor code cleanup (#2619)
* clean code

* clean code

* do not modify args in fit function

* added test
2019-12-09 20:36:54 +03:00
duckladydinh b36926d8d9 [python] Variable Typo: redictor -> predictor (#2622)
I believe that this should be a typo, right?
2019-12-08 23:05:54 +03:00
aaiyer f3afe98bed [python] Allow python sklearn interface's fit() to pass init_model to train() (#2447)
* allow python sklearn interface's fit() to pass init_model to train()

* Fix whitespace issues, and change ordering of parameters to be backward
compatible

* Formatting fixes

* allow python sklearn interface's fit() to pass init_model to train()

* Fix whitespace issues, and change ordering of parameters to be backward
compatible

* Formatting fixes

* Recognize LGBModel objects for init_model

* simplified condition

* updated docstring

* added test
2019-12-05 19:35:54 +03:00
Nikita Titov 69c1c33093
[python][R-package] warn users about untransformed values in case of custom obj (#2611) 2019-12-05 16:53:13 +03:00
Nikita Titov 00d1e6938a
[python] removed unused pylint directives (#2466) 2019-10-27 03:18:10 +03:00
Nikita Titov 5dcd4be924
[python] handle params aliases centralized (#2489)
* handle aliases centralized

* convert aliases dict to class
2019-10-22 20:11:39 +03:00
Guolin Ke 465d1262eb
check sorted indices in Subset (#2510)
* Update sparse_bin.hpp

* check sorted in c_api

* fix python package

* fix tests

* fix test

* std::is_sorted

* Update basic.py
2019-10-21 08:07:26 +08:00
Nikita Titov 72027036a9
[docs] removed misleading section about pep8 in python's readme (#2507) 2019-10-16 16:36:32 +03:00
Nikita Titov b1c50d07ce
[docs] added logos to badges (#2506)
* added logos to badges

* Update README.rst
2019-10-15 22:10:16 +03:00
Jagadeesh Kotra b0500dde9a [python] DPI arg in plotting functions (#2491)
* dpi option in plot_importance

* pep fix

* added dpi to plot_metric, plot_tree

* add dpi to plot_split_value_histogram

* removed trailing white space in docstring
2019-10-13 21:54:34 +03:00
Nikita Titov c1a7b291c5
[python] removed deprecated code (#2474) 2019-10-01 15:07:43 +03:00
Nikita Titov d064019f22
[python] avoid data copy where possible (#2383)
* avoid copy where possible

* use precise type for importance type

* removed pointless code

* simplify sparse pandas Series conversion

* more memory savings

* always force type conversion for 1-D arrays

* one more copy=False
2019-09-26 23:37:47 +03:00
Nikita Titov a0d7313b81 fixed docstrings (#2451) 2019-09-26 17:32:05 +08:00
Nikita Titov a0a117aab8 [python] make dump_text() private (#2434)
* make dump_text() private

* updated test
2019-09-26 12:09:31 +08:00