Commit 666191b2 authored by wxchan's avatar wxchan Committed by Guolin Ke
Browse files

[python] fix categorical_feature parameter (#792)

parent 715ee380
...@@ -979,8 +979,15 @@ class Dataset(object): ...@@ -979,8 +979,15 @@ class Dataset(object):
if self.categorical_feature == categorical_feature: if self.categorical_feature == categorical_feature:
return return
if self.data is not None: if self.data is not None:
self.categorical_feature = categorical_feature if self.categorical_feature is None:
self._free_handle() 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: else:
raise LightGBMError("Cannot set categorical feature after freed raw data, set free_raw_data=False when construct Dataset to avoid this.") raise LightGBMError("Cannot set categorical feature after freed raw data, set free_raw_data=False when construct Dataset to avoid this.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment