Dataset in LightGBM.
| 715 | |
| 716 | |
| 717 | class Dataset(object): |
| 718 | """Dataset in LightGBM.""" |
| 719 | |
| 720 | def __init__(self, data, label=None, reference=None, |
| 721 | weight=None, group=None, init_score=None, silent=False, |
| 722 | feature_name='auto', categorical_feature='auto', params=None, |
| 723 | free_raw_data=True): |
| 724 | """Initialize Dataset. |
| 725 | |
| 726 | Parameters |
| 727 | ---------- |
| 728 | data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse or list of numpy arrays |
| 729 | Data source of Dataset. |
| 730 | If string, it represents the path to txt file. |
| 731 | label : list, numpy 1-D array, pandas Series / one-column DataFrame or None, optional (default=None) |
| 732 | Label of the data. |
| 733 | reference : Dataset or None, optional (default=None) |
| 734 | If this is Dataset for validation, training data should be used as reference. |
| 735 | weight : list, numpy 1-D array, pandas Series or None, optional (default=None) |
| 736 | Weight for each instance. |
| 737 | group : list, numpy 1-D array, pandas Series or None, optional (default=None) |
| 738 | Group/query size for Dataset. |
| 739 | init_score : list, numpy 1-D array, pandas Series or None, optional (default=None) |
| 740 | Init score for Dataset. |
| 741 | silent : bool, optional (default=False) |
| 742 | Whether to print messages during construction. |
| 743 | feature_name : list of strings or 'auto', optional (default="auto") |
| 744 | Feature names. |
| 745 | If 'auto' and data is pandas DataFrame, data columns names are used. |
| 746 | categorical_feature : list of strings or int, or 'auto', optional (default="auto") |
| 747 | Categorical features. |
| 748 | If list of int, interpreted as indices. |
| 749 | If list of strings, interpreted as feature names (need to specify ``feature_name`` as well). |
| 750 | If 'auto' and data is pandas DataFrame, pandas unordered categorical columns are used. |
| 751 | All values in categorical features should be less than int32 max value (2147483647). |
| 752 | Large values could be memory consuming. Consider using consecutive integers starting from zero. |
| 753 | All negative values in categorical features will be treated as missing values. |
| 754 | The output cannot be monotonically constrained with respect to a categorical feature. |
| 755 | params : dict or None, optional (default=None) |
| 756 | Other parameters for Dataset. |
| 757 | free_raw_data : bool, optional (default=True) |
| 758 | If True, raw data is freed after constructing inner Dataset. |
| 759 | """ |
| 760 | self.handle = None |
| 761 | self.data = data |
| 762 | self.label = label |
| 763 | self.reference = reference |
| 764 | self.weight = weight |
| 765 | self.group = group |
| 766 | self.init_score = init_score |
| 767 | self.silent = silent |
| 768 | self.feature_name = feature_name |
| 769 | self.categorical_feature = categorical_feature |
| 770 | self.params = copy.deepcopy(params) |
| 771 | self.free_raw_data = free_raw_data |
| 772 | self.used_indices = None |
| 773 | self.need_slice = True |
| 774 | self._predictor = None |
no outgoing calls
no test coverage detected