MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / __init__

Method __init__

python-package/lightgbmmt/basic.py:1667–1774  ·  view source on GitHub ↗

Initialize the Booster. Parameters ---------- params : dict or None, optional (default=None) Parameters for Booster. train_set : Dataset or None, optional (default=None) Training dataset. model_file : string or None, optional (default=

(self, params=None, train_set=None, model_file=None, model_str=None, silent=False)

Source from the content-addressed store, hash-verified

1665 """Booster in LightGBM."""
1666
1667 def __init__(self, params=None, train_set=None, model_file=None, model_str=None, silent=False):
1668 """Initialize the Booster.
1669
1670 Parameters
1671 ----------
1672 params : dict or None, optional (default=None)
1673 Parameters for Booster.
1674 train_set : Dataset or None, optional (default=None)
1675 Training dataset.
1676 model_file : string or None, optional (default=None)
1677 Path to the model file.
1678 model_str : string or None, optional (default=None)
1679 Model will be loaded from this string.
1680 silent : bool, optional (default=False)
1681 Whether to print messages during construction.
1682 """
1683 self.handle = None
1684 self.network = False
1685 self.__need_reload_eval_info = True
1686 self._train_data_name = "training"
1687 self.__attr = {}
1688 self.__set_objective_to_none = False
1689 self.best_iteration = -1
1690 self.best_score = {}
1691 params = {} if params is None else copy.deepcopy(params)
1692 # user can set verbose with params, it has higher priority
1693 if not any(verbose_alias in params for verbose_alias in _ConfigAliases.get("verbosity")) and silent:
1694 params["verbose"] = -1
1695
1696 if 'num_labels' in params and params['num_labels'] > 1:
1697 if not 'tree_learner' in params and params['tree_learner'] != 'serial2':
1698 raise ValueError('tree_learner should be serial2')
1699
1700
1701 if 'num_labels' not in params :
1702 params['num_labels'] = 1
1703 elif params['num_labels'] != train_set.label.shape[1]:
1704 raise ValueError('num_labels {} should be equal to train_set shape {}'.format(params['num_labels'],train_set.label.shape[1]))
1705 self.num_labels__ = params['num_labels']
1706
1707 if train_set is not None:
1708 # Training task
1709 if not isinstance(train_set, Dataset):
1710 raise TypeError('Training data should be Dataset instance, met {}'
1711 .format(type(train_set).__name__))
1712 params_str = param_dict_to_str(params)
1713 # set network if necessary
1714 for alias in _ConfigAliases.get("machines"):
1715 if alias in params:
1716 machines = params[alias]
1717 if isinstance(machines, string_type):
1718 num_machines = len(machines.split(','))
1719 elif isinstance(machines, (list, set)):
1720 num_machines = len(machines)
1721 machines = ','.join(machines)
1722 else:
1723 raise ValueError("Invalid machines in params.")
1724 self.set_network(machines,

Callers

nothing calls this directly

Calls 12

set_networkMethod · 0.95
__get_eval_infoMethod · 0.95
model_from_stringMethod · 0.95
typeEnum · 0.85
param_dict_to_strFunction · 0.85
_safe_callFunction · 0.85
_load_pandas_categoricalFunction · 0.85
formatMethod · 0.80
joinMethod · 0.80
constructMethod · 0.80
c_strFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected