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

165 Коммитов

Автор SHA1 Сообщение Дата
Belinda Trotta cc7a1e2739 Predefined bin thresholds (#2325)
* Fix bug where small values of max_bin cause crash.

* Revert "Fix bug where small values of max_bin cause crash."

This reverts commit fe5c8e2547.

* Add functionality to force bin thresholds.

* Fix style issues.

* Use stable sort.

* Minor style and doc fixes.

* Add functionality to force bin thresholds.

* Fix style issues.

* Use stable sort.

* Minor style and doc fixes.

* Change binning behavior to be same as PR #2342.

* Add functionality to force bin thresholds.

* Fix style issues.

* Use stable sort.

* Minor style and doc fixes.

* Add functionality to force bin thresholds.

* Fix style issues.

* Use stable sort.

* Minor style and doc fixes.

* Change binning behavior to be same as PR #2342.

* Add functionality to force bin thresholds.

* Fix style issues.

* Minor style and doc fixes.

* Add functionality to force bin thresholds.

* Fix style issues.

* Minor style and doc fixes.

* Change binning behavior to be same as PR #2342.

* Add functionality to force bin thresholds.

* Fix style issues.

* Use stable sort.

* Minor style and doc fixes.

* Add functionality to force bin thresholds.

* Fix style issues.

* Use stable sort.

* Minor style and doc fixes.

* Change binning behavior to be same as PR #2342.

* Use different bin finding function for predefined bounds.

* Fix style issues.

* Minor refactoring, overload FindBinWithZeroAsOneBin.

* Fix style issues.

* Fix bug and add new test.

* Add warning when using categorical features with forced bins.

* Pass forced_upper_bounds by reference.

* Pass container types by const reference.

* Get categorical features using FeatureBinMapper.

* Fix bug for small max_bin.

* Move GetForcedBins to DatasetLoader.

* Find forced bins in dataset_loader.

* Minor fixes.
2019-09-28 23:31:31 +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
kenmatsu4 84754399a6 [python] Bug fix for first_metric_only on earlystopping. (#2209)
* Bug fix for first_metric_only if the first metric is train metric.

* Update bug fix for feval issue.

* Disable feval for first_metric_only.

* Additional test items.

* Fix wrong assertEqual settings & formating.

* Change dataset of test.

* Fix random seed for test.

* Modiry assumed test result due to different sklearn verion between CI and local.

* Remove f-string

* Applying variable  assumed test result for test.

* Fix flake8 error.

* Modifying  in accordance with review comments.

* Modifying for pylint.

* simplified tests

* Deleting error criteria `if eval_metric is None`.

* Delete test items of classification.

* Simplifying if condition.

* Applying first_metric_only for sklearn wrapper.

* Modifying test_sklearn for comforming to python 2.x

* Fix flake8 error.

* Additional fix for sklearn and add tests.

* Bug fix and add test cases.

* some refactor

* fixed lint

* fixed lint

* Fix duplicated metrics scores to pass the test.

* Fix the case first_metric_only not in params.

* Converting metrics aliases.

* Add comment.

* Modify comment for pylint.

* Modify comment for pydocstyle.

* Using split test set for two eval_set.

* added test case for metric aliases and length checks

* minor style fixes

* fixed rmse name and alias position

* Fix the case metric=[]

* Fix using env.model._train_data_name

* Fix wrong test condition.

* Move initial process to _init() func.

* Modify test setting for test_sklearn & training data matching on callback.py

* test_sklearn.py
-> A test case for training is wrong, so fixed.

* callback.py
-> A condition of if statement for detecting test dataset is wrong, so fixed.

* Support composite name metrics.

* Remove metric check process & reduce redundant test cases.

For #2273 fixed not only the order of metrics in cpp, removing metric check process at callback.py

* Revised according to the matters pointed out on a review.

* increased code readability

* Fix the issue of order of validation set.

* Changing to OrderdDict from default dict for score result.

* added missed check in cv function for first_metric_only and feval co-occurrence

* keep order only for metrics but not for datasets in best_score

* move OrderedDict initialization to init phase

* fixed minor printing issues

* move first metric detection to init phase and split can be performed without checks

* split only once during callback

* removed excess code

* fixed typo in variable name and squashed ifs

* use setdefault

* hotfix

* fixed failing test

* refined tests

* refined sklearn test

* Making "feval" effective on early stopping.

* allow feval and first_metric_only for cv

* removed unused code

* added tests for feval

* fixed printing

* add note about whitespaces in feval name

* Modifying final iteration process in case valid set is  training data.
2019-09-15 23:43:42 +03:00
Guolin Ke ad8e8ccc9c update feature_fraction_bynode (#2381)
* update

* fix a bug

* Update config.h

* Update Parameters.rst
2019-09-12 15:52:52 +03:00
Nikita Titov 9f6e4413bd
[python] keep consistent state for Dataset fields (#2390)
* keep consistent state for Dataset fields

* hotfix
2019-09-09 19:19:56 +03:00
CharlesAuguste f52be9be50 [python] Improved python tree plots (#2304)
* Some basic changes to the plot of the trees to make them readable.

* Squeezed the information in the nodes.

* Added colouring when a dictionnary mapping the features to the constraints is passed.

* Fix spaces.

* Added data percentage as an option in the nodes.

* Squeezed the information in the leaves.

* Important information is now in bold.

* Added a legend for the color of monotone splits.

* Changed "split_gain" to "gain" and "internal_value" to "value".

* Sqeezed leaves a bit more.

* Changed description in the legend.

* Revert "Sqeezed leaves a bit more."

This reverts commit dd8bf14a3ba604b0dfae3b7bb1c64b6784d15e03.

* Increased the readability for the gain.

* Tidied up the legend.

* Added the data percentage in the leaves.

* Added the monotone constraints to the dumped model.

* Monotone constraints are now specified automatically when plotting trees.

* Raise an exception instead of the bug that was here before.

* Removed operators on the branches for a clearer design.

* Small cleaning of the code.

* Setting a monotone constraint on a categorical feature now returns an exception instead of doing nothing.

* Fix bug when monotone constraints are empty.

* Fix another bug when monotone constraints are empty.

* Variable name change.

* Added is / isn't on every edge of the trees.

* Fix test "tree_create_digraph".

* Add new test for plotting trees with monotone constraints.

* Typo.

* Update documentation of categorical features.

* Typo.

* Information in nodes more explicit.

* Used regular strings instead of raw strings.

* Small refactoring.

* Some cleaning.

* Added future statement.

* Changed output for consistency.

* Updated documentation.

* Added comments for colors.

* Changed text on edges for more clarity.

* Small refactoring.

* Modified text in leaves for consistency with nodes.

* Updated default values and documentaton for consistency.

* Replaced CHECK with Log::Fatal for user-friendliness.

* Updated tests.

* Typo.

* Simplify imports.

* Swapped count and weight to improve readibility of the leaves in the plotted trees.

* Thresholds in bold.

* Made information in nodes written in a specific order.

* Added information to clarify legend.

* Code cleaning.
2019-09-08 19:26:55 +03:00
Nikita Titov df26b65d78
[ci][tests] install joblib for test directly (#2374) 2019-09-03 14:08:10 +03:00
Guolin Ke bbbad73db3
sub-features for node level (#2330)
* add parameter

* implement

* fix bug

* fix bug

* fix according comment

* add test

* Update test_engine.py

* Update test_engine.py

* Update test_engine.py
2019-09-03 11:43:51 +08:00
Nikita Titov e7c6e67aaa
[tests] simplified test and added dumped data to gitignore (#2372) 2019-09-02 18:59:54 +03:00
Guolin Ke 0dfda82607
normalize the lambdas in lambdamart objective (#2331)
* norm the lambda scores

* change default to false

* update doc

* typo

* Update Parameters.rst

* Update config.h

* Update test_sklearn.py

* Update test_sklearn.py

* Update test_sklearn.py

* Update test_sklearn.py

* Update test_sklearn.py

* Update rank_objective.hpp

* Update Parameters.rst

* Update config.h

* Update test_sklearn.py

* Update test_sklearn.py

* Update test_sklearn.py
2019-08-25 07:30:10 +08:00
Guolin Ke 20f94c5252
fix the bug in bin with small values (#2342)
* fix the bug in bin with small values

* Update bin.cpp

* Update test_engine.py
2019-08-20 12:56:26 +08:00
sbruch aee92f63ba sigmoid_ in grad and hess for rank objective (#2322)
* Lambdas and hessians need to factor sigmoid_ into the computation. Additionally, the sigmoid function has an arbitrary factor of 2 in the exponent; it is not just non-standard but the gradients are not computed correctly anyway.

* Update unit test

* Also remove a heuristic that normalizes the gradient by the difference in scores.

* Also fix unit test after removing the heuristic
2019-08-16 20:36:48 -07:00
Belinda Trotta c421f89851 Bug fix: small values of max_bin cause program to crash (#2299)
* Fix bug where small values of max_bin cause crash.

* Revert "Fix bug where small values of max_bin cause crash."

This reverts commit fe5c8e2547.

* Fix bug where small values of max_bin cause crash.

* Reset random seed in test, remove extra blank line.

* Minor bug fix. Remove extra blank line.

* Change old test to account for new binning behavior.
2019-08-15 22:29:53 -08:00
Nikita Titov 8f446be749
[python] add sparsity support for new version of pandas and check Series for bad dtypes (#2318)
* reworked pandas dtypes mapper

* added tests

* added sparsity support for new version of pandas

* fixed tests for old pandas

* check pd.Series for bad dtypes as well

* enhanced tests

* fixed pylint
2019-08-13 14:48:47 +03:00
Guolin Ke e1d7a7b9e3 add weight in tree model output (#2269)
* add weight in tree model output

* fix bug

* updated Python plotting part to handle weights
2019-07-24 13:09:47 +03:00
Guolin Ke 7360cff94b
fix init_model with subset (#2252)
* fix init_model with subset

* Update basic.py

* added test

* fix predictor naming issue

* Update basic.py

* fix bug

* fix pylint

* fix comments

* Update basic.py

* Update basic.py

* updated test

* fixed bug

* fixed lint

* fix warning

* add get_data before initial prediction

* refine the warning in get_data

* refine warning

* Update basic.py
2019-07-12 21:13:42 +08:00
Guolin Ke ebc831bc53
fix bug when using dart with init_model (#2251)
* add test

* fix a index bug
2019-07-09 10:37:41 +08:00
Belinda Trotta 291752de3e Max bin by feature (#2190)
* Add parameter max_bin_by_feature.

* Fix minor bug.

* Fix minor bug.

* Fix calculation of header size for writing binary file.

* Fix style issues.

* Fix python style issue.

* Fix test and python style issue.
2019-07-08 09:45:36 +08:00
Nikita Titov 86269ee38d [tests] use numpy.testing.assert_allclose (#2207)
* Update test.py

* Update test_consistency.py

* Update test_basic.py

* Update test_sklearn.py

* Update test_sklearn.py

* Update test_engine.py

* more replacements
2019-06-20 13:06:58 +08:00
Nikita Titov b6f6578368 [python] fix class_weight (#2199)
* fixed class_weight

* fixed lint

* added test

* hotfix
2019-06-04 13:44:26 +08:00
Nikita Titov 2459362acd [python] fixed picklability of sklearn models with custom obj and updated docstings for custom obj (#2191)
* refactored joblib test

* fixed picklability of sklearn models with custom obj and updated docstings for custom obj

* pickled model should be able to predict without refitting
2019-05-27 17:27:55 +08:00
Belinda Trotta b3db9e924a Top k multi error (#2178)
* Implement top-k multiclass error metric. Add new parameter top_k_threshold.

* Add test for multiclass metrics

* Make test less sensitive to avoid floating-point issues.

* Change tabs to spaces.

* Fix problem with test in Python 2. Refactor to use np.testing. Decrease number of training rounds so loss is larger and easier to compare.

* Move multiclass tests into test_engine.py

* Change parameter name from top_k_threshold to multi_error_top_k.

* Fix top-k error metric to handle case where scores are equal. Update tests and docs.

* Change name of top-k metric to multi_error@k.

* Change tabs to spaces.

* Fix formatting.

* Fix minor issues in docs.
2019-05-26 14:08:45 +03:00
Nikita Titov f91e5644a3
[python] added ability to pass first_metric_only in params (#2175)
* added ability to pass first_metric_only in params

* simplified tests

* fixed test

* fixed punctuation
2019-05-15 15:44:37 +03:00
Guolin Ke 94fbe5bb9f
[docs] updated Microsoft GitHub URL (#2152)
* fix travis badge

* updated GitHub Microsoft URL
2019-05-08 13:51:28 +08:00
Nikita Titov 611cf5d414 [python] added plot_split_value_histogram function (#2043)
* added plot_split_value_histogram function

* updated init module

* added plot split value histogram example

* added plot_split_value_histogram to notebook

* added test

* fixed pylint

* updated API docs

* fixed grammar

* set y ticks to int value in more sufficient way
2019-05-01 23:05:16 +09:00
Nikita Titov 4be53a5a1f
[python] disable default pandas cat features if cat features were explicitly provided (#2121)
* disable default pandas cat features if cat features were explicitly provided

* added assertion for cat features
2019-04-22 13:25:57 +03:00
Nikita Titov d115769c2a
[python] ignore pandas ordered categorical columns by default (#2115)
* ignore pandas ordered categorical columns by default

* fix tests

* fix tests

* added comments
2019-04-19 14:08:00 +03:00
kenmatsu4 ca85b67950 [python] add flag of displaying train loss for lgb.cv() (#2089)
* [python] displaying train loss during training with lgb.cv

* modifying only display running type when disp_train_loss==True

* Add test for display train loss

* del .idea files

* Rename disp_train_loss to show_train_loss and revise comment.

* Change aug name show_train_loss -> eval_train_metric , and add a test item.

* Modifying comment of eval_train_metric.
2019-04-16 16:26:25 +09:00
Nikita Titov 5b5b98235e
[python] make possibility to create Booster from string official (#2098) 2019-04-13 13:47:33 +03:00
remcob-gr 76102284d1 Add Cost Effective Gradient Boosting (#2014)
* Add configuration parameters for CEGB.

* Add skeleton CEGB tree learner

Like the original CEGB version, this inherits from SerialTreeLearner.
Currently, it changes nothing from the original.

* Track features used in CEGB tree learner.

* Pull CEGB tradeoff and coupled feature penalty from config.

* Implement finding best splits for CEGB

This is heavily based on the serial version, but just adds using the coupled penalties.

* Set proper defaults for cegb parameters.

* Ensure sanity checks don't switch off CEGB.

* Implement per-data-point feature penalties in CEGB.

* Implement split penalty and remove unused parameters.

* Merge changes from CEGB tree learner into serial tree learner

* Represent features_used_in_data by a bitset, to reduce the memory overhead of CEGB, and add sanity checks for the lengths of the penalty vectors.

* Fix bug where CEGB would incorrectly penalise a previously used feature

The tree learner did not update the gains of previously computed leaf splits when splitting a leaf elsewhere in the tree.
This caused it to prefer new features due to incorrectly penalising splitting on previously used features.

* Document CEGB parameters and add them to the appropriate section.

* Remove leftover reference to cegb tree learner.

* Remove outdated diff.

* Fix warnings

* Fix minor issues identified by @StrikerRUS.

* Add docs section on CEGB, including citation.

* Fix link.

* Fix CI failure.

* Add some unit tests

* Fix pylint issues.

* Fix remaining pylint issue
2019-04-04 10:35:11 +08:00
kenmatsu4 011cc90a77 [python] Use first_metric_only flag for early_stopping function. (#2049)
* Use first_metric_only flag for early_stopping function.

In order to apply early stopping with only first metric, applying first_metric_only flag for early_stopping function.

* upcate comment

* Revert "upcate comment"

This reverts commit 1e75a1a415.

* added test

* fixed docstring

* cut comment and save one line

* document new feature
2019-03-25 13:18:22 +08:00
Nikita Titov ffb134cc31 [python] disabled split value histogram for categorical features (#2045)
* disabled split value histogram for categorical features

* updated test for cat. feature

* updated docs
2019-03-14 10:52:13 +08:00
Nikita Titov 8d6666e0ff [python] added get_split_value_histogram method (#2041)
* added get_split_value_histogram method

* added param for ordinary return value
2019-03-09 20:47:55 +08:00
Nikita Titov 8aa08c4af2 [tests] fixed and refactored some tests (#2035)
* fixed number of tests in pytest

* fixed data shape and removed unused code

* refactored tests

* hotfix

* hotfix
2019-03-07 13:25:32 +08:00
remcob-gr 219c943dd7 Add ability to move features from one data set to another in memory (#2006)
* Initial attempt to implement appending features in-memory to another data set

The intent is for this to enable munging files together easily, without needing to round-trip via numpy or write multiple copies to disk.
In turn, that enables working more efficiently with data sets that were written separately.

* Implement Dataset.dump_text, and fix small bug in appending of group bin boundaries.

Dumping to text enables us to compare results, without having to worry about issues like features being reordered.

* Add basic tests for validation logic for add_features_from.

* Remove various internal mapping items from dataset text dumps

These are too sensitive to the exact feature order chosen, which is not visible to the user.
Including them in tests appears unnecessary, as the data dumping code should provide enough coverage.

* Add test that add_features_from results in identical data sets according to dump_text.

* Add test that booster behaviour after using add_features_from matches that of training on the full data

This checks:
- That training after add_features_from works at all
- That add_features_from does not cause training to misbehave

* Expose feature_penalty and monotone_types/constraints via get_field

These getters allow us to check that add_features_from does the right thing with these vectors.

* Add tests that add_features correctly handles feature_penalty and monotone_constraints.

* Ensure add_features_from properly frees the added dataset and add unit test for this

Since add_features_from moves the feature group pointers from the added dataset to the dataset being added to, the added dataset is invalid after the call.
We must ensure we do not try and access this handle.

* Remove some obsolete TODOs

* Tidy up DumpTextFile by using a single iterator for each feature

This iterators were also passed around as raw pointers without being freed, which is now fixed.

* Factor out offsetting logic in AddFeaturesFrom

* Remove obsolete TODO

* Remove another TODO

This one is debatable, test code can be a bit messy and duplicate-heavy, factoring it out tends to end badly.
Leaving this for now, will revisit if adding more tests later on becomes a mess.

* Add documentation for newly-added methods.

* Fix whitespace issues identified by pylint.

* Fix a few more whitespace issues.

* Fix doc comments

* Implement deep copying for feature groups.

* Replace awkward std::move usage by emplace_back, and reduce vector size to num_features rather than num_total_features.

* Copy feature groups in addFeaturesFrom, rather than moving them.

* Fix bugs in FeatureGroup copy constructor and ensure source dataset remains usable

* Add reserve to PushVector and PushOffset

* Move definition of Clone into class body

* Fix PR review issues

* Fix for loop increment style.

* Fix test failure

* Some more docstring fixes.

* Remove blank line
2019-02-26 10:58:54 +08:00
Nikita Titov 861de1c1f0 improved model loading routines (#1979) 2019-02-02 14:36:17 +08:00
Guolin Ke feeaf38fff
fix nan in eval results (#1973)
* always save the score of the first round in early stopping

fix #1971

* avoid using std::log on non-positive numbers

* remove unnecessary changes

* add tests

* Update test_sklearn.py

* enhanced tests
2019-01-30 22:40:34 +08:00
Nikita Titov fe77eac5e7
[tests][python] added test for huge string model (#1964)
* added test for huge string model

* fixed tree sizes field

* simplified model structure

* fixed test and added try/except
2019-01-30 16:34:06 +03:00
Nikita Titov f9a1465dd4 [tests][python] added tests for metrics' behavior and fixed case for multiclass task with custom objective (#1954)
* added metrics test for standard interface

* simplified code

* less trees

* less trees

* use dummy custom objective and metric

* added tests for multiclass metrics aliases

* fixed bug in case of custom obj and num_class > 1

* added metric test for sklearn wrapper
2019-01-27 20:20:05 +08:00
Nikita Titov 2323cb3bef [python] added get_data() method to Dataset class (#1870)
* added get_data method

* hotfix

* added warning for other data types

* reworked according to review comments

* minor addition to FAQ

* added test
2018-12-20 12:10:40 +08:00
Tsukasa OMOTO c9bcba44c9
[python] fix creating train_set in fit (#1916)
* [python] fix creating train_set in fit

cc99f0d36a/python-package/lightgbm/sklearn.py (L519)
may False even if valid_data[0] is X and valid_data[1] is y actually, because `check_X_y` might return copy of X and y.
https://scikit-learn.org/0.20/modules/generated/sklearn.utils.check_X_y.html

cf. https://github.com/Microsoft/LightGBM/pull/451

* use assertIn
2018-12-20 12:04:40 +09:00
Guolin Ke cba8244748
Fix bugs in RF (#1906)
* fix RF's bugs

* fix tests

* rollback num_iterations

* fix a bug and reduce memory costs

* reduce memory cost
2018-12-17 13:56:32 +08:00
Nikita Titov af3c4f89ff [python] save pandas_categorical to model string and JSON (#1766)
* add pandas_categorical to returned json

* save pandas_categorical to model file

* added regression test

* removed excess conversion to list

* removed deprecated line

* hotfix
2018-10-22 23:35:00 +08:00
Nikita Titov ccf2570ca3 [docs][ci][python] added docstring style test and fixed errors in existing docstrings (#1759)
* added docstring style test and fixed errors in existing docstrings

* hotfix

* hotfix

* fix grammar

* hotfix
2018-10-16 14:19:36 +08:00
Nikita Titov 108e80f2bd
[tests] fixed codestyle, removed unused code and added several new checks (#1688)
* break huge lines in sklearn tests

* break huge line in plotting tests

* break huge lines in basic tests

* multiple enhancements in engine tests

* multiple enhancements in sklearn tests

* hotfixes

* break huge lines and use with statement in C API test

* make NDCG test more strict
2018-10-11 11:46:04 +03:00
Guolin Ke 496a07d1db
fix ranking tasks consistency (#1739)
* fix ndcg consistency.

* more stable sorts

* Update gbdt_model_text.cpp

* Update dataset.cpp

* Update gbdt_model_text.cpp
2018-10-10 18:09:13 +08:00
Guolin Ke c920e6345b
average predictions for constant features (#1735)
* average predictions for constant features

* fix possible numerical issues in std::log.

* fix pylint

* fix bugs in c_api

* fix styles

* clean code for multi class

* rewrite test

* fix pylint

* skip test_constant_features

* refine test

* fix tests

* fix tests

* update FAQ

* fix test

* Update FAQ.rst
2018-10-09 18:10:18 +08:00
Nikita Titov 9bbfffe64f do not modify users params (#1722) 2018-10-03 09:07:16 +08:00
Nikita Titov f53116af34 [ci][python] fixes according to scikit-learn 0.20 release (#1707)
* fixed FutureWarning about cv default value

* fixed according to new check_estimator API

* fixed joblib warning
2018-09-28 12:43:05 +08:00
Nikita Titov 577a03cea5 [python] added possibility to use sklearn splitter classes in cv function (#1685)
* added sklearn splitter classes in cv function

* added tests
2018-09-22 10:23:58 +08:00