(self, data, label=None, reference=None,
weight=None, group=None, init_score=None, predictor=None,
silent=False, feature_name='auto',
categorical_feature='auto', params=None)
| 821 | self.set_init_score(init_score) |
| 822 | |
| 823 | def _lazy_init(self, data, label=None, reference=None, |
| 824 | weight=None, group=None, init_score=None, predictor=None, |
| 825 | silent=False, feature_name='auto', |
| 826 | categorical_feature='auto', params=None): |
| 827 | if data is None: |
| 828 | self.handle = None |
| 829 | return self |
| 830 | if reference is not None: |
| 831 | self.pandas_categorical = reference.pandas_categorical |
| 832 | categorical_feature = reference.categorical_feature |
| 833 | data, feature_name, categorical_feature, self.pandas_categorical = _data_from_pandas(data, |
| 834 | feature_name, |
| 835 | categorical_feature, |
| 836 | self.pandas_categorical) |
| 837 | label = _label_from_pandas(label) |
| 838 | |
| 839 | # process for args |
| 840 | params = {} if params is None else params |
| 841 | args_names = (getattr(self.__class__, '_lazy_init') |
| 842 | .__code__ |
| 843 | .co_varnames[:getattr(self.__class__, '_lazy_init').__code__.co_argcount]) |
| 844 | for key, _ in params.items(): |
| 845 | if key in args_names: |
| 846 | warnings.warn('{0} keyword has been found in `params` and will be ignored.\n' |
| 847 | 'Please use {0} argument of the Dataset constructor to pass this parameter.' |
| 848 | .format(key)) |
| 849 | # user can set verbose with params, it has higher priority |
| 850 | if not any(verbose_alias in params for verbose_alias in _ConfigAliases.get("verbosity")) and silent: |
| 851 | params["verbose"] = -1 |
| 852 | # get categorical features |
| 853 | if categorical_feature is not None: |
| 854 | categorical_indices = set() |
| 855 | feature_dict = {} |
| 856 | if feature_name is not None: |
| 857 | feature_dict = {name: i for i, name in enumerate(feature_name)} |
| 858 | for name in categorical_feature: |
| 859 | if isinstance(name, string_type) and name in feature_dict: |
| 860 | categorical_indices.add(feature_dict[name]) |
| 861 | elif isinstance(name, integer_types): |
| 862 | categorical_indices.add(name) |
| 863 | else: |
| 864 | raise TypeError("Wrong type({}) or unknown name({}) in categorical_feature" |
| 865 | .format(type(name).__name__, name)) |
| 866 | if categorical_indices: |
| 867 | for cat_alias in _ConfigAliases.get("categorical_feature"): |
| 868 | if cat_alias in params: |
| 869 | warnings.warn('{} in param dict is overridden.'.format(cat_alias)) |
| 870 | params.pop(cat_alias, None) |
| 871 | params['categorical_column'] = sorted(categorical_indices) |
| 872 | |
| 873 | params_str = param_dict_to_str(params) |
| 874 | # process for reference dataset |
| 875 | ref_dataset = None |
| 876 | if isinstance(reference, Dataset): |
| 877 | ref_dataset = reference.construct().handle |
| 878 | elif reference is not None: |
| 879 | raise TypeError('Reference dataset should be None or dataset instance') |
| 880 | # start construct data |
no test coverage detected