partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Dataset.set_label
Set label of Dataset. Parameters ---------- label : list, numpy 1-D array, pandas Series / one-column DataFrame or None The label information to be set into Dataset. Returns ------- self : Dataset Dataset with set label.
python-package/lightgbm/basic.py
def set_label(self, label): """Set label of Dataset. Parameters ---------- label : list, numpy 1-D array, pandas Series / one-column DataFrame or None The label information to be set into Dataset. Returns ------- self : Dataset Dataset wi...
def set_label(self, label): """Set label of Dataset. Parameters ---------- label : list, numpy 1-D array, pandas Series / one-column DataFrame or None The label information to be set into Dataset. Returns ------- self : Dataset Dataset wi...
[ "Set", "label", "of", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1299-L1316
[ "def", "set_label", "(", "self", ",", "label", ")", ":", "self", ".", "label", "=", "label", "if", "self", ".", "handle", "is", "not", "None", ":", "label", "=", "list_to_1d_numpy", "(", "_label_from_pandas", "(", "label", ")", ",", "name", "=", "'labe...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.set_weight
Set weight of each instance. Parameters ---------- weight : list, numpy 1-D array, pandas Series or None Weight to be set for each data point. Returns ------- self : Dataset Dataset with set weight.
python-package/lightgbm/basic.py
def set_weight(self, weight): """Set weight of each instance. Parameters ---------- weight : list, numpy 1-D array, pandas Series or None Weight to be set for each data point. Returns ------- self : Dataset Dataset with set weight. ...
def set_weight(self, weight): """Set weight of each instance. Parameters ---------- weight : list, numpy 1-D array, pandas Series or None Weight to be set for each data point. Returns ------- self : Dataset Dataset with set weight. ...
[ "Set", "weight", "of", "each", "instance", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1318-L1337
[ "def", "set_weight", "(", "self", ",", "weight", ")", ":", "if", "weight", "is", "not", "None", "and", "np", ".", "all", "(", "weight", "==", "1", ")", ":", "weight", "=", "None", "self", ".", "weight", "=", "weight", "if", "self", ".", "handle", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.set_init_score
Set init score of Booster to start from. Parameters ---------- init_score : list, numpy 1-D array, pandas Series or None Init score for Booster. Returns ------- self : Dataset Dataset with set init score.
python-package/lightgbm/basic.py
def set_init_score(self, init_score): """Set init score of Booster to start from. Parameters ---------- init_score : list, numpy 1-D array, pandas Series or None Init score for Booster. Returns ------- self : Dataset Dataset with set init...
def set_init_score(self, init_score): """Set init score of Booster to start from. Parameters ---------- init_score : list, numpy 1-D array, pandas Series or None Init score for Booster. Returns ------- self : Dataset Dataset with set init...
[ "Set", "init", "score", "of", "Booster", "to", "start", "from", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1339-L1356
[ "def", "set_init_score", "(", "self", ",", "init_score", ")", ":", "self", ".", "init_score", "=", "init_score", "if", "self", ".", "handle", "is", "not", "None", "and", "init_score", "is", "not", "None", ":", "init_score", "=", "list_to_1d_numpy", "(", "i...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.set_group
Set group size of Dataset (used for ranking). Parameters ---------- group : list, numpy 1-D array, pandas Series or None Group size of each group. Returns ------- self : Dataset Dataset with set group.
python-package/lightgbm/basic.py
def set_group(self, group): """Set group size of Dataset (used for ranking). Parameters ---------- group : list, numpy 1-D array, pandas Series or None Group size of each group. Returns ------- self : Dataset Dataset with set group. ...
def set_group(self, group): """Set group size of Dataset (used for ranking). Parameters ---------- group : list, numpy 1-D array, pandas Series or None Group size of each group. Returns ------- self : Dataset Dataset with set group. ...
[ "Set", "group", "size", "of", "Dataset", "(", "used", "for", "ranking", ")", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1358-L1375
[ "def", "set_group", "(", "self", ",", "group", ")", ":", "self", ".", "group", "=", "group", "if", "self", ".", "handle", "is", "not", "None", "and", "group", "is", "not", "None", ":", "group", "=", "list_to_1d_numpy", "(", "group", ",", "np", ".", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_label
Get the label of the Dataset. Returns ------- label : numpy array or None The label information from the Dataset.
python-package/lightgbm/basic.py
def get_label(self): """Get the label of the Dataset. Returns ------- label : numpy array or None The label information from the Dataset. """ if self.label is None: self.label = self.get_field('label') return self.label
def get_label(self): """Get the label of the Dataset. Returns ------- label : numpy array or None The label information from the Dataset. """ if self.label is None: self.label = self.get_field('label') return self.label
[ "Get", "the", "label", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1377-L1387
[ "def", "get_label", "(", "self", ")", ":", "if", "self", ".", "label", "is", "None", ":", "self", ".", "label", "=", "self", ".", "get_field", "(", "'label'", ")", "return", "self", ".", "label" ]
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_weight
Get the weight of the Dataset. Returns ------- weight : numpy array or None Weight for each data point from the Dataset.
python-package/lightgbm/basic.py
def get_weight(self): """Get the weight of the Dataset. Returns ------- weight : numpy array or None Weight for each data point from the Dataset. """ if self.weight is None: self.weight = self.get_field('weight') return self.weight
def get_weight(self): """Get the weight of the Dataset. Returns ------- weight : numpy array or None Weight for each data point from the Dataset. """ if self.weight is None: self.weight = self.get_field('weight') return self.weight
[ "Get", "the", "weight", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1389-L1399
[ "def", "get_weight", "(", "self", ")", ":", "if", "self", ".", "weight", "is", "None", ":", "self", ".", "weight", "=", "self", ".", "get_field", "(", "'weight'", ")", "return", "self", ".", "weight" ]
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_feature_penalty
Get the feature penalty of the Dataset. Returns ------- feature_penalty : numpy array or None Feature penalty for each feature in the Dataset.
python-package/lightgbm/basic.py
def get_feature_penalty(self): """Get the feature penalty of the Dataset. Returns ------- feature_penalty : numpy array or None Feature penalty for each feature in the Dataset. """ if self.feature_penalty is None: self.feature_penalty = self.get_f...
def get_feature_penalty(self): """Get the feature penalty of the Dataset. Returns ------- feature_penalty : numpy array or None Feature penalty for each feature in the Dataset. """ if self.feature_penalty is None: self.feature_penalty = self.get_f...
[ "Get", "the", "feature", "penalty", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1401-L1411
[ "def", "get_feature_penalty", "(", "self", ")", ":", "if", "self", ".", "feature_penalty", "is", "None", ":", "self", ".", "feature_penalty", "=", "self", ".", "get_field", "(", "'feature_penalty'", ")", "return", "self", ".", "feature_penalty" ]
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_monotone_constraints
Get the monotone constraints of the Dataset. Returns ------- monotone_constraints : numpy array or None Monotone constraints: -1, 0 or 1, for each feature in the Dataset.
python-package/lightgbm/basic.py
def get_monotone_constraints(self): """Get the monotone constraints of the Dataset. Returns ------- monotone_constraints : numpy array or None Monotone constraints: -1, 0 or 1, for each feature in the Dataset. """ if self.monotone_constraints is None: ...
def get_monotone_constraints(self): """Get the monotone constraints of the Dataset. Returns ------- monotone_constraints : numpy array or None Monotone constraints: -1, 0 or 1, for each feature in the Dataset. """ if self.monotone_constraints is None: ...
[ "Get", "the", "monotone", "constraints", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1413-L1423
[ "def", "get_monotone_constraints", "(", "self", ")", ":", "if", "self", ".", "monotone_constraints", "is", "None", ":", "self", ".", "monotone_constraints", "=", "self", ".", "get_field", "(", "'monotone_constraints'", ")", "return", "self", ".", "monotone_constra...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_init_score
Get the initial score of the Dataset. Returns ------- init_score : numpy array or None Init score of Booster.
python-package/lightgbm/basic.py
def get_init_score(self): """Get the initial score of the Dataset. Returns ------- init_score : numpy array or None Init score of Booster. """ if self.init_score is None: self.init_score = self.get_field('init_score') return self.init_scor...
def get_init_score(self): """Get the initial score of the Dataset. Returns ------- init_score : numpy array or None Init score of Booster. """ if self.init_score is None: self.init_score = self.get_field('init_score') return self.init_scor...
[ "Get", "the", "initial", "score", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1425-L1435
[ "def", "get_init_score", "(", "self", ")", ":", "if", "self", ".", "init_score", "is", "None", ":", "self", ".", "init_score", "=", "self", ".", "get_field", "(", "'init_score'", ")", "return", "self", ".", "init_score" ]
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_data
Get the raw data of the Dataset. Returns ------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse, list of numpy arrays or None Raw data used in the Dataset construction.
python-package/lightgbm/basic.py
def get_data(self): """Get the raw data of the Dataset. Returns ------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse, list of numpy arrays or None Raw data used in the Dataset construction. """ if self.handle is None: ...
def get_data(self): """Get the raw data of the Dataset. Returns ------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse, list of numpy arrays or None Raw data used in the Dataset construction. """ if self.handle is None: ...
[ "Get", "the", "raw", "data", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1437-L1458
[ "def", "get_data", "(", "self", ")", ":", "if", "self", ".", "handle", "is", "None", ":", "raise", "Exception", "(", "\"Cannot get data before construct Dataset\"", ")", "if", "self", ".", "data", "is", "not", "None", "and", "self", ".", "used_indices", "is"...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_group
Get the group of the Dataset. Returns ------- group : numpy array or None Group size of each group.
python-package/lightgbm/basic.py
def get_group(self): """Get the group of the Dataset. Returns ------- group : numpy array or None Group size of each group. """ if self.group is None: self.group = self.get_field('group') if self.group is not None: # gr...
def get_group(self): """Get the group of the Dataset. Returns ------- group : numpy array or None Group size of each group. """ if self.group is None: self.group = self.get_field('group') if self.group is not None: # gr...
[ "Get", "the", "group", "of", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1460-L1473
[ "def", "get_group", "(", "self", ")", ":", "if", "self", ".", "group", "is", "None", ":", "self", ".", "group", "=", "self", ".", "get_field", "(", "'group'", ")", "if", "self", ".", "group", "is", "not", "None", ":", "# group data from LightGBM is bound...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.num_data
Get the number of rows in the Dataset. Returns ------- number_of_rows : int The number of rows in the Dataset.
python-package/lightgbm/basic.py
def num_data(self): """Get the number of rows in the Dataset. Returns ------- number_of_rows : int The number of rows in the Dataset. """ if self.handle is not None: ret = ctypes.c_int() _safe_call(_LIB.LGBM_DatasetGetNumData(self.hand...
def num_data(self): """Get the number of rows in the Dataset. Returns ------- number_of_rows : int The number of rows in the Dataset. """ if self.handle is not None: ret = ctypes.c_int() _safe_call(_LIB.LGBM_DatasetGetNumData(self.hand...
[ "Get", "the", "number", "of", "rows", "in", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1475-L1489
[ "def", "num_data", "(", "self", ")", ":", "if", "self", ".", "handle", "is", "not", "None", ":", "ret", "=", "ctypes", ".", "c_int", "(", ")", "_safe_call", "(", "_LIB", ".", "LGBM_DatasetGetNumData", "(", "self", ".", "handle", ",", "ctypes", ".", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.num_feature
Get the number of columns (features) in the Dataset. Returns ------- number_of_columns : int The number of columns (features) in the Dataset.
python-package/lightgbm/basic.py
def num_feature(self): """Get the number of columns (features) in the Dataset. Returns ------- number_of_columns : int The number of columns (features) in the Dataset. """ if self.handle is not None: ret = ctypes.c_int() _safe_call(_LI...
def num_feature(self): """Get the number of columns (features) in the Dataset. Returns ------- number_of_columns : int The number of columns (features) in the Dataset. """ if self.handle is not None: ret = ctypes.c_int() _safe_call(_LI...
[ "Get", "the", "number", "of", "columns", "(", "features", ")", "in", "the", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1491-L1505
[ "def", "num_feature", "(", "self", ")", ":", "if", "self", ".", "handle", "is", "not", "None", ":", "ret", "=", "ctypes", ".", "c_int", "(", ")", "_safe_call", "(", "_LIB", ".", "LGBM_DatasetGetNumFeature", "(", "self", ".", "handle", ",", "ctypes", "....
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.get_ref_chain
Get a chain of Dataset objects. Starts with r, then goes to r.reference (if exists), then to r.reference.reference, etc. until we hit ``ref_limit`` or a reference loop. Parameters ---------- ref_limit : int, optional (default=100) The limit number of referen...
python-package/lightgbm/basic.py
def get_ref_chain(self, ref_limit=100): """Get a chain of Dataset objects. Starts with r, then goes to r.reference (if exists), then to r.reference.reference, etc. until we hit ``ref_limit`` or a reference loop. Parameters ---------- ref_limit : int, optional (d...
def get_ref_chain(self, ref_limit=100): """Get a chain of Dataset objects. Starts with r, then goes to r.reference (if exists), then to r.reference.reference, etc. until we hit ``ref_limit`` or a reference loop. Parameters ---------- ref_limit : int, optional (d...
[ "Get", "a", "chain", "of", "Dataset", "objects", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1507-L1535
[ "def", "get_ref_chain", "(", "self", ",", "ref_limit", "=", "100", ")", ":", "head", "=", "self", "ref_chain", "=", "set", "(", ")", "while", "len", "(", "ref_chain", ")", "<", "ref_limit", ":", "if", "isinstance", "(", "head", ",", "Dataset", ")", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.add_features_from
Add features from other Dataset to the current Dataset. Both Datasets must be constructed before calling this method. Parameters ---------- other : Dataset The Dataset to take features from. Returns ------- self : Dataset Dataset with th...
python-package/lightgbm/basic.py
def add_features_from(self, other): """Add features from other Dataset to the current Dataset. Both Datasets must be constructed before calling this method. Parameters ---------- other : Dataset The Dataset to take features from. Returns ------- ...
def add_features_from(self, other): """Add features from other Dataset to the current Dataset. Both Datasets must be constructed before calling this method. Parameters ---------- other : Dataset The Dataset to take features from. Returns ------- ...
[ "Add", "features", "from", "other", "Dataset", "to", "the", "current", "Dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1537-L1555
[ "def", "add_features_from", "(", "self", ",", "other", ")", ":", "if", "self", ".", "handle", "is", "None", "or", "other", ".", "handle", "is", "None", ":", "raise", "ValueError", "(", "'Both source and target Datasets must be constructed before adding features'", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Dataset.dump_text
Save Dataset to a text file. This format cannot be loaded back in by LightGBM, but is useful for debugging purposes. Parameters ---------- filename : string Name of the output file. Returns ------- self : Dataset Returns self.
python-package/lightgbm/basic.py
def dump_text(self, filename): """Save Dataset to a text file. This format cannot be loaded back in by LightGBM, but is useful for debugging purposes. Parameters ---------- filename : string Name of the output file. Returns ------- self : Da...
def dump_text(self, filename): """Save Dataset to a text file. This format cannot be loaded back in by LightGBM, but is useful for debugging purposes. Parameters ---------- filename : string Name of the output file. Returns ------- self : Da...
[ "Save", "Dataset", "to", "a", "text", "file", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1557-L1575
[ "def", "dump_text", "(", "self", ",", "filename", ")", ":", "_safe_call", "(", "_LIB", ".", "LGBM_DatasetDumpText", "(", "self", ".", "construct", "(", ")", ".", "handle", ",", "c_str", "(", "filename", ")", ")", ")", "return", "self" ]
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.free_dataset
Free Booster's Datasets. Returns ------- self : Booster Booster without Datasets.
python-package/lightgbm/basic.py
def free_dataset(self): """Free Booster's Datasets. Returns ------- self : Booster Booster without Datasets. """ self.__dict__.pop('train_set', None) self.__dict__.pop('valid_sets', None) self.__num_dataset = 0 return self
def free_dataset(self): """Free Booster's Datasets. Returns ------- self : Booster Booster without Datasets. """ self.__dict__.pop('train_set', None) self.__dict__.pop('valid_sets', None) self.__num_dataset = 0 return self
[ "Free", "Booster", "s", "Datasets", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1719-L1730
[ "def", "free_dataset", "(", "self", ")", ":", "self", ".", "__dict__", ".", "pop", "(", "'train_set'", ",", "None", ")", "self", ".", "__dict__", ".", "pop", "(", "'valid_sets'", ",", "None", ")", "self", ".", "__num_dataset", "=", "0", "return", "self...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.set_network
Set the network configuration. Parameters ---------- machines : list, set or string Names of machines. local_listen_port : int, optional (default=12400) TCP listen port for local machines. listen_time_out : int, optional (default=120) Socket t...
python-package/lightgbm/basic.py
def set_network(self, machines, local_listen_port=12400, listen_time_out=120, num_machines=1): """Set the network configuration. Parameters ---------- machines : list, set or string Names of machines. local_listen_port : int, optional (default=124...
def set_network(self, machines, local_listen_port=12400, listen_time_out=120, num_machines=1): """Set the network configuration. Parameters ---------- machines : list, set or string Names of machines. local_listen_port : int, optional (default=124...
[ "Set", "the", "network", "configuration", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1737-L1762
[ "def", "set_network", "(", "self", ",", "machines", ",", "local_listen_port", "=", "12400", ",", "listen_time_out", "=", "120", ",", "num_machines", "=", "1", ")", ":", "_safe_call", "(", "_LIB", ".", "LGBM_NetworkInit", "(", "c_str", "(", "machines", ")", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.add_valid
Add validation data. Parameters ---------- data : Dataset Validation data. name : string Name of validation data. Returns ------- self : Booster Booster with set validation data.
python-package/lightgbm/basic.py
def add_valid(self, data, name): """Add validation data. Parameters ---------- data : Dataset Validation data. name : string Name of validation data. Returns ------- self : Booster Booster with set validation data. ...
def add_valid(self, data, name): """Add validation data. Parameters ---------- data : Dataset Validation data. name : string Name of validation data. Returns ------- self : Booster Booster with set validation data. ...
[ "Add", "validation", "data", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1792-L1821
[ "def", "add_valid", "(", "self", ",", "data", ",", "name", ")", ":", "if", "not", "isinstance", "(", "data", ",", "Dataset", ")", ":", "raise", "TypeError", "(", "'Validation data should be Dataset instance, met {}'", ".", "format", "(", "type", "(", "data", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.reset_parameter
Reset parameters of Booster. Parameters ---------- params : dict New parameters for Booster. Returns ------- self : Booster Booster with new parameters.
python-package/lightgbm/basic.py
def reset_parameter(self, params): """Reset parameters of Booster. Parameters ---------- params : dict New parameters for Booster. Returns ------- self : Booster Booster with new parameters. """ if any(metric_alias in para...
def reset_parameter(self, params): """Reset parameters of Booster. Parameters ---------- params : dict New parameters for Booster. Returns ------- self : Booster Booster with new parameters. """ if any(metric_alias in para...
[ "Reset", "parameters", "of", "Booster", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1823-L1844
[ "def", "reset_parameter", "(", "self", ",", "params", ")", ":", "if", "any", "(", "metric_alias", "in", "params", "for", "metric_alias", "in", "(", "'metric'", ",", "'metrics'", ",", "'metric_types'", ")", ")", ":", "self", ".", "__need_reload_eval_info", "=...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.update
Update Booster for one iteration. Parameters ---------- train_set : Dataset or None, optional (default=None) Training data. If None, last training data is used. fobj : callable or None, optional (default=None) Customized objective function. ...
python-package/lightgbm/basic.py
def update(self, train_set=None, fobj=None): """Update Booster for one iteration. Parameters ---------- train_set : Dataset or None, optional (default=None) Training data. If None, last training data is used. fobj : callable or None, optional (default=Non...
def update(self, train_set=None, fobj=None): """Update Booster for one iteration. Parameters ---------- train_set : Dataset or None, optional (default=None) Training data. If None, last training data is used. fobj : callable or None, optional (default=Non...
[ "Update", "Booster", "for", "one", "iteration", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1846-L1892
[ "def", "update", "(", "self", ",", "train_set", "=", "None", ",", "fobj", "=", "None", ")", ":", "# need reset training data", "if", "train_set", "is", "not", "None", "and", "train_set", "is", "not", "self", ".", "train_set", ":", "if", "not", "isinstance"...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.__boost
Boost Booster for one iteration with customized gradient statistics. Note ---- For multi-class task, the score is group by class_id first, then group by row_id. If you want to get i-th row score in j-th class, the access way is score[j * num_data + i] and you should group grad a...
python-package/lightgbm/basic.py
def __boost(self, grad, hess): """Boost Booster for one iteration with customized gradient statistics. Note ---- For multi-class task, the score is group by class_id first, then group by row_id. If you want to get i-th row score in j-th class, the access way is score[j * num_dat...
def __boost(self, grad, hess): """Boost Booster for one iteration with customized gradient statistics. Note ---- For multi-class task, the score is group by class_id first, then group by row_id. If you want to get i-th row score in j-th class, the access way is score[j * num_dat...
[ "Boost", "Booster", "for", "one", "iteration", "with", "customized", "gradient", "statistics", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1894-L1929
[ "def", "__boost", "(", "self", ",", "grad", ",", "hess", ")", ":", "grad", "=", "list_to_1d_numpy", "(", "grad", ",", "name", "=", "'gradient'", ")", "hess", "=", "list_to_1d_numpy", "(", "hess", ",", "name", "=", "'hessian'", ")", "assert", "grad", "....
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.rollback_one_iter
Rollback one iteration. Returns ------- self : Booster Booster with rolled back one iteration.
python-package/lightgbm/basic.py
def rollback_one_iter(self): """Rollback one iteration. Returns ------- self : Booster Booster with rolled back one iteration. """ _safe_call(_LIB.LGBM_BoosterRollbackOneIter( self.handle)) self.__is_predicted_cur_iter = [False for _ in ra...
def rollback_one_iter(self): """Rollback one iteration. Returns ------- self : Booster Booster with rolled back one iteration. """ _safe_call(_LIB.LGBM_BoosterRollbackOneIter( self.handle)) self.__is_predicted_cur_iter = [False for _ in ra...
[ "Rollback", "one", "iteration", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1931-L1942
[ "def", "rollback_one_iter", "(", "self", ")", ":", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterRollbackOneIter", "(", "self", ".", "handle", ")", ")", "self", ".", "__is_predicted_cur_iter", "=", "[", "False", "for", "_", "in", "range_", "(", "self", ".", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.current_iteration
Get the index of the current iteration. Returns ------- cur_iter : int The index of the current iteration.
python-package/lightgbm/basic.py
def current_iteration(self): """Get the index of the current iteration. Returns ------- cur_iter : int The index of the current iteration. """ out_cur_iter = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterGetCurrentIteration( self.handle, ...
def current_iteration(self): """Get the index of the current iteration. Returns ------- cur_iter : int The index of the current iteration. """ out_cur_iter = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterGetCurrentIteration( self.handle, ...
[ "Get", "the", "index", "of", "the", "current", "iteration", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1944-L1956
[ "def", "current_iteration", "(", "self", ")", ":", "out_cur_iter", "=", "ctypes", ".", "c_int", "(", "0", ")", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterGetCurrentIteration", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "out_cur_iter", ")...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.num_model_per_iteration
Get number of models per iteration. Returns ------- model_per_iter : int The number of models per iteration.
python-package/lightgbm/basic.py
def num_model_per_iteration(self): """Get number of models per iteration. Returns ------- model_per_iter : int The number of models per iteration. """ model_per_iter = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterNumModelPerIteration( self....
def num_model_per_iteration(self): """Get number of models per iteration. Returns ------- model_per_iter : int The number of models per iteration. """ model_per_iter = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterNumModelPerIteration( self....
[ "Get", "number", "of", "models", "per", "iteration", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1958-L1970
[ "def", "num_model_per_iteration", "(", "self", ")", ":", "model_per_iter", "=", "ctypes", ".", "c_int", "(", "0", ")", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterNumModelPerIteration", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "model_per_...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.num_trees
Get number of weak sub-models. Returns ------- num_trees : int The number of weak sub-models.
python-package/lightgbm/basic.py
def num_trees(self): """Get number of weak sub-models. Returns ------- num_trees : int The number of weak sub-models. """ num_trees = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterNumberOfTotalModel( self.handle, ctypes.byref(num...
def num_trees(self): """Get number of weak sub-models. Returns ------- num_trees : int The number of weak sub-models. """ num_trees = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterNumberOfTotalModel( self.handle, ctypes.byref(num...
[ "Get", "number", "of", "weak", "sub", "-", "models", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1972-L1984
[ "def", "num_trees", "(", "self", ")", ":", "num_trees", "=", "ctypes", ".", "c_int", "(", "0", ")", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterNumberOfTotalModel", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "num_trees", ")", ")", ")"...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.eval
Evaluate for data. Parameters ---------- data : Dataset Data for the evaluating. name : string Name of the data. feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds,...
python-package/lightgbm/basic.py
def eval(self, data, name, feval=None): """Evaluate for data. Parameters ---------- data : Dataset Data for the evaluating. name : string Name of the data. feval : callable or None, optional (default=None) Customized evaluation functio...
def eval(self, data, name, feval=None): """Evaluate for data. Parameters ---------- data : Dataset Data for the evaluating. name : string Name of the data. feval : callable or None, optional (default=None) Customized evaluation functio...
[ "Evaluate", "for", "data", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1986-L2022
[ "def", "eval", "(", "self", ",", "data", ",", "name", ",", "feval", "=", "None", ")", ":", "if", "not", "isinstance", "(", "data", ",", "Dataset", ")", ":", "raise", "TypeError", "(", "\"Can only eval for Dataset instance\"", ")", "data_idx", "=", "-", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.eval_valid
Evaluate for validation data. Parameters ---------- feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_result, is_higher_better) or list of such tuples...
python-package/lightgbm/basic.py
def eval_valid(self, feval=None): """Evaluate for validation data. Parameters ---------- feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_res...
def eval_valid(self, feval=None): """Evaluate for validation data. Parameters ---------- feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_res...
[ "Evaluate", "for", "validation", "data", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2043-L2061
[ "def", "eval_valid", "(", "self", ",", "feval", "=", "None", ")", ":", "return", "[", "item", "for", "i", "in", "range_", "(", "1", ",", "self", ".", "__num_dataset", ")", "for", "item", "in", "self", ".", "__inner_eval", "(", "self", ".", "name_vali...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.save_model
Save Booster to file. Parameters ---------- filename : string Filename to save Booster. num_iteration : int or None, optional (default=None) Index of the iteration that should be saved. If None, if the best iteration exists, it is saved; otherwise, al...
python-package/lightgbm/basic.py
def save_model(self, filename, num_iteration=None, start_iteration=0): """Save Booster to file. Parameters ---------- filename : string Filename to save Booster. num_iteration : int or None, optional (default=None) Index of the iteration that should be sa...
def save_model(self, filename, num_iteration=None, start_iteration=0): """Save Booster to file. Parameters ---------- filename : string Filename to save Booster. num_iteration : int or None, optional (default=None) Index of the iteration that should be sa...
[ "Save", "Booster", "to", "file", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2063-L2090
[ "def", "save_model", "(", "self", ",", "filename", ",", "num_iteration", "=", "None", ",", "start_iteration", "=", "0", ")", ":", "if", "num_iteration", "is", "None", ":", "num_iteration", "=", "self", ".", "best_iteration", "_safe_call", "(", "_LIB", ".", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.shuffle_models
Shuffle models. Parameters ---------- start_iteration : int, optional (default=0) The first iteration that will be shuffled. end_iteration : int, optional (default=-1) The last iteration that will be shuffled. If <= 0, means the last available iterati...
python-package/lightgbm/basic.py
def shuffle_models(self, start_iteration=0, end_iteration=-1): """Shuffle models. Parameters ---------- start_iteration : int, optional (default=0) The first iteration that will be shuffled. end_iteration : int, optional (default=-1) The last iteration th...
def shuffle_models(self, start_iteration=0, end_iteration=-1): """Shuffle models. Parameters ---------- start_iteration : int, optional (default=0) The first iteration that will be shuffled. end_iteration : int, optional (default=-1) The last iteration th...
[ "Shuffle", "models", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2092-L2112
[ "def", "shuffle_models", "(", "self", ",", "start_iteration", "=", "0", ",", "end_iteration", "=", "-", "1", ")", ":", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterShuffleModels", "(", "self", ".", "handle", ",", "ctypes", ".", "c_int", "(", "start_iteration...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.model_from_string
Load Booster from a string. Parameters ---------- model_str : string Model will be loaded from this string. verbose : bool, optional (default=True) Whether to print messages while loading model. Returns ------- self : Booster ...
python-package/lightgbm/basic.py
def model_from_string(self, model_str, verbose=True): """Load Booster from a string. Parameters ---------- model_str : string Model will be loaded from this string. verbose : bool, optional (default=True) Whether to print messages while loading model. ...
def model_from_string(self, model_str, verbose=True): """Load Booster from a string. Parameters ---------- model_str : string Model will be loaded from this string. verbose : bool, optional (default=True) Whether to print messages while loading model. ...
[ "Load", "Booster", "from", "a", "string", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2114-L2146
[ "def", "model_from_string", "(", "self", ",", "model_str", ",", "verbose", "=", "True", ")", ":", "if", "self", ".", "handle", "is", "not", "None", ":", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterFree", "(", "self", ".", "handle", ")", ")", "self", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.model_to_string
Save Booster to string. Parameters ---------- num_iteration : int or None, optional (default=None) Index of the iteration that should be saved. If None, if the best iteration exists, it is saved; otherwise, all iterations are saved. If <= 0, all iterations ar...
python-package/lightgbm/basic.py
def model_to_string(self, num_iteration=None, start_iteration=0): """Save Booster to string. Parameters ---------- num_iteration : int or None, optional (default=None) Index of the iteration that should be saved. If None, if the best iteration exists, it is saved...
def model_to_string(self, num_iteration=None, start_iteration=0): """Save Booster to string. Parameters ---------- num_iteration : int or None, optional (default=None) Index of the iteration that should be saved. If None, if the best iteration exists, it is saved...
[ "Save", "Booster", "to", "string", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2148-L2192
[ "def", "model_to_string", "(", "self", ",", "num_iteration", "=", "None", ",", "start_iteration", "=", "0", ")", ":", "if", "num_iteration", "is", "None", ":", "num_iteration", "=", "self", ".", "best_iteration", "buffer_len", "=", "1", "<<", "20", "tmp_out_...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.dump_model
Dump Booster to JSON format. Parameters ---------- num_iteration : int or None, optional (default=None) Index of the iteration that should be dumped. If None, if the best iteration exists, it is dumped; otherwise, all iterations are dumped. If <= 0, all itera...
python-package/lightgbm/basic.py
def dump_model(self, num_iteration=None, start_iteration=0): """Dump Booster to JSON format. Parameters ---------- num_iteration : int or None, optional (default=None) Index of the iteration that should be dumped. If None, if the best iteration exists, it is dump...
def dump_model(self, num_iteration=None, start_iteration=0): """Dump Booster to JSON format. Parameters ---------- num_iteration : int or None, optional (default=None) Index of the iteration that should be dumped. If None, if the best iteration exists, it is dump...
[ "Dump", "Booster", "to", "JSON", "format", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2194-L2239
[ "def", "dump_model", "(", "self", ",", "num_iteration", "=", "None", ",", "start_iteration", "=", "0", ")", ":", "if", "num_iteration", "is", "None", ":", "num_iteration", "=", "self", ".", "best_iteration", "buffer_len", "=", "1", "<<", "20", "tmp_out_len",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.predict
Make a prediction. Parameters ---------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse Data source for prediction. If string, it represents the path to txt file. num_iteration : int or None, optional (default=None) ...
python-package/lightgbm/basic.py
def predict(self, data, num_iteration=None, raw_score=False, pred_leaf=False, pred_contrib=False, data_has_header=False, is_reshape=True, **kwargs): """Make a prediction. Parameters ---------- data : string, numpy array, pandas DataFrame, H2O DataTable's ...
def predict(self, data, num_iteration=None, raw_score=False, pred_leaf=False, pred_contrib=False, data_has_header=False, is_reshape=True, **kwargs): """Make a prediction. Parameters ---------- data : string, numpy array, pandas DataFrame, H2O DataTable's ...
[ "Make", "a", "prediction", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2241-L2288
[ "def", "predict", "(", "self", ",", "data", ",", "num_iteration", "=", "None", ",", "raw_score", "=", "False", ",", "pred_leaf", "=", "False", ",", "pred_contrib", "=", "False", ",", "data_has_header", "=", "False", ",", "is_reshape", "=", "True", ",", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.refit
Refit the existing Booster by new data. Parameters ---------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse Data source for refit. If string, it represents the path to txt file. label : list, numpy 1-D array or pandas Series ...
python-package/lightgbm/basic.py
def refit(self, data, label, decay_rate=0.9, **kwargs): """Refit the existing Booster by new data. Parameters ---------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse Data source for refit. If string, it represents the path t...
def refit(self, data, label, decay_rate=0.9, **kwargs): """Refit the existing Booster by new data. Parameters ---------- data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse Data source for refit. If string, it represents the path t...
[ "Refit", "the", "existing", "Booster", "by", "new", "data", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2290-L2332
[ "def", "refit", "(", "self", ",", "data", ",", "label", ",", "decay_rate", "=", "0.9", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "__set_objective_to_none", ":", "raise", "LightGBMError", "(", "'Cannot refit due to null objective function.'", ")", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.get_leaf_output
Get the output of a leaf. Parameters ---------- tree_id : int The index of the tree. leaf_id : int The index of the leaf in the tree. Returns ------- result : float The output of the leaf.
python-package/lightgbm/basic.py
def get_leaf_output(self, tree_id, leaf_id): """Get the output of a leaf. Parameters ---------- tree_id : int The index of the tree. leaf_id : int The index of the leaf in the tree. Returns ------- result : float The o...
def get_leaf_output(self, tree_id, leaf_id): """Get the output of a leaf. Parameters ---------- tree_id : int The index of the tree. leaf_id : int The index of the leaf in the tree. Returns ------- result : float The o...
[ "Get", "the", "output", "of", "a", "leaf", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2334-L2355
[ "def", "get_leaf_output", "(", "self", ",", "tree_id", ",", "leaf_id", ")", ":", "ret", "=", "ctypes", ".", "c_double", "(", "0", ")", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterGetLeafValue", "(", "self", ".", "handle", ",", "ctypes", ".", "c_int", "(...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster._to_predictor
Convert to predictor.
python-package/lightgbm/basic.py
def _to_predictor(self, pred_parameter=None): """Convert to predictor.""" predictor = _InnerPredictor(booster_handle=self.handle, pred_parameter=pred_parameter) predictor.pandas_categorical = self.pandas_categorical return predictor
def _to_predictor(self, pred_parameter=None): """Convert to predictor.""" predictor = _InnerPredictor(booster_handle=self.handle, pred_parameter=pred_parameter) predictor.pandas_categorical = self.pandas_categorical return predictor
[ "Convert", "to", "predictor", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2357-L2361
[ "def", "_to_predictor", "(", "self", ",", "pred_parameter", "=", "None", ")", ":", "predictor", "=", "_InnerPredictor", "(", "booster_handle", "=", "self", ".", "handle", ",", "pred_parameter", "=", "pred_parameter", ")", "predictor", ".", "pandas_categorical", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.num_feature
Get number of features. Returns ------- num_feature : int The number of features.
python-package/lightgbm/basic.py
def num_feature(self): """Get number of features. Returns ------- num_feature : int The number of features. """ out_num_feature = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterGetNumFeature( self.handle, ctypes.byref(out_num_feat...
def num_feature(self): """Get number of features. Returns ------- num_feature : int The number of features. """ out_num_feature = ctypes.c_int(0) _safe_call(_LIB.LGBM_BoosterGetNumFeature( self.handle, ctypes.byref(out_num_feat...
[ "Get", "number", "of", "features", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2363-L2375
[ "def", "num_feature", "(", "self", ")", ":", "out_num_feature", "=", "ctypes", ".", "c_int", "(", "0", ")", "_safe_call", "(", "_LIB", ".", "LGBM_BoosterGetNumFeature", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "out_num_feature", ")", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.feature_name
Get names of features. Returns ------- result : list List with names of features.
python-package/lightgbm/basic.py
def feature_name(self): """Get names of features. Returns ------- result : list List with names of features. """ num_feature = self.num_feature() # Get name of features tmp_out_len = ctypes.c_int(0) string_buffers = [ctypes.create_stri...
def feature_name(self): """Get names of features. Returns ------- result : list List with names of features. """ num_feature = self.num_feature() # Get name of features tmp_out_len = ctypes.c_int(0) string_buffers = [ctypes.create_stri...
[ "Get", "names", "of", "features", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2377-L2396
[ "def", "feature_name", "(", "self", ")", ":", "num_feature", "=", "self", ".", "num_feature", "(", ")", "# Get name of features", "tmp_out_len", "=", "ctypes", ".", "c_int", "(", "0", ")", "string_buffers", "=", "[", "ctypes", ".", "create_string_buffer", "(",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.feature_importance
Get feature importances. Parameters ---------- importance_type : string, optional (default="split") How the importance is calculated. If "split", result contains numbers of times the feature is used in a model. If "gain", result contains total gains of splits...
python-package/lightgbm/basic.py
def feature_importance(self, importance_type='split', iteration=None): """Get feature importances. Parameters ---------- importance_type : string, optional (default="split") How the importance is calculated. If "split", result contains numbers of times the featur...
def feature_importance(self, importance_type='split', iteration=None): """Get feature importances. Parameters ---------- importance_type : string, optional (default="split") How the importance is calculated. If "split", result contains numbers of times the featur...
[ "Get", "feature", "importances", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2398-L2434
[ "def", "feature_importance", "(", "self", ",", "importance_type", "=", "'split'", ",", "iteration", "=", "None", ")", ":", "if", "iteration", "is", "None", ":", "iteration", "=", "self", ".", "best_iteration", "if", "importance_type", "==", "\"split\"", ":", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.get_split_value_histogram
Get split value histogram for the specified feature. Parameters ---------- feature : int or string The feature name or index the histogram is calculated for. If int, interpreted as index. If string, interpreted as name. Note ---- ...
python-package/lightgbm/basic.py
def get_split_value_histogram(self, feature, bins=None, xgboost_style=False): """Get split value histogram for the specified feature. Parameters ---------- feature : int or string The feature name or index the histogram is calculated for. If int, interpreted as i...
def get_split_value_histogram(self, feature, bins=None, xgboost_style=False): """Get split value histogram for the specified feature. Parameters ---------- feature : int or string The feature name or index the histogram is calculated for. If int, interpreted as i...
[ "Get", "split", "value", "histogram", "for", "the", "specified", "feature", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2436-L2503
[ "def", "get_split_value_histogram", "(", "self", ",", "feature", ",", "bins", "=", "None", ",", "xgboost_style", "=", "False", ")", ":", "def", "add", "(", "root", ")", ":", "\"\"\"Recursively add thresholds.\"\"\"", "if", "'split_index'", "in", "root", ":", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.__inner_eval
Evaluate training or validation data.
python-package/lightgbm/basic.py
def __inner_eval(self, data_name, data_idx, feval=None): """Evaluate training or validation data.""" if data_idx >= self.__num_dataset: raise ValueError("Data_idx should be smaller than number of dataset") self.__get_eval_info() ret = [] if self.__num_inner_eval > 0: ...
def __inner_eval(self, data_name, data_idx, feval=None): """Evaluate training or validation data.""" if data_idx >= self.__num_dataset: raise ValueError("Data_idx should be smaller than number of dataset") self.__get_eval_info() ret = [] if self.__num_inner_eval > 0: ...
[ "Evaluate", "training", "or", "validation", "data", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2505-L2536
[ "def", "__inner_eval", "(", "self", ",", "data_name", ",", "data_idx", ",", "feval", "=", "None", ")", ":", "if", "data_idx", ">=", "self", ".", "__num_dataset", ":", "raise", "ValueError", "(", "\"Data_idx should be smaller than number of dataset\"", ")", "self",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.__inner_predict
Predict for training and validation dataset.
python-package/lightgbm/basic.py
def __inner_predict(self, data_idx): """Predict for training and validation dataset.""" if data_idx >= self.__num_dataset: raise ValueError("Data_idx should be smaller than number of dataset") if self.__inner_predict_buffer[data_idx] is None: if data_idx == 0: ...
def __inner_predict(self, data_idx): """Predict for training and validation dataset.""" if data_idx >= self.__num_dataset: raise ValueError("Data_idx should be smaller than number of dataset") if self.__inner_predict_buffer[data_idx] is None: if data_idx == 0: ...
[ "Predict", "for", "training", "and", "validation", "dataset", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2538-L2560
[ "def", "__inner_predict", "(", "self", ",", "data_idx", ")", ":", "if", "data_idx", ">=", "self", ".", "__num_dataset", ":", "raise", "ValueError", "(", "\"Data_idx should be smaller than number of dataset\"", ")", "if", "self", ".", "__inner_predict_buffer", "[", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.__get_eval_info
Get inner evaluation count and names.
python-package/lightgbm/basic.py
def __get_eval_info(self): """Get inner evaluation count and names.""" if self.__need_reload_eval_info: self.__need_reload_eval_info = False out_num_eval = ctypes.c_int(0) # Get num of inner evals _safe_call(_LIB.LGBM_BoosterGetEvalCounts( ...
def __get_eval_info(self): """Get inner evaluation count and names.""" if self.__need_reload_eval_info: self.__need_reload_eval_info = False out_num_eval = ctypes.c_int(0) # Get num of inner evals _safe_call(_LIB.LGBM_BoosterGetEvalCounts( ...
[ "Get", "inner", "evaluation", "count", "and", "names", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2562-L2586
[ "def", "__get_eval_info", "(", "self", ")", ":", "if", "self", ".", "__need_reload_eval_info", ":", "self", ".", "__need_reload_eval_info", "=", "False", "out_num_eval", "=", "ctypes", ".", "c_int", "(", "0", ")", "# Get num of inner evals", "_safe_call", "(", "...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
Booster.set_attr
Set attributes to the Booster. Parameters ---------- **kwargs The attributes to set. Setting a value to None deletes an attribute. Returns ------- self : Booster Booster with set attributes.
python-package/lightgbm/basic.py
def set_attr(self, **kwargs): """Set attributes to the Booster. Parameters ---------- **kwargs The attributes to set. Setting a value to None deletes an attribute. Returns ------- self : Booster Booster with set attributes. ...
def set_attr(self, **kwargs): """Set attributes to the Booster. Parameters ---------- **kwargs The attributes to set. Setting a value to None deletes an attribute. Returns ------- self : Booster Booster with set attributes. ...
[ "Set", "attributes", "to", "the", "Booster", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2604-L2625
[ "def", "set_attr", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "value", "is", "not", "None", ":", "if", "not", "isinstance", "(", "value", ",", "string_type", ")", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
find_lib_path
Find the path to LightGBM library files. Returns ------- lib_path: list of strings List of all found library paths to LightGBM.
python-package/lightgbm/libpath.py
def find_lib_path(): """Find the path to LightGBM library files. Returns ------- lib_path: list of strings List of all found library paths to LightGBM. """ if os.environ.get('LIGHTGBM_BUILD_DOC', False): # we don't need lib_lightgbm while building docs return [] curr...
def find_lib_path(): """Find the path to LightGBM library files. Returns ------- lib_path: list of strings List of all found library paths to LightGBM. """ if os.environ.get('LIGHTGBM_BUILD_DOC', False): # we don't need lib_lightgbm while building docs return [] curr...
[ "Find", "the", "path", "to", "LightGBM", "library", "files", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/libpath.py#L8-L38
[ "def", "find_lib_path", "(", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "'LIGHTGBM_BUILD_DOC'", ",", "False", ")", ":", "# we don't need lib_lightgbm while building docs", "return", "[", "]", "curr_path", "=", "os", ".", "path", ".", "dirname", "("...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
json_default_with_numpy
Convert numpy classes to JSON serializable objects.
python-package/lightgbm/compat.py
def json_default_with_numpy(obj): """Convert numpy classes to JSON serializable objects.""" if isinstance(obj, (np.integer, np.floating, np.bool_)): return obj.item() elif isinstance(obj, np.ndarray): return obj.tolist() else: return obj
def json_default_with_numpy(obj): """Convert numpy classes to JSON serializable objects.""" if isinstance(obj, (np.integer, np.floating, np.bool_)): return obj.item() elif isinstance(obj, np.ndarray): return obj.tolist() else: return obj
[ "Convert", "numpy", "classes", "to", "JSON", "serializable", "objects", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/compat.py#L52-L59
[ "def", "json_default_with_numpy", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "np", ".", "integer", ",", "np", ".", "floating", ",", "np", ".", "bool_", ")", ")", ":", "return", "obj", ".", "item", "(", ")", "elif", "isinstance", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
_format_eval_result
Format metric string.
python-package/lightgbm/callback.py
def _format_eval_result(value, show_stdv=True): """Format metric string.""" if len(value) == 4: return '%s\'s %s: %g' % (value[0], value[1], value[2]) elif len(value) == 5: if show_stdv: return '%s\'s %s: %g + %g' % (value[0], value[1], value[2], value[4]) else: ...
def _format_eval_result(value, show_stdv=True): """Format metric string.""" if len(value) == 4: return '%s\'s %s: %g' % (value[0], value[1], value[2]) elif len(value) == 5: if show_stdv: return '%s\'s %s: %g + %g' % (value[0], value[1], value[2], value[4]) else: ...
[ "Format", "metric", "string", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L42-L52
[ "def", "_format_eval_result", "(", "value", ",", "show_stdv", "=", "True", ")", ":", "if", "len", "(", "value", ")", "==", "4", ":", "return", "'%s\\'s %s: %g'", "%", "(", "value", "[", "0", "]", ",", "value", "[", "1", "]", ",", "value", "[", "2",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
print_evaluation
Create a callback that prints the evaluation results. Parameters ---------- period : int, optional (default=1) The period to print the evaluation results. show_stdv : bool, optional (default=True) Whether to show stdv (if provided). Returns ------- callback : function ...
python-package/lightgbm/callback.py
def print_evaluation(period=1, show_stdv=True): """Create a callback that prints the evaluation results. Parameters ---------- period : int, optional (default=1) The period to print the evaluation results. show_stdv : bool, optional (default=True) Whether to show stdv (if provided)....
def print_evaluation(period=1, show_stdv=True): """Create a callback that prints the evaluation results. Parameters ---------- period : int, optional (default=1) The period to print the evaluation results. show_stdv : bool, optional (default=True) Whether to show stdv (if provided)....
[ "Create", "a", "callback", "that", "prints", "the", "evaluation", "results", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L55-L75
[ "def", "print_evaluation", "(", "period", "=", "1", ",", "show_stdv", "=", "True", ")", ":", "def", "_callback", "(", "env", ")", ":", "if", "period", ">", "0", "and", "env", ".", "evaluation_result_list", "and", "(", "env", ".", "iteration", "+", "1",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
record_evaluation
Create a callback that records the evaluation history into ``eval_result``. Parameters ---------- eval_result : dict A dictionary to store the evaluation results. Returns ------- callback : function The callback that records the evaluation history into the passed dictionary.
python-package/lightgbm/callback.py
def record_evaluation(eval_result): """Create a callback that records the evaluation history into ``eval_result``. Parameters ---------- eval_result : dict A dictionary to store the evaluation results. Returns ------- callback : function The callback that records the evaluat...
def record_evaluation(eval_result): """Create a callback that records the evaluation history into ``eval_result``. Parameters ---------- eval_result : dict A dictionary to store the evaluation results. Returns ------- callback : function The callback that records the evaluat...
[ "Create", "a", "callback", "that", "records", "the", "evaluation", "history", "into", "eval_result", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L78-L105
[ "def", "record_evaluation", "(", "eval_result", ")", ":", "if", "not", "isinstance", "(", "eval_result", ",", "dict", ")", ":", "raise", "TypeError", "(", "'Eval_result should be a dictionary'", ")", "eval_result", ".", "clear", "(", ")", "def", "_init", "(", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
reset_parameter
Create a callback that resets the parameter after the first iteration. Note ---- The initial parameter will still take in-effect on first iteration. Parameters ---------- **kwargs : value should be list or function List of parameters for each boosting round or a customized func...
python-package/lightgbm/callback.py
def reset_parameter(**kwargs): """Create a callback that resets the parameter after the first iteration. Note ---- The initial parameter will still take in-effect on first iteration. Parameters ---------- **kwargs : value should be list or function List of parameters for each boost...
def reset_parameter(**kwargs): """Create a callback that resets the parameter after the first iteration. Note ---- The initial parameter will still take in-effect on first iteration. Parameters ---------- **kwargs : value should be list or function List of parameters for each boost...
[ "Create", "a", "callback", "that", "resets", "the", "parameter", "after", "the", "first", "iteration", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L108-L150
[ "def", "reset_parameter", "(", "*", "*", "kwargs", ")", ":", "def", "_callback", "(", "env", ")", ":", "new_parameters", "=", "{", "}", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "key", "in", "[", "'num_class'", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
early_stopping
Create a callback that activates early stopping. Note ---- Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_rounds`` round(s) to continue training. Requires at least one validation da...
python-package/lightgbm/callback.py
def early_stopping(stopping_rounds, first_metric_only=False, verbose=True): """Create a callback that activates early stopping. Note ---- Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_...
def early_stopping(stopping_rounds, first_metric_only=False, verbose=True): """Create a callback that activates early stopping. Note ---- Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_...
[ "Create", "a", "callback", "that", "activates", "early", "stopping", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L153-L236
[ "def", "early_stopping", "(", "stopping_rounds", ",", "first_metric_only", "=", "False", ",", "verbose", "=", "True", ")", ":", "best_score", "=", "[", "]", "best_iter", "=", "[", "]", "best_score_list", "=", "[", "]", "cmp_op", "=", "[", "]", "enabled", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
train
Perform the training with given parameters. Parameters ---------- params : dict Parameters for training. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. valid_sets : list of Datasets or None, optiona...
python-package/lightgbm/engine.py
def train(params, train_set, num_boost_round=100, valid_sets=None, valid_names=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, evals_result=None, verbose_eval=True, learning_rates=None, ...
def train(params, train_set, num_boost_round=100, valid_sets=None, valid_names=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, evals_result=None, verbose_eval=True, learning_rates=None, ...
[ "Perform", "the", "training", "with", "given", "parameters", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L19-L245
[ "def", "train", "(", "params", ",", "train_set", ",", "num_boost_round", "=", "100", ",", "valid_sets", "=", "None", ",", "valid_names", "=", "None", ",", "fobj", "=", "None", ",", "feval", "=", "None", ",", "init_model", "=", "None", ",", "feature_name"...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
_make_n_folds
Make a n-fold list of Booster from random indices.
python-package/lightgbm/engine.py
def _make_n_folds(full_data, folds, nfold, params, seed, fpreproc=None, stratified=True, shuffle=True, eval_train_metric=False): """Make a n-fold list of Booster from random indices.""" full_data = full_data.construct() num_data = full_data.num_data() if folds is not None: if n...
def _make_n_folds(full_data, folds, nfold, params, seed, fpreproc=None, stratified=True, shuffle=True, eval_train_metric=False): """Make a n-fold list of Booster from random indices.""" full_data = full_data.construct() num_data = full_data.num_data() if folds is not None: if n...
[ "Make", "a", "n", "-", "fold", "list", "of", "Booster", "from", "random", "indices", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L270-L325
[ "def", "_make_n_folds", "(", "full_data", ",", "folds", ",", "nfold", ",", "params", ",", "seed", ",", "fpreproc", "=", "None", ",", "stratified", "=", "True", ",", "shuffle", "=", "True", ",", "eval_train_metric", "=", "False", ")", ":", "full_data", "=...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
_agg_cv_result
Aggregate cross-validation results.
python-package/lightgbm/engine.py
def _agg_cv_result(raw_results, eval_train_metric=False): """Aggregate cross-validation results.""" cvmap = collections.defaultdict(list) metric_type = {} for one_result in raw_results: for one_line in one_result: if eval_train_metric: key = "{} {}".format(one_line[0]...
def _agg_cv_result(raw_results, eval_train_metric=False): """Aggregate cross-validation results.""" cvmap = collections.defaultdict(list) metric_type = {} for one_result in raw_results: for one_line in one_result: if eval_train_metric: key = "{} {}".format(one_line[0]...
[ "Aggregate", "cross", "-", "validation", "results", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L328-L340
[ "def", "_agg_cv_result", "(", "raw_results", ",", "eval_train_metric", "=", "False", ")", ":", "cvmap", "=", "collections", ".", "defaultdict", "(", "list", ")", "metric_type", "=", "{", "}", "for", "one_result", "in", "raw_results", ":", "for", "one_line", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
cv
Perform the cross-validation with given paramaters. Parameters ---------- params : dict Parameters for Booster. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. folds : generator or iterator of (train...
python-package/lightgbm/engine.py
def cv(params, train_set, num_boost_round=100, folds=None, nfold=5, stratified=True, shuffle=True, metrics=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, fpreproc=None, verbose_eval=None, show_stdv=True, seed=...
def cv(params, train_set, num_boost_round=100, folds=None, nfold=5, stratified=True, shuffle=True, metrics=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, fpreproc=None, verbose_eval=None, show_stdv=True, seed=...
[ "Perform", "the", "cross", "-", "validation", "with", "given", "paramaters", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L343-L520
[ "def", "cv", "(", "params", ",", "train_set", ",", "num_boost_round", "=", "100", ",", "folds", "=", "None", ",", "nfold", "=", "5", ",", "stratified", "=", "True", ",", "shuffle", "=", "True", ",", "metrics", "=", "None", ",", "fobj", "=", "None", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
log_loss
Logarithmic loss with non-necessarily-binary labels.
examples/python-guide/logistic_regression.py
def log_loss(preds, labels): """Logarithmic loss with non-necessarily-binary labels.""" log_likelihood = np.sum(labels * np.log(preds)) / len(preds) return -log_likelihood
def log_loss(preds, labels): """Logarithmic loss with non-necessarily-binary labels.""" log_likelihood = np.sum(labels * np.log(preds)) / len(preds) return -log_likelihood
[ "Logarithmic", "loss", "with", "non", "-", "necessarily", "-", "binary", "labels", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/examples/python-guide/logistic_regression.py#L49-L52
[ "def", "log_loss", "(", "preds", ",", "labels", ")", ":", "log_likelihood", "=", "np", ".", "sum", "(", "labels", "*", "np", ".", "log", "(", "preds", ")", ")", "/", "len", "(", "preds", ")", "return", "-", "log_likelihood" ]
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
experiment
Measure performance of an objective. Parameters ---------- objective : string 'binary' or 'xentropy' Objective function. label_type : string 'binary' or 'probability' Type of the label. data : dict Data for training. Returns ------- result : dict Experim...
examples/python-guide/logistic_regression.py
def experiment(objective, label_type, data): """Measure performance of an objective. Parameters ---------- objective : string 'binary' or 'xentropy' Objective function. label_type : string 'binary' or 'probability' Type of the label. data : dict Data for training. R...
def experiment(objective, label_type, data): """Measure performance of an objective. Parameters ---------- objective : string 'binary' or 'xentropy' Objective function. label_type : string 'binary' or 'probability' Type of the label. data : dict Data for training. R...
[ "Measure", "performance", "of", "an", "objective", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/examples/python-guide/logistic_regression.py#L55-L90
[ "def", "experiment", "(", "objective", ",", "label_type", ",", "data", ")", ":", "np", ".", "random", ".", "seed", "(", "0", ")", "nrounds", "=", "5", "lgb_data", "=", "data", "[", "'lgb_with_'", "+", "label_type", "+", "'_labels'", "]", "params", "=",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
_check_not_tuple_of_2_elements
Check object is not tuple or does not have 2 elements.
python-package/lightgbm/plotting.py
def _check_not_tuple_of_2_elements(obj, obj_name='obj'): """Check object is not tuple or does not have 2 elements.""" if not isinstance(obj, tuple) or len(obj) != 2: raise TypeError('%s must be a tuple of 2 elements.' % obj_name)
def _check_not_tuple_of_2_elements(obj, obj_name='obj'): """Check object is not tuple or does not have 2 elements.""" if not isinstance(obj, tuple) or len(obj) != 2: raise TypeError('%s must be a tuple of 2 elements.' % obj_name)
[ "Check", "object", "is", "not", "tuple", "or", "does", "not", "have", "2", "elements", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L18-L21
[ "def", "_check_not_tuple_of_2_elements", "(", "obj", ",", "obj_name", "=", "'obj'", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "tuple", ")", "or", "len", "(", "obj", ")", "!=", "2", ":", "raise", "TypeError", "(", "'%s must be a tuple of 2 element...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
plot_importance
Plot model's feature importances. Parameters ---------- booster : Booster or LGBMModel Booster or LGBMModel instance which feature importance should be plotted. ax : matplotlib.axes.Axes or None, optional (default=None) Target axes instance. If None, new figure and axes will be ...
python-package/lightgbm/plotting.py
def plot_importance(booster, ax=None, height=0.2, xlim=None, ylim=None, title='Feature importance', xlabel='Feature importance', ylabel='Features', importance_type='split', max_num_features=None, ignore_zero=True, figsize=None, grid=True, ...
def plot_importance(booster, ax=None, height=0.2, xlim=None, ylim=None, title='Feature importance', xlabel='Feature importance', ylabel='Features', importance_type='split', max_num_features=None, ignore_zero=True, figsize=None, grid=True, ...
[ "Plot", "model", "s", "feature", "importances", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L30-L141
[ "def", "plot_importance", "(", "booster", ",", "ax", "=", "None", ",", "height", "=", "0.2", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "title", "=", "'Feature importance'", ",", "xlabel", "=", "'Feature importance'", ",", "ylabel", "=", "'...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
plot_metric
Plot one metric during training. Parameters ---------- booster : dict or LGBMModel Dictionary returned from ``lightgbm.train()`` or LGBMModel instance. metric : string or None, optional (default=None) The metric name to plot. Only one metric supported because different metrics h...
python-package/lightgbm/plotting.py
def plot_metric(booster, metric=None, dataset_names=None, ax=None, xlim=None, ylim=None, title='Metric during training', xlabel='Iterations', ylabel='auto', figsize=None, grid=True): """Plot one metric during training. Parameters ---------- ...
def plot_metric(booster, metric=None, dataset_names=None, ax=None, xlim=None, ylim=None, title='Metric during training', xlabel='Iterations', ylabel='auto', figsize=None, grid=True): """Plot one metric during training. Parameters ---------- ...
[ "Plot", "one", "metric", "during", "training", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L144-L265
[ "def", "plot_metric", "(", "booster", ",", "metric", "=", "None", ",", "dataset_names", "=", "None", ",", "ax", "=", "None", ",", "xlim", "=", "None", ",", "ylim", "=", "None", ",", "title", "=", "'Metric during training'", ",", "xlabel", "=", "'Iteratio...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
_to_graphviz
Convert specified tree to graphviz instance. See: - https://graphviz.readthedocs.io/en/stable/api.html#digraph
python-package/lightgbm/plotting.py
def _to_graphviz(tree_info, show_info, feature_names, precision=None, **kwargs): """Convert specified tree to graphviz instance. See: - https://graphviz.readthedocs.io/en/stable/api.html#digraph """ if GRAPHVIZ_INSTALLED: from graphviz import Digraph else: raise ImportError('Y...
def _to_graphviz(tree_info, show_info, feature_names, precision=None, **kwargs): """Convert specified tree to graphviz instance. See: - https://graphviz.readthedocs.io/en/stable/api.html#digraph """ if GRAPHVIZ_INSTALLED: from graphviz import Digraph else: raise ImportError('Y...
[ "Convert", "specified", "tree", "to", "graphviz", "instance", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L268-L315
[ "def", "_to_graphviz", "(", "tree_info", ",", "show_info", ",", "feature_names", ",", "precision", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "GRAPHVIZ_INSTALLED", ":", "from", "graphviz", "import", "Digraph", "else", ":", "raise", "ImportError", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
create_tree_digraph
Create a digraph representation of specified tree. Note ---- For more information please visit https://graphviz.readthedocs.io/en/stable/api.html#digraph. Parameters ---------- booster : Booster or LGBMModel Booster or LGBMModel instance to be converted. tree_index : int, optio...
python-package/lightgbm/plotting.py
def create_tree_digraph(booster, tree_index=0, show_info=None, precision=None, old_name=None, old_comment=None, old_filename=None, old_directory=None, old_format=None, old_engine=None, old_encoding=None, old_graph_attr=None, old_node_attr=None, old...
def create_tree_digraph(booster, tree_index=0, show_info=None, precision=None, old_name=None, old_comment=None, old_filename=None, old_directory=None, old_format=None, old_engine=None, old_encoding=None, old_graph_attr=None, old_node_attr=None, old...
[ "Create", "a", "digraph", "representation", "of", "specified", "tree", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L318-L388
[ "def", "create_tree_digraph", "(", "booster", ",", "tree_index", "=", "0", ",", "show_info", "=", "None", ",", "precision", "=", "None", ",", "old_name", "=", "None", ",", "old_comment", "=", "None", ",", "old_filename", "=", "None", ",", "old_directory", ...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
plot_tree
Plot specified tree. Note ---- It is preferable to use ``create_tree_digraph()`` because of its lossless quality and returned objects can be also rendered and displayed directly inside a Jupyter notebook. Parameters ---------- booster : Booster or LGBMModel Booster or LGBMModel ins...
python-package/lightgbm/plotting.py
def plot_tree(booster, ax=None, tree_index=0, figsize=None, old_graph_attr=None, old_node_attr=None, old_edge_attr=None, show_info=None, precision=None, **kwargs): """Plot specified tree. Note ---- It is preferable to use ``create_tree_digraph()`` because of its lossless qua...
def plot_tree(booster, ax=None, tree_index=0, figsize=None, old_graph_attr=None, old_node_attr=None, old_edge_attr=None, show_info=None, precision=None, **kwargs): """Plot specified tree. Note ---- It is preferable to use ``create_tree_digraph()`` because of its lossless qua...
[ "Plot", "specified", "tree", "." ]
Microsoft/LightGBM
python
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L391-L456
[ "def", "plot_tree", "(", "booster", ",", "ax", "=", "None", ",", "tree_index", "=", "0", ",", "figsize", "=", "None", ",", "old_graph_attr", "=", "None", ",", "old_node_attr", "=", "None", ",", "old_edge_attr", "=", "None", ",", "show_info", "=", "None",...
8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147
train
cpp_flag
Return the -std=c++[0x/11/14] compiler flag. The c++14 is preferred over c++0x/11 (when it is available).
setup.py
def cpp_flag(compiler): """Return the -std=c++[0x/11/14] compiler flag. The c++14 is preferred over c++0x/11 (when it is available). """ standards = ['-std=c++14', '-std=c++11', '-std=c++0x'] for standard in standards: if has_flag(compiler, [standard]): return standard raise ...
def cpp_flag(compiler): """Return the -std=c++[0x/11/14] compiler flag. The c++14 is preferred over c++0x/11 (when it is available). """ standards = ['-std=c++14', '-std=c++11', '-std=c++0x'] for standard in standards: if has_flag(compiler, [standard]): return standard raise ...
[ "Return", "the", "-", "std", "=", "c", "++", "[", "0x", "/", "11", "/", "14", "]", "compiler", "flag", ".", "The", "c", "++", "14", "is", "preferred", "over", "c", "++", "0x", "/", "11", "(", "when", "it", "is", "available", ")", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/setup.py#L99-L110
[ "def", "cpp_flag", "(", "compiler", ")", ":", "standards", "=", "[", "'-std=c++14'", ",", "'-std=c++11'", ",", "'-std=c++0x'", "]", "for", "standard", "in", "standards", ":", "if", "has_flag", "(", "compiler", ",", "[", "standard", "]", ")", ":", "return",...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
find_nearest_neighbor
query is a 1d numpy array corresponding to the vector to which you want to find the closest vector vectors is a 2d numpy array corresponding to the vectors you want to consider ban_set is a set of indicies within vectors you want to ignore for nearest match cossims is a 1d numpy array of size len(vector...
python/fastText/util/util.py
def find_nearest_neighbor(query, vectors, ban_set, cossims=None): """ query is a 1d numpy array corresponding to the vector to which you want to find the closest vector vectors is a 2d numpy array corresponding to the vectors you want to consider ban_set is a set of indicies within vectors you want ...
def find_nearest_neighbor(query, vectors, ban_set, cossims=None): """ query is a 1d numpy array corresponding to the vector to which you want to find the closest vector vectors is a 2d numpy array corresponding to the vectors you want to consider ban_set is a set of indicies within vectors you want ...
[ "query", "is", "a", "1d", "numpy", "array", "corresponding", "to", "the", "vector", "to", "which", "you", "want", "to", "find", "the", "closest", "vector", "vectors", "is", "a", "2d", "numpy", "array", "corresponding", "to", "the", "vectors", "you", "want"...
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/util/util.py#L40-L60
[ "def", "find_nearest_neighbor", "(", "query", ",", "vectors", ",", "ban_set", ",", "cossims", "=", "None", ")", ":", "if", "cossims", "is", "None", ":", "cossims", "=", "np", ".", "matmul", "(", "vectors", ",", "query", ",", "out", "=", "cossims", ")",...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
train_supervised
Train a supervised model and return a model object. input must be a filepath. The input text does not need to be tokenized as per the tokenize function, but it must be preprocessed and encoded as UTF-8. You might want to consult standard preprocessing scripts such as tokenizer.perl mentioned here: http...
python/fastText/FastText.py
def train_supervised( input, lr=0.1, dim=100, ws=5, epoch=5, minCount=1, minCountLabel=0, minn=0, maxn=0, neg=5, wordNgrams=1, loss="softmax", bucket=2000000, thread=multiprocessing.cpu_count() - 1, lrUpdateRate=100, t=1e-4, label="__label__", verb...
def train_supervised( input, lr=0.1, dim=100, ws=5, epoch=5, minCount=1, minCountLabel=0, minn=0, maxn=0, neg=5, wordNgrams=1, loss="softmax", bucket=2000000, thread=multiprocessing.cpu_count() - 1, lrUpdateRate=100, t=1e-4, label="__label__", verb...
[ "Train", "a", "supervised", "model", "and", "return", "a", "model", "object", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L323-L360
[ "def", "train_supervised", "(", "input", ",", "lr", "=", "0.1", ",", "dim", "=", "100", ",", "ws", "=", "5", ",", "epoch", "=", "5", ",", "minCount", "=", "1", ",", "minCountLabel", "=", "0", ",", "minn", "=", "0", ",", "maxn", "=", "0", ",", ...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_word_vector
Get the vector representation of word.
python/fastText/FastText.py
def get_word_vector(self, word): """Get the vector representation of word.""" dim = self.get_dimension() b = fasttext.Vector(dim) self.f.getWordVector(b, word) return np.array(b)
def get_word_vector(self, word): """Get the vector representation of word.""" dim = self.get_dimension() b = fasttext.Vector(dim) self.f.getWordVector(b, word) return np.array(b)
[ "Get", "the", "vector", "representation", "of", "word", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L47-L52
[ "def", "get_word_vector", "(", "self", ",", "word", ")", ":", "dim", "=", "self", ".", "get_dimension", "(", ")", "b", "=", "fasttext", ".", "Vector", "(", "dim", ")", "self", ".", "f", ".", "getWordVector", "(", "b", ",", "word", ")", "return", "n...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_sentence_vector
Given a string, get a single vector represenation. This function assumes to be given a single line of text. We split words on whitespace (space, newline, tab, vertical tab) and the control characters carriage return, formfeed and the null character.
python/fastText/FastText.py
def get_sentence_vector(self, text): """ Given a string, get a single vector represenation. This function assumes to be given a single line of text. We split words on whitespace (space, newline, tab, vertical tab) and the control characters carriage return, formfeed and the null ...
def get_sentence_vector(self, text): """ Given a string, get a single vector represenation. This function assumes to be given a single line of text. We split words on whitespace (space, newline, tab, vertical tab) and the control characters carriage return, formfeed and the null ...
[ "Given", "a", "string", "get", "a", "single", "vector", "represenation", ".", "This", "function", "assumes", "to", "be", "given", "a", "single", "line", "of", "text", ".", "We", "split", "words", "on", "whitespace", "(", "space", "newline", "tab", "vertica...
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L54-L69
[ "def", "get_sentence_vector", "(", "self", ",", "text", ")", ":", "if", "text", ".", "find", "(", "'\\n'", ")", "!=", "-", "1", ":", "raise", "ValueError", "(", "\"predict processes one line at a time (remove \\'\\\\n\\')\"", ")", "text", "+=", "\"\\n\"", "dim",...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_subwords
Given a word, get the subwords and their indicies.
python/fastText/FastText.py
def get_subwords(self, word, on_unicode_error='strict'): """ Given a word, get the subwords and their indicies. """ pair = self.f.getSubwords(word, on_unicode_error) return pair[0], np.array(pair[1])
def get_subwords(self, word, on_unicode_error='strict'): """ Given a word, get the subwords and their indicies. """ pair = self.f.getSubwords(word, on_unicode_error) return pair[0], np.array(pair[1])
[ "Given", "a", "word", "get", "the", "subwords", "and", "their", "indicies", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L84-L89
[ "def", "get_subwords", "(", "self", ",", "word", ",", "on_unicode_error", "=", "'strict'", ")", ":", "pair", "=", "self", ".", "f", ".", "getSubwords", "(", "word", ",", "on_unicode_error", ")", "return", "pair", "[", "0", "]", ",", "np", ".", "array",...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_input_vector
Given an index, get the corresponding vector of the Input Matrix.
python/fastText/FastText.py
def get_input_vector(self, ind): """ Given an index, get the corresponding vector of the Input Matrix. """ dim = self.get_dimension() b = fasttext.Vector(dim) self.f.getInputVector(b, ind) return np.array(b)
def get_input_vector(self, ind): """ Given an index, get the corresponding vector of the Input Matrix. """ dim = self.get_dimension() b = fasttext.Vector(dim) self.f.getInputVector(b, ind) return np.array(b)
[ "Given", "an", "index", "get", "the", "corresponding", "vector", "of", "the", "Input", "Matrix", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L91-L98
[ "def", "get_input_vector", "(", "self", ",", "ind", ")", ":", "dim", "=", "self", ".", "get_dimension", "(", ")", "b", "=", "fasttext", ".", "Vector", "(", "dim", ")", "self", ".", "f", ".", "getInputVector", "(", "b", ",", "ind", ")", "return", "n...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.predict
Given a string, get a list of labels and a list of corresponding probabilities. k controls the number of returned labels. A choice of 5, will return the 5 most probable labels. By default this returns only the most likely label and probability. threshold filters the returned labe...
python/fastText/FastText.py
def predict(self, text, k=1, threshold=0.0, on_unicode_error='strict'): """ Given a string, get a list of labels and a list of corresponding probabilities. k controls the number of returned labels. A choice of 5, will return the 5 most probable labels. By default this returns onl...
def predict(self, text, k=1, threshold=0.0, on_unicode_error='strict'): """ Given a string, get a list of labels and a list of corresponding probabilities. k controls the number of returned labels. A choice of 5, will return the 5 most probable labels. By default this returns onl...
[ "Given", "a", "string", "get", "a", "list", "of", "labels", "and", "a", "list", "of", "corresponding", "probabilities", ".", "k", "controls", "the", "number", "of", "returned", "labels", ".", "A", "choice", "of", "5", "will", "return", "the", "5", "most"...
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L100-L143
[ "def", "predict", "(", "self", ",", "text", ",", "k", "=", "1", ",", "threshold", "=", "0.0", ",", "on_unicode_error", "=", "'strict'", ")", ":", "def", "check", "(", "entry", ")", ":", "if", "entry", ".", "find", "(", "'\\n'", ")", "!=", "-", "1...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_input_matrix
Get a copy of the full input matrix of a Model. This only works if the model is not quantized.
python/fastText/FastText.py
def get_input_matrix(self): """ Get a copy of the full input matrix of a Model. This only works if the model is not quantized. """ if self.f.isQuant(): raise ValueError("Can't get quantized Matrix") return np.array(self.f.getInputMatrix())
def get_input_matrix(self): """ Get a copy of the full input matrix of a Model. This only works if the model is not quantized. """ if self.f.isQuant(): raise ValueError("Can't get quantized Matrix") return np.array(self.f.getInputMatrix())
[ "Get", "a", "copy", "of", "the", "full", "input", "matrix", "of", "a", "Model", ".", "This", "only", "works", "if", "the", "model", "is", "not", "quantized", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L145-L152
[ "def", "get_input_matrix", "(", "self", ")", ":", "if", "self", ".", "f", ".", "isQuant", "(", ")", ":", "raise", "ValueError", "(", "\"Can't get quantized Matrix\"", ")", "return", "np", ".", "array", "(", "self", ".", "f", ".", "getInputMatrix", "(", "...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_output_matrix
Get a copy of the full output matrix of a Model. This only works if the model is not quantized.
python/fastText/FastText.py
def get_output_matrix(self): """ Get a copy of the full output matrix of a Model. This only works if the model is not quantized. """ if self.f.isQuant(): raise ValueError("Can't get quantized Matrix") return np.array(self.f.getOutputMatrix())
def get_output_matrix(self): """ Get a copy of the full output matrix of a Model. This only works if the model is not quantized. """ if self.f.isQuant(): raise ValueError("Can't get quantized Matrix") return np.array(self.f.getOutputMatrix())
[ "Get", "a", "copy", "of", "the", "full", "output", "matrix", "of", "a", "Model", ".", "This", "only", "works", "if", "the", "model", "is", "not", "quantized", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L154-L161
[ "def", "get_output_matrix", "(", "self", ")", ":", "if", "self", ".", "f", ".", "isQuant", "(", ")", ":", "raise", "ValueError", "(", "\"Can't get quantized Matrix\"", ")", "return", "np", ".", "array", "(", "self", ".", "f", ".", "getOutputMatrix", "(", ...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_words
Get the entire list of words of the dictionary optionally including the frequency of the individual words. This does not include any subwords. For that please consult the function get_subwords.
python/fastText/FastText.py
def get_words(self, include_freq=False, on_unicode_error='strict'): """ Get the entire list of words of the dictionary optionally including the frequency of the individual words. This does not include any subwords. For that please consult the function get_subwords. """ ...
def get_words(self, include_freq=False, on_unicode_error='strict'): """ Get the entire list of words of the dictionary optionally including the frequency of the individual words. This does not include any subwords. For that please consult the function get_subwords. """ ...
[ "Get", "the", "entire", "list", "of", "words", "of", "the", "dictionary", "optionally", "including", "the", "frequency", "of", "the", "individual", "words", ".", "This", "does", "not", "include", "any", "subwords", ".", "For", "that", "please", "consult", "t...
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L163-L174
[ "def", "get_words", "(", "self", ",", "include_freq", "=", "False", ",", "on_unicode_error", "=", "'strict'", ")", ":", "pair", "=", "self", ".", "f", ".", "getVocab", "(", "on_unicode_error", ")", "if", "include_freq", ":", "return", "(", "pair", "[", "...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_labels
Get the entire list of labels of the dictionary optionally including the frequency of the individual labels. Unsupervised models use words as labels, which is why get_labels will call and return get_words for this type of model.
python/fastText/FastText.py
def get_labels(self, include_freq=False, on_unicode_error='strict'): """ Get the entire list of labels of the dictionary optionally including the frequency of the individual labels. Unsupervised models use words as labels, which is why get_labels will call and return get_words fo...
def get_labels(self, include_freq=False, on_unicode_error='strict'): """ Get the entire list of labels of the dictionary optionally including the frequency of the individual labels. Unsupervised models use words as labels, which is why get_labels will call and return get_words fo...
[ "Get", "the", "entire", "list", "of", "labels", "of", "the", "dictionary", "optionally", "including", "the", "frequency", "of", "the", "individual", "labels", ".", "Unsupervised", "models", "use", "words", "as", "labels", "which", "is", "why", "get_labels", "w...
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L176-L192
[ "def", "get_labels", "(", "self", ",", "include_freq", "=", "False", ",", "on_unicode_error", "=", "'strict'", ")", ":", "a", "=", "self", ".", "f", ".", "getArgs", "(", ")", "if", "a", ".", "model", "==", "model_name", ".", "supervised", ":", "pair", ...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.get_line
Split a line of text into words and labels. Labels must start with the prefix used to create the model (__label__ by default).
python/fastText/FastText.py
def get_line(self, text, on_unicode_error='strict'): """ Split a line of text into words and labels. Labels must start with the prefix used to create the model (__label__ by default). """ def check(entry): if entry.find('\n') != -1: raise ValueError( ...
def get_line(self, text, on_unicode_error='strict'): """ Split a line of text into words and labels. Labels must start with the prefix used to create the model (__label__ by default). """ def check(entry): if entry.find('\n') != -1: raise ValueError( ...
[ "Split", "a", "line", "of", "text", "into", "words", "and", "labels", ".", "Labels", "must", "start", "with", "the", "prefix", "used", "to", "create", "the", "model", "(", "__label__", "by", "default", ")", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L194-L213
[ "def", "get_line", "(", "self", ",", "text", ",", "on_unicode_error", "=", "'strict'", ")", ":", "def", "check", "(", "entry", ")", ":", "if", "entry", ".", "find", "(", "'\\n'", ")", "!=", "-", "1", ":", "raise", "ValueError", "(", "\"get_line process...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
_FastText.quantize
Quantize the model reducing the size of the model and it's memory footprint.
python/fastText/FastText.py
def quantize( self, input=None, qout=False, cutoff=0, retrain=False, epoch=None, lr=None, thread=None, verbose=None, dsub=2, qnorm=False ): """ Quantize the model reducing the size of the model and it's m...
def quantize( self, input=None, qout=False, cutoff=0, retrain=False, epoch=None, lr=None, thread=None, verbose=None, dsub=2, qnorm=False ): """ Quantize the model reducing the size of the model and it's m...
[ "Quantize", "the", "model", "reducing", "the", "size", "of", "the", "model", "and", "it", "s", "memory", "footprint", "." ]
facebookresearch/fastText
python
https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L234-L267
[ "def", "quantize", "(", "self", ",", "input", "=", "None", ",", "qout", "=", "False", ",", "cutoff", "=", "0", ",", "retrain", "=", "False", ",", "epoch", "=", "None", ",", "lr", "=", "None", ",", "thread", "=", "None", ",", "verbose", "=", "None...
6dd2e11b5fe82854c4529d2a58d699b2cb182b1b
train
StackedBidirectionalLstm.forward
Parameters ---------- inputs : ``PackedSequence``, required. A batch first ``PackedSequence`` to run the stacked LSTM over. initial_state : Tuple[torch.Tensor, torch.Tensor], optional, (default = None) A tuple (state, memory) representing the initial hidden state and memo...
allennlp/modules/stacked_bidirectional_lstm.py
def forward(self, # pylint: disable=arguments-differ inputs: PackedSequence, initial_state: Optional[Tuple[torch.Tensor, torch.Tensor]] = None ) -> Tuple[PackedSequence, Tuple[torch.Tensor, torch.Tensor]]: """ Parameters ---------- inputs :...
def forward(self, # pylint: disable=arguments-differ inputs: PackedSequence, initial_state: Optional[Tuple[torch.Tensor, torch.Tensor]] = None ) -> Tuple[PackedSequence, Tuple[torch.Tensor, torch.Tensor]]: """ Parameters ---------- inputs :...
[ "Parameters", "----------", "inputs", ":", "PackedSequence", "required", ".", "A", "batch", "first", "PackedSequence", "to", "run", "the", "stacked", "LSTM", "over", ".", "initial_state", ":", "Tuple", "[", "torch", ".", "Tensor", "torch", ".", "Tensor", "]", ...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/stacked_bidirectional_lstm.py#L78-L134
[ "def", "forward", "(", "self", ",", "# pylint: disable=arguments-differ", "inputs", ":", "PackedSequence", ",", "initial_state", ":", "Optional", "[", "Tuple", "[", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", "]", "]", "=", "None", ")", "->", "Tuple...
648a36f77db7e45784c047176074f98534c76636
train
RegularizerApplicator.from_params
Converts a List of pairs (regex, params) into an RegularizerApplicator. This list should look like [["regex1", {"type": "l2", "alpha": 0.01}], ["regex2", "l1"]] where each parameter receives the penalty corresponding to the first regex that matches its name (which may be no regex and h...
allennlp/nn/regularizers/regularizer_applicator.py
def from_params(cls, params: Iterable[Tuple[str, Params]] = ()) -> Optional['RegularizerApplicator']: """ Converts a List of pairs (regex, params) into an RegularizerApplicator. This list should look like [["regex1", {"type": "l2", "alpha": 0.01}], ["regex2", "l1"]] where each ...
def from_params(cls, params: Iterable[Tuple[str, Params]] = ()) -> Optional['RegularizerApplicator']: """ Converts a List of pairs (regex, params) into an RegularizerApplicator. This list should look like [["regex1", {"type": "l2", "alpha": 0.01}], ["regex2", "l1"]] where each ...
[ "Converts", "a", "List", "of", "pairs", "(", "regex", "params", ")", "into", "an", "RegularizerApplicator", ".", "This", "list", "should", "look", "like" ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/nn/regularizers/regularizer_applicator.py#L45-L81
[ "def", "from_params", "(", "cls", ",", "params", ":", "Iterable", "[", "Tuple", "[", "str", ",", "Params", "]", "]", "=", "(", ")", ")", "->", "Optional", "[", "'RegularizerApplicator'", "]", ":", "if", "not", "params", ":", "return", "None", "instanti...
648a36f77db7e45784c047176074f98534c76636
train
Registrable.list_available
List default first if it exists
allennlp/common/registrable.py
def list_available(cls) -> List[str]: """List default first if it exists""" keys = list(Registrable._registry[cls].keys()) default = cls.default_implementation if default is None: return keys elif default not in keys: message = "Default implementation %s ...
def list_available(cls) -> List[str]: """List default first if it exists""" keys = list(Registrable._registry[cls].keys()) default = cls.default_implementation if default is None: return keys elif default not in keys: message = "Default implementation %s ...
[ "List", "default", "first", "if", "it", "exists" ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/registrable.py#L62-L73
[ "def", "list_available", "(", "cls", ")", "->", "List", "[", "str", "]", ":", "keys", "=", "list", "(", "Registrable", ".", "_registry", "[", "cls", "]", ".", "keys", "(", ")", ")", "default", "=", "cls", ".", "default_implementation", "if", "default",...
648a36f77db7e45784c047176074f98534c76636
train
sanitize
Sanitize turns PyTorch and Numpy types into basic Python types so they can be serialized into JSON.
allennlp/common/util.py
def sanitize(x: Any) -> Any: # pylint: disable=invalid-name,too-many-return-statements """ Sanitize turns PyTorch and Numpy types into basic Python types so they can be serialized into JSON. """ if isinstance(x, (str, float, int, bool)): # x is already serializable return x elif...
def sanitize(x: Any) -> Any: # pylint: disable=invalid-name,too-many-return-statements """ Sanitize turns PyTorch and Numpy types into basic Python types so they can be serialized into JSON. """ if isinstance(x, (str, float, int, bool)): # x is already serializable return x elif...
[ "Sanitize", "turns", "PyTorch", "and", "Numpy", "types", "into", "basic", "Python", "types", "so", "they", "can", "be", "serialized", "into", "JSON", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L48-L81
[ "def", "sanitize", "(", "x", ":", "Any", ")", "->", "Any", ":", "# pylint: disable=invalid-name,too-many-return-statements", "if", "isinstance", "(", "x", ",", "(", "str", ",", "float", ",", "int", ",", "bool", ")", ")", ":", "# x is already serializable", "re...
648a36f77db7e45784c047176074f98534c76636
train
group_by_count
Takes a list and groups it into sublists of size ``count``, using ``default_value`` to pad the list at the end if the list is not divisable by ``count``. For example: >>> group_by_count([1, 2, 3, 4, 5, 6, 7], 3, 0) [[1, 2, 3], [4, 5, 6], [7, 0, 0]] This is a short method, but it's complicated and ...
allennlp/common/util.py
def group_by_count(iterable: List[Any], count: int, default_value: Any) -> List[List[Any]]: """ Takes a list and groups it into sublists of size ``count``, using ``default_value`` to pad the list at the end if the list is not divisable by ``count``. For example: >>> group_by_count([1, 2, 3, 4, 5, 6...
def group_by_count(iterable: List[Any], count: int, default_value: Any) -> List[List[Any]]: """ Takes a list and groups it into sublists of size ``count``, using ``default_value`` to pad the list at the end if the list is not divisable by ``count``. For example: >>> group_by_count([1, 2, 3, 4, 5, 6...
[ "Takes", "a", "list", "and", "groups", "it", "into", "sublists", "of", "size", "count", "using", "default_value", "to", "pad", "the", "list", "at", "the", "end", "if", "the", "list", "is", "not", "divisable", "by", "count", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L83-L95
[ "def", "group_by_count", "(", "iterable", ":", "List", "[", "Any", "]", ",", "count", ":", "int", ",", "default_value", ":", "Any", ")", "->", "List", "[", "List", "[", "Any", "]", "]", ":", "return", "[", "list", "(", "l", ")", "for", "l", "in",...
648a36f77db7e45784c047176074f98534c76636
train
lazy_groups_of
Takes an iterator and batches the individual instances into lists of the specified size. The last list may be smaller if there are instances left over.
allennlp/common/util.py
def lazy_groups_of(iterator: Iterator[A], group_size: int) -> Iterator[List[A]]: """ Takes an iterator and batches the individual instances into lists of the specified size. The last list may be smaller if there are instances left over. """ return iter(lambda: list(islice(iterator, 0, group_size)), ...
def lazy_groups_of(iterator: Iterator[A], group_size: int) -> Iterator[List[A]]: """ Takes an iterator and batches the individual instances into lists of the specified size. The last list may be smaller if there are instances left over. """ return iter(lambda: list(islice(iterator, 0, group_size)), ...
[ "Takes", "an", "iterator", "and", "batches", "the", "individual", "instances", "into", "lists", "of", "the", "specified", "size", ".", "The", "last", "list", "may", "be", "smaller", "if", "there", "are", "instances", "left", "over", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L99-L104
[ "def", "lazy_groups_of", "(", "iterator", ":", "Iterator", "[", "A", "]", ",", "group_size", ":", "int", ")", "->", "Iterator", "[", "List", "[", "A", "]", "]", ":", "return", "iter", "(", "lambda", ":", "list", "(", "islice", "(", "iterator", ",", ...
648a36f77db7e45784c047176074f98534c76636
train
pad_sequence_to_length
Take a list of objects and pads it to the desired length, returning the padded list. The original list is not modified. Parameters ---------- sequence : List A list of objects to be padded. desired_length : int Maximum length of each sequence. Longer sequences are truncated to thi...
allennlp/common/util.py
def pad_sequence_to_length(sequence: List, desired_length: int, default_value: Callable[[], Any] = lambda: 0, padding_on_right: bool = True) -> List: """ Take a list of objects and pads it to the desired length, returning the padde...
def pad_sequence_to_length(sequence: List, desired_length: int, default_value: Callable[[], Any] = lambda: 0, padding_on_right: bool = True) -> List: """ Take a list of objects and pads it to the desired length, returning the padde...
[ "Take", "a", "list", "of", "objects", "and", "pads", "it", "to", "the", "desired", "length", "returning", "the", "padded", "list", ".", "The", "original", "list", "is", "not", "modified", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L106-L147
[ "def", "pad_sequence_to_length", "(", "sequence", ":", "List", ",", "desired_length", ":", "int", ",", "default_value", ":", "Callable", "[", "[", "]", ",", "Any", "]", "=", "lambda", ":", "0", ",", "padding_on_right", ":", "bool", "=", "True", ")", "->"...
648a36f77db7e45784c047176074f98534c76636
train
add_noise_to_dict_values
Returns a new dictionary with noise added to every key in ``dictionary``. The noise is uniformly distributed within ``noise_param`` percent of the value for every value in the dictionary.
allennlp/common/util.py
def add_noise_to_dict_values(dictionary: Dict[A, float], noise_param: float) -> Dict[A, float]: """ Returns a new dictionary with noise added to every key in ``dictionary``. The noise is uniformly distributed within ``noise_param`` percent of the value for every value in the dictionary. """ new...
def add_noise_to_dict_values(dictionary: Dict[A, float], noise_param: float) -> Dict[A, float]: """ Returns a new dictionary with noise added to every key in ``dictionary``. The noise is uniformly distributed within ``noise_param`` percent of the value for every value in the dictionary. """ new...
[ "Returns", "a", "new", "dictionary", "with", "noise", "added", "to", "every", "key", "in", "dictionary", ".", "The", "noise", "is", "uniformly", "distributed", "within", "noise_param", "percent", "of", "the", "value", "for", "every", "value", "in", "the", "d...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L150-L161
[ "def", "add_noise_to_dict_values", "(", "dictionary", ":", "Dict", "[", "A", ",", "float", "]", ",", "noise_param", ":", "float", ")", "->", "Dict", "[", "A", ",", "float", "]", ":", "new_dict", "=", "{", "}", "for", "key", ",", "value", "in", "dicti...
648a36f77db7e45784c047176074f98534c76636
train
namespace_match
Matches a namespace pattern against a namespace string. For example, ``*tags`` matches ``passage_tags`` and ``question_tags`` and ``tokens`` matches ``tokens`` but not ``stemmed_tokens``.
allennlp/common/util.py
def namespace_match(pattern: str, namespace: str): """ Matches a namespace pattern against a namespace string. For example, ``*tags`` matches ``passage_tags`` and ``question_tags`` and ``tokens`` matches ``tokens`` but not ``stemmed_tokens``. """ if pattern[0] == '*' and namespace.endswith(patt...
def namespace_match(pattern: str, namespace: str): """ Matches a namespace pattern against a namespace string. For example, ``*tags`` matches ``passage_tags`` and ``question_tags`` and ``tokens`` matches ``tokens`` but not ``stemmed_tokens``. """ if pattern[0] == '*' and namespace.endswith(patt...
[ "Matches", "a", "namespace", "pattern", "against", "a", "namespace", "string", ".", "For", "example", "*", "tags", "matches", "passage_tags", "and", "question_tags", "and", "tokens", "matches", "tokens", "but", "not", "stemmed_tokens", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L164-L174
[ "def", "namespace_match", "(", "pattern", ":", "str", ",", "namespace", ":", "str", ")", ":", "if", "pattern", "[", "0", "]", "==", "'*'", "and", "namespace", ".", "endswith", "(", "pattern", "[", "1", ":", "]", ")", ":", "return", "True", "elif", ...
648a36f77db7e45784c047176074f98534c76636
train
prepare_environment
Sets random seeds for reproducible experiments. This may not work as expected if you use this from within a python project in which you have already imported Pytorch. If you use the scripts/run_model.py entry point to training models with this library, your experiments should be reasonably reproducible. If ...
allennlp/common/util.py
def prepare_environment(params: Params): """ Sets random seeds for reproducible experiments. This may not work as expected if you use this from within a python project in which you have already imported Pytorch. If you use the scripts/run_model.py entry point to training models with this library, yo...
def prepare_environment(params: Params): """ Sets random seeds for reproducible experiments. This may not work as expected if you use this from within a python project in which you have already imported Pytorch. If you use the scripts/run_model.py entry point to training models with this library, yo...
[ "Sets", "random", "seeds", "for", "reproducible", "experiments", ".", "This", "may", "not", "work", "as", "expected", "if", "you", "use", "this", "from", "within", "a", "python", "project", "in", "which", "you", "have", "already", "imported", "Pytorch", ".",...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L177-L206
[ "def", "prepare_environment", "(", "params", ":", "Params", ")", ":", "seed", "=", "params", ".", "pop_int", "(", "\"random_seed\"", ",", "13370", ")", "numpy_seed", "=", "params", ".", "pop_int", "(", "\"numpy_seed\"", ",", "1337", ")", "torch_seed", "=", ...
648a36f77db7e45784c047176074f98534c76636
train
prepare_global_logging
This function configures 3 global logging attributes - streaming stdout and stderr to a file as well as the terminal, setting the formatting for the python logging library and setting the interval frequency for the Tqdm progress bar. Note that this function does not set the logging level, which is set in `...
allennlp/common/util.py
def prepare_global_logging(serialization_dir: str, file_friendly_logging: bool) -> logging.FileHandler: """ This function configures 3 global logging attributes - streaming stdout and stderr to a file as well as the terminal, setting the formatting for the python logging library and setting the interval...
def prepare_global_logging(serialization_dir: str, file_friendly_logging: bool) -> logging.FileHandler: """ This function configures 3 global logging attributes - streaming stdout and stderr to a file as well as the terminal, setting the formatting for the python logging library and setting the interval...
[ "This", "function", "configures", "3", "global", "logging", "attributes", "-", "streaming", "stdout", "and", "stderr", "to", "a", "file", "as", "well", "as", "the", "terminal", "setting", "the", "formatting", "for", "the", "python", "logging", "library", "and"...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L208-L250
[ "def", "prepare_global_logging", "(", "serialization_dir", ":", "str", ",", "file_friendly_logging", ":", "bool", ")", "->", "logging", ".", "FileHandler", ":", "# If we don't have a terminal as stdout,", "# force tqdm to be nicer.", "if", "not", "sys", ".", "stdout", "...
648a36f77db7e45784c047176074f98534c76636
train
cleanup_global_logging
This function closes any open file handles and logs set up by `prepare_global_logging`. Parameters ---------- stdout_handler : ``logging.FileHandler``, required. The file handler returned from `prepare_global_logging`, attached to the global logger.
allennlp/common/util.py
def cleanup_global_logging(stdout_handler: logging.FileHandler) -> None: """ This function closes any open file handles and logs set up by `prepare_global_logging`. Parameters ---------- stdout_handler : ``logging.FileHandler``, required. The file handler returned from `prepare_global_loggi...
def cleanup_global_logging(stdout_handler: logging.FileHandler) -> None: """ This function closes any open file handles and logs set up by `prepare_global_logging`. Parameters ---------- stdout_handler : ``logging.FileHandler``, required. The file handler returned from `prepare_global_loggi...
[ "This", "function", "closes", "any", "open", "file", "handles", "and", "logs", "set", "up", "by", "prepare_global_logging", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L252-L267
[ "def", "cleanup_global_logging", "(", "stdout_handler", ":", "logging", ".", "FileHandler", ")", "->", "None", ":", "stdout_handler", ".", "close", "(", ")", "logging", ".", "getLogger", "(", ")", ".", "removeHandler", "(", "stdout_handler", ")", "if", "isinst...
648a36f77db7e45784c047176074f98534c76636
train
get_spacy_model
In order to avoid loading spacy models a whole bunch of times, we'll save references to them, keyed by the options we used to create the spacy model, so any particular configuration only gets loaded once.
allennlp/common/util.py
def get_spacy_model(spacy_model_name: str, pos_tags: bool, parse: bool, ner: bool) -> SpacyModelType: """ In order to avoid loading spacy models a whole bunch of times, we'll save references to them, keyed by the options we used to create the spacy model, so any particular configuration only gets loaded...
def get_spacy_model(spacy_model_name: str, pos_tags: bool, parse: bool, ner: bool) -> SpacyModelType: """ In order to avoid loading spacy models a whole bunch of times, we'll save references to them, keyed by the options we used to create the spacy model, so any particular configuration only gets loaded...
[ "In", "order", "to", "avoid", "loading", "spacy", "models", "a", "whole", "bunch", "of", "times", "we", "ll", "save", "references", "to", "them", "keyed", "by", "the", "options", "we", "used", "to", "create", "the", "spacy", "model", "so", "any", "partic...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L272-L306
[ "def", "get_spacy_model", "(", "spacy_model_name", ":", "str", ",", "pos_tags", ":", "bool", ",", "parse", ":", "bool", ",", "ner", ":", "bool", ")", "->", "SpacyModelType", ":", "options", "=", "(", "spacy_model_name", ",", "pos_tags", ",", "parse", ",", ...
648a36f77db7e45784c047176074f98534c76636
train
import_submodules
Import all submodules under the given package. Primarily useful so that people using AllenNLP as a library can specify their own custom packages and have their custom classes get loaded and registered.
allennlp/common/util.py
def import_submodules(package_name: str) -> None: """ Import all submodules under the given package. Primarily useful so that people using AllenNLP as a library can specify their own custom packages and have their custom classes get loaded and registered. """ importlib.invalidate_caches() ...
def import_submodules(package_name: str) -> None: """ Import all submodules under the given package. Primarily useful so that people using AllenNLP as a library can specify their own custom packages and have their custom classes get loaded and registered. """ importlib.invalidate_caches() ...
[ "Import", "all", "submodules", "under", "the", "given", "package", ".", "Primarily", "useful", "so", "that", "people", "using", "AllenNLP", "as", "a", "library", "can", "specify", "their", "own", "custom", "packages", "and", "have", "their", "custom", "classes...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L308-L334
[ "def", "import_submodules", "(", "package_name", ":", "str", ")", "->", "None", ":", "importlib", ".", "invalidate_caches", "(", ")", "# For some reason, python doesn't always add this by default to your path, but you pretty much", "# always want it when using `--include-package`. A...
648a36f77db7e45784c047176074f98534c76636
train
peak_memory_mb
Get peak memory usage for this process, as measured by max-resident-set size: https://unix.stackexchange.com/questions/30940/getrusage-system-call-what-is-maximum-resident-set-size Only works on OSX and Linux, returns 0.0 otherwise.
allennlp/common/util.py
def peak_memory_mb() -> float: """ Get peak memory usage for this process, as measured by max-resident-set size: https://unix.stackexchange.com/questions/30940/getrusage-system-call-what-is-maximum-resident-set-size Only works on OSX and Linux, returns 0.0 otherwise. """ if resource is Non...
def peak_memory_mb() -> float: """ Get peak memory usage for this process, as measured by max-resident-set size: https://unix.stackexchange.com/questions/30940/getrusage-system-call-what-is-maximum-resident-set-size Only works on OSX and Linux, returns 0.0 otherwise. """ if resource is Non...
[ "Get", "peak", "memory", "usage", "for", "this", "process", "as", "measured", "by", "max", "-", "resident", "-", "set", "size", ":" ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L337-L360
[ "def", "peak_memory_mb", "(", ")", "->", "float", ":", "if", "resource", "is", "None", "or", "sys", ".", "platform", "not", "in", "(", "'linux'", ",", "'darwin'", ")", ":", "return", "0.0", "# TODO(joelgrus): For whatever, our pinned version 0.521 of mypy does not l...
648a36f77db7e45784c047176074f98534c76636
train
gpu_memory_mb
Get the current GPU memory usage. Based on https://discuss.pytorch.org/t/access-gpu-memory-usage-in-pytorch/3192/4 Returns ------- ``Dict[int, int]`` Keys are device ids as integers. Values are memory usage as integers in MB. Returns an empty ``dict`` if GPUs are not available.
allennlp/common/util.py
def gpu_memory_mb() -> Dict[int, int]: """ Get the current GPU memory usage. Based on https://discuss.pytorch.org/t/access-gpu-memory-usage-in-pytorch/3192/4 Returns ------- ``Dict[int, int]`` Keys are device ids as integers. Values are memory usage as integers in MB. Re...
def gpu_memory_mb() -> Dict[int, int]: """ Get the current GPU memory usage. Based on https://discuss.pytorch.org/t/access-gpu-memory-usage-in-pytorch/3192/4 Returns ------- ``Dict[int, int]`` Keys are device ids as integers. Values are memory usage as integers in MB. Re...
[ "Get", "the", "current", "GPU", "memory", "usage", ".", "Based", "on", "https", ":", "//", "discuss", ".", "pytorch", ".", "org", "/", "t", "/", "access", "-", "gpu", "-", "memory", "-", "usage", "-", "in", "-", "pytorch", "/", "3192", "/", "4" ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L362-L388
[ "def", "gpu_memory_mb", "(", ")", "->", "Dict", "[", "int", ",", "int", "]", ":", "# pylint: disable=bare-except", "try", ":", "result", "=", "subprocess", ".", "check_output", "(", "[", "'nvidia-smi'", ",", "'--query-gpu=memory.used'", ",", "'--format=csv,nounits...
648a36f77db7e45784c047176074f98534c76636
train
ensure_list
An Iterable may be a list or a generator. This ensures we get a list without making an unnecessary copy.
allennlp/common/util.py
def ensure_list(iterable: Iterable[A]) -> List[A]: """ An Iterable may be a list or a generator. This ensures we get a list without making an unnecessary copy. """ if isinstance(iterable, list): return iterable else: return list(iterable)
def ensure_list(iterable: Iterable[A]) -> List[A]: """ An Iterable may be a list or a generator. This ensures we get a list without making an unnecessary copy. """ if isinstance(iterable, list): return iterable else: return list(iterable)
[ "An", "Iterable", "may", "be", "a", "list", "or", "a", "generator", ".", "This", "ensures", "we", "get", "a", "list", "without", "making", "an", "unnecessary", "copy", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/common/util.py#L391-L399
[ "def", "ensure_list", "(", "iterable", ":", "Iterable", "[", "A", "]", ")", "->", "List", "[", "A", "]", ":", "if", "isinstance", "(", "iterable", ",", "list", ")", ":", "return", "iterable", "else", ":", "return", "list", "(", "iterable", ")" ]
648a36f77db7e45784c047176074f98534c76636
train
ChecklistStatelet.update
Takes an action index, updates checklist and returns an updated state.
allennlp/state_machines/states/checklist_statelet.py
def update(self, action: torch.Tensor) -> 'ChecklistStatelet': """ Takes an action index, updates checklist and returns an updated state. """ checklist_addition = (self.terminal_actions == action).float() new_checklist = self.checklist + checklist_addition new_checklist_s...
def update(self, action: torch.Tensor) -> 'ChecklistStatelet': """ Takes an action index, updates checklist and returns an updated state. """ checklist_addition = (self.terminal_actions == action).float() new_checklist = self.checklist + checklist_addition new_checklist_s...
[ "Takes", "an", "action", "index", "updates", "checklist", "and", "returns", "an", "updated", "state", "." ]
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/state_machines/states/checklist_statelet.py#L57-L68
[ "def", "update", "(", "self", ",", "action", ":", "torch", ".", "Tensor", ")", "->", "'ChecklistStatelet'", ":", "checklist_addition", "=", "(", "self", ".", "terminal_actions", "==", "action", ")", ".", "float", "(", ")", "new_checklist", "=", "self", "."...
648a36f77db7e45784c047176074f98534c76636
train
WikiTablesWorld._remove_action_from_type
Finds the production rule matching the filter function in the given type's valid action list, and removes it. If there is more than one matching function, we crash.
allennlp/semparse/worlds/wikitables_world.py
def _remove_action_from_type(valid_actions: Dict[str, List[str]], type_: str, filter_function: Callable[[str], bool]) -> None: """ Finds the production rule matching the filter function in the given type's valid action list, and r...
def _remove_action_from_type(valid_actions: Dict[str, List[str]], type_: str, filter_function: Callable[[str], bool]) -> None: """ Finds the production rule matching the filter function in the given type's valid action list, and r...
[ "Finds", "the", "production", "rule", "matching", "the", "filter", "function", "in", "the", "given", "type", "s", "valid", "action", "list", "and", "removes", "it", ".", "If", "there", "is", "more", "than", "one", "matching", "function", "we", "crash", "."...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/worlds/wikitables_world.py#L124-L134
[ "def", "_remove_action_from_type", "(", "valid_actions", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ",", "type_", ":", "str", ",", "filter_function", ":", "Callable", "[", "[", "str", "]", ",", "bool", "]", ")", "->", "None", ":", "a...
648a36f77db7e45784c047176074f98534c76636
train
LstmCellWithProjection.forward
Parameters ---------- inputs : ``torch.FloatTensor``, required. A tensor of shape (batch_size, num_timesteps, input_size) to apply the LSTM over. batch_lengths : ``List[int]``, required. A list of length batch_size containing the lengths of the sequences in ba...
allennlp/modules/lstm_cell_with_projection.py
def forward(self, # pylint: disable=arguments-differ inputs: torch.FloatTensor, batch_lengths: List[int], initial_state: Optional[Tuple[torch.Tensor, torch.Tensor]] = None): """ Parameters ---------- inputs : ``torch.FloatTensor``, require...
def forward(self, # pylint: disable=arguments-differ inputs: torch.FloatTensor, batch_lengths: List[int], initial_state: Optional[Tuple[torch.Tensor, torch.Tensor]] = None): """ Parameters ---------- inputs : ``torch.FloatTensor``, require...
[ "Parameters", "----------", "inputs", ":", "torch", ".", "FloatTensor", "required", ".", "A", "tensor", "of", "shape", "(", "batch_size", "num_timesteps", "input_size", ")", "to", "apply", "the", "LSTM", "over", ".", "batch_lengths", ":", "List", "[", "int", ...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/lstm_cell_with_projection.py#L93-L230
[ "def", "forward", "(", "self", ",", "# pylint: disable=arguments-differ", "inputs", ":", "torch", ".", "FloatTensor", ",", "batch_lengths", ":", "List", "[", "int", "]", ",", "initial_state", ":", "Optional", "[", "Tuple", "[", "torch", ".", "Tensor", ",", "...
648a36f77db7e45784c047176074f98534c76636
train
linkcode_resolve
Determine the URL corresponding to Python object This code is from https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L290 and https://github.com/Lasagne/Lasagne/pull/262
doc/conf.py
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object This code is from https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L290 and https://github.com/Lasagne/Lasagne/pull/262 """ if domain != 'py': return None modname = info['module...
def linkcode_resolve(domain, info): """ Determine the URL corresponding to Python object This code is from https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L290 and https://github.com/Lasagne/Lasagne/pull/262 """ if domain != 'py': return None modname = info['module...
[ "Determine", "the", "URL", "corresponding", "to", "Python", "object", "This", "code", "is", "from", "https", ":", "//", "github", ".", "com", "/", "numpy", "/", "numpy", "/", "blob", "/", "master", "/", "doc", "/", "source", "/", "conf", ".", "py#L290"...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/doc/conf.py#L199-L241
[ "def", "linkcode_resolve", "(", "domain", ",", "info", ")", ":", "if", "domain", "!=", "'py'", ":", "return", "None", "modname", "=", "info", "[", "'module'", "]", "fullname", "=", "info", "[", "'fullname'", "]", "submod", "=", "sys", ".", "modules", "...
648a36f77db7e45784c047176074f98534c76636
train
WikiTablesSemanticParser._get_initial_rnn_and_grammar_state
Encodes the question and table, computes a linking between the two, and constructs an initial RnnStatelet and LambdaGrammarStatelet for each batch instance to pass to the decoder. We take ``outputs`` as a parameter here and `modify` it, adding things that we want to visualize in a demo.
allennlp/models/semantic_parsing/wikitables/wikitables_semantic_parser.py
def _get_initial_rnn_and_grammar_state(self, question: Dict[str, torch.LongTensor], table: Dict[str, torch.LongTensor], world: List[WikiTablesWorld], ...
def _get_initial_rnn_and_grammar_state(self, question: Dict[str, torch.LongTensor], table: Dict[str, torch.LongTensor], world: List[WikiTablesWorld], ...
[ "Encodes", "the", "question", "and", "table", "computes", "a", "linking", "between", "the", "two", "and", "constructs", "an", "initial", "RnnStatelet", "and", "LambdaGrammarStatelet", "for", "each", "batch", "instance", "to", "pass", "to", "the", "decoder", "." ...
allenai/allennlp
python
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_parsing/wikitables/wikitables_semantic_parser.py#L140-L296
[ "def", "_get_initial_rnn_and_grammar_state", "(", "self", ",", "question", ":", "Dict", "[", "str", ",", "torch", ".", "LongTensor", "]", ",", "table", ":", "Dict", "[", "str", ",", "torch", ".", "LongTensor", "]", ",", "world", ":", "List", "[", "WikiTa...
648a36f77db7e45784c047176074f98534c76636