Skip to content

Commit

Permalink
[python] fix categorical_feature parameter (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxchan authored and guolinke committed Aug 18, 2017
1 parent 715ee38 commit 666191b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,15 @@ def set_categorical_feature(self, categorical_feature):
if self.categorical_feature == categorical_feature:
return
if self.data is not None:
self.categorical_feature = categorical_feature
self._free_handle()
if self.categorical_feature is None:
self.categorical_feature = categorical_feature
self._free_handle()
elif categorical_feature == 'auto':
warnings.warn('Using categorical_feature in Dataset.')
else:
warnings.warn('categorical_feature in Dataset is overrided. New categorical_feature is {}'.format(sorted(list(categorical_feature))))
self.categorical_feature = categorical_feature
self._free_handle()
else:
raise LightGBMError("Cannot set categorical feature after freed raw data, set free_raw_data=False when construct Dataset to avoid this.")

Expand Down

0 comments on commit 666191b

Please sign in to comment.