repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Microsoft/LightGBM | python-package/lightgbm/basic.py | cint8_array_to_numpy | def cint8_array_to_numpy(cptr, length):
"""Convert a ctypes int pointer array to a numpy array."""
if isinstance(cptr, ctypes.POINTER(ctypes.c_int8)):
return np.fromiter(cptr, dtype=np.int8, count=length)
else:
raise RuntimeError('Expected int pointer') | python | def cint8_array_to_numpy(cptr, length):
"""Convert a ctypes int pointer array to a numpy array."""
if isinstance(cptr, ctypes.POINTER(ctypes.c_int8)):
return np.fromiter(cptr, dtype=np.int8, count=length)
else:
raise RuntimeError('Expected int pointer') | [
"def",
"cint8_array_to_numpy",
"(",
"cptr",
",",
"length",
")",
":",
"if",
"isinstance",
"(",
"cptr",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_int8",
")",
")",
":",
"return",
"np",
".",
"fromiter",
"(",
"cptr",
",",
"dtype",
"=",
"np",
"... | Convert a ctypes int pointer array to a numpy array. | [
"Convert",
"a",
"ctypes",
"int",
"pointer",
"array",
"to",
"a",
"numpy",
"array",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L111-L116 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | param_dict_to_str | def param_dict_to_str(data):
"""Convert Python dictionary to string, which is passed to C API."""
if data is None or not data:
return ""
pairs = []
for key, val in data.items():
if isinstance(val, (list, tuple, set)) or is_numpy_1d_array(val):
pairs.append(str(key) + '=' + ',... | python | def param_dict_to_str(data):
"""Convert Python dictionary to string, which is passed to C API."""
if data is None or not data:
return ""
pairs = []
for key, val in data.items():
if isinstance(val, (list, tuple, set)) or is_numpy_1d_array(val):
pairs.append(str(key) + '=' + ',... | [
"def",
"param_dict_to_str",
"(",
"data",
")",
":",
"if",
"data",
"is",
"None",
"or",
"not",
"data",
":",
"return",
"\"\"",
"pairs",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
... | Convert Python dictionary to string, which is passed to C API. | [
"Convert",
"Python",
"dictionary",
"to",
"string",
"which",
"is",
"passed",
"to",
"C",
"API",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L129-L142 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | convert_from_sliced_object | def convert_from_sliced_object(data):
"""Fix the memory of multi-dimensional sliced object."""
if data.base is not None and isinstance(data, np.ndarray) and isinstance(data.base, np.ndarray):
if not data.flags.c_contiguous:
warnings.warn("Usage of np.ndarray subset (sliced data) is not recom... | python | def convert_from_sliced_object(data):
"""Fix the memory of multi-dimensional sliced object."""
if data.base is not None and isinstance(data, np.ndarray) and isinstance(data.base, np.ndarray):
if not data.flags.c_contiguous:
warnings.warn("Usage of np.ndarray subset (sliced data) is not recom... | [
"def",
"convert_from_sliced_object",
"(",
"data",
")",
":",
"if",
"data",
".",
"base",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"data",
",",
"np",
".",
"ndarray",
")",
"and",
"isinstance",
"(",
"data",
".",
"base",
",",
"np",
".",
"ndarray",
")",... | Fix the memory of multi-dimensional sliced object. | [
"Fix",
"the",
"memory",
"of",
"multi",
"-",
"dimensional",
"sliced",
"object",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L203-L210 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | c_float_array | def c_float_array(data):
"""Get pointer of float numpy array / list."""
if is_1d_list(data):
data = np.array(data, copy=False)
if is_numpy_1d_array(data):
data = convert_from_sliced_object(data)
assert data.flags.c_contiguous
if data.dtype == np.float32:
ptr_data ... | python | def c_float_array(data):
"""Get pointer of float numpy array / list."""
if is_1d_list(data):
data = np.array(data, copy=False)
if is_numpy_1d_array(data):
data = convert_from_sliced_object(data)
assert data.flags.c_contiguous
if data.dtype == np.float32:
ptr_data ... | [
"def",
"c_float_array",
"(",
"data",
")",
":",
"if",
"is_1d_list",
"(",
"data",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
",",
"copy",
"=",
"False",
")",
"if",
"is_numpy_1d_array",
"(",
"data",
")",
":",
"data",
"=",
"convert_from_sliced_... | Get pointer of float numpy array / list. | [
"Get",
"pointer",
"of",
"float",
"numpy",
"array",
"/",
"list",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L213-L231 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | c_int_array | def c_int_array(data):
"""Get pointer of int numpy array / list."""
if is_1d_list(data):
data = np.array(data, copy=False)
if is_numpy_1d_array(data):
data = convert_from_sliced_object(data)
assert data.flags.c_contiguous
if data.dtype == np.int32:
ptr_data = data... | python | def c_int_array(data):
"""Get pointer of int numpy array / list."""
if is_1d_list(data):
data = np.array(data, copy=False)
if is_numpy_1d_array(data):
data = convert_from_sliced_object(data)
assert data.flags.c_contiguous
if data.dtype == np.int32:
ptr_data = data... | [
"def",
"c_int_array",
"(",
"data",
")",
":",
"if",
"is_1d_list",
"(",
"data",
")",
":",
"data",
"=",
"np",
".",
"array",
"(",
"data",
",",
"copy",
"=",
"False",
")",
"if",
"is_numpy_1d_array",
"(",
"data",
")",
":",
"data",
"=",
"convert_from_sliced_ob... | Get pointer of int numpy array / list. | [
"Get",
"pointer",
"of",
"int",
"numpy",
"array",
"/",
"list",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L234-L252 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | _InnerPredictor.predict | def predict(self, data, num_iteration=-1,
raw_score=False, pred_leaf=False, pred_contrib=False, data_has_header=False,
is_reshape=True):
"""Predict logic.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.s... | python | def predict(self, data, num_iteration=-1,
raw_score=False, pred_leaf=False, pred_contrib=False, data_has_header=False,
is_reshape=True):
"""Predict logic.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.s... | [
"def",
"predict",
"(",
"self",
",",
"data",
",",
"num_iteration",
"=",
"-",
"1",
",",
"raw_score",
"=",
"False",
",",
"pred_leaf",
"=",
"False",
",",
"pred_contrib",
"=",
"False",
",",
"data_has_header",
"=",
"False",
",",
"is_reshape",
"=",
"True",
")",... | Predict logic.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame or scipy.sparse
Data source for prediction.
When data type is string, it represents the path of txt file.
num_iteration : int, optional (default=-1)
... | [
"Predict",
"logic",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L417-L503 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | _InnerPredictor.__get_num_preds | def __get_num_preds(self, num_iteration, nrow, predict_type):
"""Get size of prediction result."""
if nrow > MAX_INT32:
raise LightGBMError('LightGBM cannot perform prediction for data'
'with number of rows greater than MAX_INT32 (%d).\n'
... | python | def __get_num_preds(self, num_iteration, nrow, predict_type):
"""Get size of prediction result."""
if nrow > MAX_INT32:
raise LightGBMError('LightGBM cannot perform prediction for data'
'with number of rows greater than MAX_INT32 (%d).\n'
... | [
"def",
"__get_num_preds",
"(",
"self",
",",
"num_iteration",
",",
"nrow",
",",
"predict_type",
")",
":",
"if",
"nrow",
">",
"MAX_INT32",
":",
"raise",
"LightGBMError",
"(",
"'LightGBM cannot perform prediction for data'",
"'with number of rows greater than MAX_INT32 (%d).\\... | Get size of prediction result. | [
"Get",
"size",
"of",
"prediction",
"result",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L505-L519 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | _InnerPredictor.__pred_for_np2d | def __pred_for_np2d(self, mat, num_iteration, predict_type):
"""Predict for a 2-D numpy matrix."""
if len(mat.shape) != 2:
raise ValueError('Input numpy.ndarray or list must be 2 dimensional')
def inner_predict(mat, num_iteration, predict_type, preds=None):
if mat.dtype ... | python | def __pred_for_np2d(self, mat, num_iteration, predict_type):
"""Predict for a 2-D numpy matrix."""
if len(mat.shape) != 2:
raise ValueError('Input numpy.ndarray or list must be 2 dimensional')
def inner_predict(mat, num_iteration, predict_type, preds=None):
if mat.dtype ... | [
"def",
"__pred_for_np2d",
"(",
"self",
",",
"mat",
",",
"num_iteration",
",",
"predict_type",
")",
":",
"if",
"len",
"(",
"mat",
".",
"shape",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'Input numpy.ndarray or list must be 2 dimensional'",
")",
"def",
"... | Predict for a 2-D numpy matrix. | [
"Predict",
"for",
"a",
"2",
"-",
"D",
"numpy",
"matrix",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L521-L568 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | _InnerPredictor.__pred_for_csr | def __pred_for_csr(self, csr, num_iteration, predict_type):
"""Predict for a CSR data."""
def inner_predict(csr, num_iteration, predict_type, preds=None):
nrow = len(csr.indptr) - 1
n_preds = self.__get_num_preds(num_iteration, nrow, predict_type)
if preds is None:
... | python | def __pred_for_csr(self, csr, num_iteration, predict_type):
"""Predict for a CSR data."""
def inner_predict(csr, num_iteration, predict_type, preds=None):
nrow = len(csr.indptr) - 1
n_preds = self.__get_num_preds(num_iteration, nrow, predict_type)
if preds is None:
... | [
"def",
"__pred_for_csr",
"(",
"self",
",",
"csr",
",",
"num_iteration",
",",
"predict_type",
")",
":",
"def",
"inner_predict",
"(",
"csr",
",",
"num_iteration",
",",
"predict_type",
",",
"preds",
"=",
"None",
")",
":",
"nrow",
"=",
"len",
"(",
"csr",
"."... | Predict for a CSR data. | [
"Predict",
"for",
"a",
"CSR",
"data",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L570-L619 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | _InnerPredictor.__pred_for_csc | def __pred_for_csc(self, csc, num_iteration, predict_type):
"""Predict for a CSC data."""
nrow = csc.shape[0]
if nrow > MAX_INT32:
return self.__pred_for_csr(csc.tocsr(), num_iteration, predict_type)
n_preds = self.__get_num_preds(num_iteration, nrow, predict_type)
pr... | python | def __pred_for_csc(self, csc, num_iteration, predict_type):
"""Predict for a CSC data."""
nrow = csc.shape[0]
if nrow > MAX_INT32:
return self.__pred_for_csr(csc.tocsr(), num_iteration, predict_type)
n_preds = self.__get_num_preds(num_iteration, nrow, predict_type)
pr... | [
"def",
"__pred_for_csc",
"(",
"self",
",",
"csc",
",",
"num_iteration",
",",
"predict_type",
")",
":",
"nrow",
"=",
"csc",
".",
"shape",
"[",
"0",
"]",
"if",
"nrow",
">",
"MAX_INT32",
":",
"return",
"self",
".",
"__pred_for_csr",
"(",
"csc",
".",
"tocs... | Predict for a CSC data. | [
"Predict",
"for",
"a",
"CSC",
"data",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L621-L653 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.__init_from_np2d | def __init_from_np2d(self, mat, params_str, ref_dataset):
"""Initialize data from a 2-D numpy matrix."""
if len(mat.shape) != 2:
raise ValueError('Input numpy.ndarray must be 2 dimensional')
self.handle = ctypes.c_void_p()
if mat.dtype == np.float32 or mat.dtype == np.float6... | python | def __init_from_np2d(self, mat, params_str, ref_dataset):
"""Initialize data from a 2-D numpy matrix."""
if len(mat.shape) != 2:
raise ValueError('Input numpy.ndarray must be 2 dimensional')
self.handle = ctypes.c_void_p()
if mat.dtype == np.float32 or mat.dtype == np.float6... | [
"def",
"__init_from_np2d",
"(",
"self",
",",
"mat",
",",
"params_str",
",",
"ref_dataset",
")",
":",
"if",
"len",
"(",
"mat",
".",
"shape",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'Input numpy.ndarray must be 2 dimensional'",
")",
"self",
".",
"han... | Initialize data from a 2-D numpy matrix. | [
"Initialize",
"data",
"from",
"a",
"2",
"-",
"D",
"numpy",
"matrix",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L848-L870 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.__init_from_list_np2d | def __init_from_list_np2d(self, mats, params_str, ref_dataset):
"""Initialize data from a list of 2-D numpy matrices."""
ncol = mats[0].shape[1]
nrow = np.zeros((len(mats),), np.int32)
if mats[0].dtype == np.float64:
ptr_data = (ctypes.POINTER(ctypes.c_double) * len(mats))()
... | python | def __init_from_list_np2d(self, mats, params_str, ref_dataset):
"""Initialize data from a list of 2-D numpy matrices."""
ncol = mats[0].shape[1]
nrow = np.zeros((len(mats),), np.int32)
if mats[0].dtype == np.float64:
ptr_data = (ctypes.POINTER(ctypes.c_double) * len(mats))()
... | [
"def",
"__init_from_list_np2d",
"(",
"self",
",",
"mats",
",",
"params_str",
",",
"ref_dataset",
")",
":",
"ncol",
"=",
"mats",
"[",
"0",
"]",
".",
"shape",
"[",
"1",
"]",
"nrow",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"mats",
")",
",",
"... | Initialize data from a list of 2-D numpy matrices. | [
"Initialize",
"data",
"from",
"a",
"list",
"of",
"2",
"-",
"D",
"numpy",
"matrices",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L872-L917 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.__init_from_csr | def __init_from_csr(self, csr, params_str, ref_dataset):
"""Initialize data from a CSR matrix."""
if len(csr.indices) != len(csr.data):
raise ValueError('Length mismatch: {} vs {}'.format(len(csr.indices), len(csr.data)))
self.handle = ctypes.c_void_p()
ptr_indptr, type_ptr_... | python | def __init_from_csr(self, csr, params_str, ref_dataset):
"""Initialize data from a CSR matrix."""
if len(csr.indices) != len(csr.data):
raise ValueError('Length mismatch: {} vs {}'.format(len(csr.indices), len(csr.data)))
self.handle = ctypes.c_void_p()
ptr_indptr, type_ptr_... | [
"def",
"__init_from_csr",
"(",
"self",
",",
"csr",
",",
"params_str",
",",
"ref_dataset",
")",
":",
"if",
"len",
"(",
"csr",
".",
"indices",
")",
"!=",
"len",
"(",
"csr",
".",
"data",
")",
":",
"raise",
"ValueError",
"(",
"'Length mismatch: {} vs {}'",
"... | Initialize data from a CSR matrix. | [
"Initialize",
"data",
"from",
"a",
"CSR",
"matrix",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L919-L943 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.__init_from_csc | def __init_from_csc(self, csc, params_str, ref_dataset):
"""Initialize data from a CSC matrix."""
if len(csc.indices) != len(csc.data):
raise ValueError('Length mismatch: {} vs {}'.format(len(csc.indices), len(csc.data)))
self.handle = ctypes.c_void_p()
ptr_indptr, type_ptr_... | python | def __init_from_csc(self, csc, params_str, ref_dataset):
"""Initialize data from a CSC matrix."""
if len(csc.indices) != len(csc.data):
raise ValueError('Length mismatch: {} vs {}'.format(len(csc.indices), len(csc.data)))
self.handle = ctypes.c_void_p()
ptr_indptr, type_ptr_... | [
"def",
"__init_from_csc",
"(",
"self",
",",
"csc",
",",
"params_str",
",",
"ref_dataset",
")",
":",
"if",
"len",
"(",
"csc",
".",
"indices",
")",
"!=",
"len",
"(",
"csc",
".",
"data",
")",
":",
"raise",
"ValueError",
"(",
"'Length mismatch: {} vs {}'",
"... | Initialize data from a CSC matrix. | [
"Initialize",
"data",
"from",
"a",
"CSC",
"matrix",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L945-L969 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.construct | def construct(self):
"""Lazy init.
Returns
-------
self : Dataset
Constructed Dataset object.
"""
if self.handle is None:
if self.reference is not None:
if self.used_indices is None:
# create valid
... | python | def construct(self):
"""Lazy init.
Returns
-------
self : Dataset
Constructed Dataset object.
"""
if self.handle is None:
if self.reference is not None:
if self.used_indices is None:
# create valid
... | [
"def",
"construct",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
":",
"if",
"self",
".",
"reference",
"is",
"not",
"None",
":",
"if",
"self",
".",
"used_indices",
"is",
"None",
":",
"# create valid",
"self",
".",
"_lazy_init",
"(",... | Lazy init.
Returns
-------
self : Dataset
Constructed Dataset object. | [
"Lazy",
"init",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L971-L1018 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.create_valid | def create_valid(self, data, label=None, weight=None, group=None,
init_score=None, silent=False, params=None):
"""Create validation data align with current Dataset.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.spar... | python | def create_valid(self, data, label=None, weight=None, group=None,
init_score=None, silent=False, params=None):
"""Create validation data align with current Dataset.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.spar... | [
"def",
"create_valid",
"(",
"self",
",",
"data",
",",
"label",
"=",
"None",
",",
"weight",
"=",
"None",
",",
"group",
"=",
"None",
",",
"init_score",
"=",
"None",
",",
"silent",
"=",
"False",
",",
"params",
"=",
"None",
")",
":",
"ret",
"=",
"Datas... | Create validation data align with current Dataset.
Parameters
----------
data : string, numpy array, pandas DataFrame, H2O DataTable's Frame, scipy.sparse or list of numpy arrays
Data source of Dataset.
If string, it represents the path to txt file.
label : list,... | [
"Create",
"validation",
"data",
"align",
"with",
"current",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1020-L1052 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.subset | def subset(self, used_indices, params=None):
"""Get subset of current Dataset.
Parameters
----------
used_indices : list of int
Indices used to create the subset.
params : dict or None, optional (default=None)
These parameters will be passed to Dataset co... | python | def subset(self, used_indices, params=None):
"""Get subset of current Dataset.
Parameters
----------
used_indices : list of int
Indices used to create the subset.
params : dict or None, optional (default=None)
These parameters will be passed to Dataset co... | [
"def",
"subset",
"(",
"self",
",",
"used_indices",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"self",
".",
"params",
"ret",
"=",
"Dataset",
"(",
"None",
",",
"reference",
"=",
"self",
",",
"feature_name",
... | Get subset of current Dataset.
Parameters
----------
used_indices : list of int
Indices used to create the subset.
params : dict or None, optional (default=None)
These parameters will be passed to Dataset constructor.
Returns
-------
subs... | [
"Get",
"subset",
"of",
"current",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1054-L1077 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.save_binary | def save_binary(self, filename):
"""Save Dataset to a binary file.
Parameters
----------
filename : string
Name of the output file.
Returns
-------
self : Dataset
Returns self.
"""
_safe_call(_LIB.LGBM_DatasetSaveBinary(
... | python | def save_binary(self, filename):
"""Save Dataset to a binary file.
Parameters
----------
filename : string
Name of the output file.
Returns
-------
self : Dataset
Returns self.
"""
_safe_call(_LIB.LGBM_DatasetSaveBinary(
... | [
"def",
"save_binary",
"(",
"self",
",",
"filename",
")",
":",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_DatasetSaveBinary",
"(",
"self",
".",
"construct",
"(",
")",
".",
"handle",
",",
"c_str",
"(",
"filename",
")",
")",
")",
"return",
"self"
] | Save Dataset to a binary file.
Parameters
----------
filename : string
Name of the output file.
Returns
-------
self : Dataset
Returns self. | [
"Save",
"Dataset",
"to",
"a",
"binary",
"file",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1079-L1095 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.set_field | def set_field(self, field_name, data):
"""Set property into the Dataset.
Parameters
----------
field_name : string
The field name of the information.
data : list, numpy 1-D array, pandas Series or None
The array of data to be set.
Returns
... | python | def set_field(self, field_name, data):
"""Set property into the Dataset.
Parameters
----------
field_name : string
The field name of the information.
data : list, numpy 1-D array, pandas Series or None
The array of data to be set.
Returns
... | [
"def",
"set_field",
"(",
"self",
",",
"field_name",
",",
"data",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Cannot set %s before construct dataset\"",
"%",
"field_name",
")",
"if",
"data",
"is",
"None",
":",
"# se... | Set property into the Dataset.
Parameters
----------
field_name : string
The field name of the information.
data : list, numpy 1-D array, pandas Series or None
The array of data to be set.
Returns
-------
self : Dataset
Datase... | [
"Set",
"property",
"into",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1114-L1160 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_field | def get_field(self, field_name):
"""Get property from the Dataset.
Parameters
----------
field_name : string
The field name of the information.
Returns
-------
info : numpy array
A numpy array with information from the Dataset.
""... | python | def get_field(self, field_name):
"""Get property from the Dataset.
Parameters
----------
field_name : string
The field name of the information.
Returns
-------
info : numpy array
A numpy array with information from the Dataset.
""... | [
"def",
"get_field",
"(",
"self",
",",
"field_name",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Cannot get %s before construct Dataset\"",
"%",
"field_name",
")",
"tmp_out_len",
"=",
"ctypes",
".",
"c_int",
"(",
")",... | Get property from the Dataset.
Parameters
----------
field_name : string
The field name of the information.
Returns
-------
info : numpy array
A numpy array with information from the Dataset. | [
"Get",
"property",
"from",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1162-L1199 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.set_categorical_feature | def set_categorical_feature(self, categorical_feature):
"""Set categorical features.
Parameters
----------
categorical_feature : list of int or strings
Names or indices of categorical features.
Returns
-------
self : Dataset
Dataset with ... | python | def set_categorical_feature(self, categorical_feature):
"""Set categorical features.
Parameters
----------
categorical_feature : list of int or strings
Names or indices of categorical features.
Returns
-------
self : Dataset
Dataset with ... | [
"def",
"set_categorical_feature",
"(",
"self",
",",
"categorical_feature",
")",
":",
"if",
"self",
".",
"categorical_feature",
"==",
"categorical_feature",
":",
"return",
"self",
"if",
"self",
".",
"data",
"is",
"not",
"None",
":",
"if",
"self",
".",
"categori... | Set categorical features.
Parameters
----------
categorical_feature : list of int or strings
Names or indices of categorical features.
Returns
-------
self : Dataset
Dataset with set categorical features. | [
"Set",
"categorical",
"features",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1201-L1230 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset._set_predictor | def _set_predictor(self, predictor):
"""Set predictor for continued training.
It is not recommended for user to call this function.
Please use init_model argument in engine.train() or engine.cv() instead.
"""
if predictor is self._predictor:
return self
if se... | python | def _set_predictor(self, predictor):
"""Set predictor for continued training.
It is not recommended for user to call this function.
Please use init_model argument in engine.train() or engine.cv() instead.
"""
if predictor is self._predictor:
return self
if se... | [
"def",
"_set_predictor",
"(",
"self",
",",
"predictor",
")",
":",
"if",
"predictor",
"is",
"self",
".",
"_predictor",
":",
"return",
"self",
"if",
"self",
".",
"data",
"is",
"not",
"None",
":",
"self",
".",
"_predictor",
"=",
"predictor",
"return",
"self... | Set predictor for continued training.
It is not recommended for user to call this function.
Please use init_model argument in engine.train() or engine.cv() instead. | [
"Set",
"predictor",
"for",
"continued",
"training",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1232-L1245 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.set_reference | def set_reference(self, reference):
"""Set reference Dataset.
Parameters
----------
reference : Dataset
Reference that is used as a template to construct the current Dataset.
Returns
-------
self : Dataset
Dataset with set reference.
... | python | def set_reference(self, reference):
"""Set reference Dataset.
Parameters
----------
reference : Dataset
Reference that is used as a template to construct the current Dataset.
Returns
-------
self : Dataset
Dataset with set reference.
... | [
"def",
"set_reference",
"(",
"self",
",",
"reference",
")",
":",
"self",
".",
"set_categorical_feature",
"(",
"reference",
".",
"categorical_feature",
")",
".",
"set_feature_name",
"(",
"reference",
".",
"feature_name",
")",
".",
"_set_predictor",
"(",
"reference"... | Set reference Dataset.
Parameters
----------
reference : Dataset
Reference that is used as a template to construct the current Dataset.
Returns
-------
self : Dataset
Dataset with set reference. | [
"Set",
"reference",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1247-L1271 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.set_feature_name | def set_feature_name(self, feature_name):
"""Set feature name.
Parameters
----------
feature_name : list of strings
Feature names.
Returns
-------
self : Dataset
Dataset with set feature name.
"""
if feature_name != 'auto'... | python | def set_feature_name(self, feature_name):
"""Set feature name.
Parameters
----------
feature_name : list of strings
Feature names.
Returns
-------
self : Dataset
Dataset with set feature name.
"""
if feature_name != 'auto'... | [
"def",
"set_feature_name",
"(",
"self",
",",
"feature_name",
")",
":",
"if",
"feature_name",
"!=",
"'auto'",
":",
"self",
".",
"feature_name",
"=",
"feature_name",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
"and",
"feature_name",
"is",
"not",
"None",
... | Set feature name.
Parameters
----------
feature_name : list of strings
Feature names.
Returns
-------
self : Dataset
Dataset with set feature name. | [
"Set",
"feature",
"name",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1273-L1297 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.set_label | 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... | python | 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",
")",
":",
"self",
".",
"label",
"=",
"label",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
":",
"label",
"=",
"list_to_1d_numpy",
"(",
"_label_from_pandas",
"(",
"label",
")",
",",
"name",
"=",
"'labe... | 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. | [
"Set",
"label",
"of",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1299-L1316 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.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.
... | python | 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",
")",
":",
"if",
"weight",
"is",
"not",
"None",
"and",
"np",
".",
"all",
"(",
"weight",
"==",
"1",
")",
":",
"weight",
"=",
"None",
"self",
".",
"weight",
"=",
"weight",
"if",
"self",
".",
"handle",
... | 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",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1318-L1337 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.set_init_score | 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... | python | 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",
")",
":",
"self",
".",
"init_score",
"=",
"init_score",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
"and",
"init_score",
"is",
"not",
"None",
":",
"init_score",
"=",
"list_to_1d_numpy",
"(",
"i... | 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. | [
"Set",
"init",
"score",
"of",
"Booster",
"to",
"start",
"from",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1339-L1356 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.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.
... | python | 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",
")",
":",
"self",
".",
"group",
"=",
"group",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
"and",
"group",
"is",
"not",
"None",
":",
"group",
"=",
"list_to_1d_numpy",
"(",
"group",
",",
"np",
".",
... | 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",
")",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1358-L1375 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_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 | python | 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",
")",
":",
"if",
"self",
".",
"label",
"is",
"None",
":",
"self",
".",
"label",
"=",
"self",
".",
"get_field",
"(",
"'label'",
")",
"return",
"self",
".",
"label"
] | Get the label of the Dataset.
Returns
-------
label : numpy array or None
The label information from the Dataset. | [
"Get",
"the",
"label",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1377-L1387 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_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 | python | 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",
")",
":",
"if",
"self",
".",
"weight",
"is",
"None",
":",
"self",
".",
"weight",
"=",
"self",
".",
"get_field",
"(",
"'weight'",
")",
"return",
"self",
".",
"weight"
] | Get the weight of the Dataset.
Returns
-------
weight : numpy array or None
Weight for each data point from the Dataset. | [
"Get",
"the",
"weight",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1389-L1399 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_feature_penalty | 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... | python | 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",
")",
":",
"if",
"self",
".",
"feature_penalty",
"is",
"None",
":",
"self",
".",
"feature_penalty",
"=",
"self",
".",
"get_field",
"(",
"'feature_penalty'",
")",
"return",
"self",
".",
"feature_penalty"
] | Get the feature penalty of the Dataset.
Returns
-------
feature_penalty : numpy array or None
Feature penalty for each feature in the Dataset. | [
"Get",
"the",
"feature",
"penalty",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1401-L1411 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_monotone_constraints | 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:
... | python | 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",
")",
":",
"if",
"self",
".",
"monotone_constraints",
"is",
"None",
":",
"self",
".",
"monotone_constraints",
"=",
"self",
".",
"get_field",
"(",
"'monotone_constraints'",
")",
"return",
"self",
".",
"monotone_constra... | 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. | [
"Get",
"the",
"monotone",
"constraints",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1413-L1423 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_init_score | 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... | python | 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",
")",
":",
"if",
"self",
".",
"init_score",
"is",
"None",
":",
"self",
".",
"init_score",
"=",
"self",
".",
"get_field",
"(",
"'init_score'",
")",
"return",
"self",
".",
"init_score"
] | Get the initial score of the Dataset.
Returns
-------
init_score : numpy array or None
Init score of Booster. | [
"Get",
"the",
"initial",
"score",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1425-L1435 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_data | 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:
... | python | 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",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Cannot get data before construct Dataset\"",
")",
"if",
"self",
".",
"data",
"is",
"not",
"None",
"and",
"self",
".",
"used_indices",
"is"... | 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. | [
"Get",
"the",
"raw",
"data",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1437-L1458 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_group | 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... | python | 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",
")",
":",
"if",
"self",
".",
"group",
"is",
"None",
":",
"self",
".",
"group",
"=",
"self",
".",
"get_field",
"(",
"'group'",
")",
"if",
"self",
".",
"group",
"is",
"not",
"None",
":",
"# group data from LightGBM is bound... | Get the group of the Dataset.
Returns
-------
group : numpy array or None
Group size of each group. | [
"Get",
"the",
"group",
"of",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1460-L1473 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.num_data | 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... | python | 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",
")",
":",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
":",
"ret",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_DatasetGetNumData",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"... | Get the number of rows in the Dataset.
Returns
-------
number_of_rows : int
The number of rows in the Dataset. | [
"Get",
"the",
"number",
"of",
"rows",
"in",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1475-L1489 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.num_feature | 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... | python | 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",
")",
":",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
":",
"ret",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_DatasetGetNumFeature",
"(",
"self",
".",
"handle",
",",
"ctypes",
".... | Get the number of columns (features) in the Dataset.
Returns
-------
number_of_columns : int
The number of columns (features) in the Dataset. | [
"Get",
"the",
"number",
"of",
"columns",
"(",
"features",
")",
"in",
"the",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1491-L1505 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.get_ref_chain | 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... | python | 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",
")",
":",
"head",
"=",
"self",
"ref_chain",
"=",
"set",
"(",
")",
"while",
"len",
"(",
"ref_chain",
")",
"<",
"ref_limit",
":",
"if",
"isinstance",
"(",
"head",
",",
"Dataset",
")",
"... | 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... | [
"Get",
"a",
"chain",
"of",
"Dataset",
"objects",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1507-L1535 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.add_features_from | 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
-------
... | python | 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",
")",
":",
"if",
"self",
".",
"handle",
"is",
"None",
"or",
"other",
".",
"handle",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Both source and target Datasets must be constructed before adding features'",
"... | 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... | [
"Add",
"features",
"from",
"other",
"Dataset",
"to",
"the",
"current",
"Dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1537-L1555 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Dataset.dump_text | 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... | python | 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",
")",
":",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_DatasetDumpText",
"(",
"self",
".",
"construct",
"(",
")",
".",
"handle",
",",
"c_str",
"(",
"filename",
")",
")",
")",
"return",
"self"
] | 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. | [
"Save",
"Dataset",
"to",
"a",
"text",
"file",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1557-L1575 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.free_dataset | 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 | python | 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",
")",
":",
"self",
".",
"__dict__",
".",
"pop",
"(",
"'train_set'",
",",
"None",
")",
"self",
".",
"__dict__",
".",
"pop",
"(",
"'valid_sets'",
",",
"None",
")",
"self",
".",
"__num_dataset",
"=",
"0",
"return",
"self... | Free Booster's Datasets.
Returns
-------
self : Booster
Booster without Datasets. | [
"Free",
"Booster",
"s",
"Datasets",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1719-L1730 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.set_network | 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... | python | 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",
")",
":",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_NetworkInit",
"(",
"c_str",
"(",
"machines",
")",
... | 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... | [
"Set",
"the",
"network",
"configuration",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1737-L1762 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.add_valid | 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.
... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"Dataset",
")",
":",
"raise",
"TypeError",
"(",
"'Validation data should be Dataset instance, met {}'",
".",
"format",
"(",
"type",
"(",
"data",
... | 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",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1792-L1821 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.reset_parameter | 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... | python | 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",
")",
":",
"if",
"any",
"(",
"metric_alias",
"in",
"params",
"for",
"metric_alias",
"in",
"(",
"'metric'",
",",
"'metrics'",
",",
"'metric_types'",
")",
")",
":",
"self",
".",
"__need_reload_eval_info",
"=... | Reset parameters of Booster.
Parameters
----------
params : dict
New parameters for Booster.
Returns
-------
self : Booster
Booster with new parameters. | [
"Reset",
"parameters",
"of",
"Booster",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1823-L1844 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.update | 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... | python | 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",
")",
":",
"# need reset training data",
"if",
"train_set",
"is",
"not",
"None",
"and",
"train_set",
"is",
"not",
"self",
".",
"train_set",
":",
"if",
"not",
"isinstance"... | 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.
... | [
"Update",
"Booster",
"for",
"one",
"iteration",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1846-L1892 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.__boost | 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... | python | 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",
")",
":",
"grad",
"=",
"list_to_1d_numpy",
"(",
"grad",
",",
"name",
"=",
"'gradient'",
")",
"hess",
"=",
"list_to_1d_numpy",
"(",
"hess",
",",
"name",
"=",
"'hessian'",
")",
"assert",
"grad",
".... | 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... | [
"Boost",
"Booster",
"for",
"one",
"iteration",
"with",
"customized",
"gradient",
"statistics",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1894-L1929 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.rollback_one_iter | 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... | python | 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",
")",
":",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterRollbackOneIter",
"(",
"self",
".",
"handle",
")",
")",
"self",
".",
"__is_predicted_cur_iter",
"=",
"[",
"False",
"for",
"_",
"in",
"range_",
"(",
"self",
".",
... | Rollback one iteration.
Returns
-------
self : Booster
Booster with rolled back one iteration. | [
"Rollback",
"one",
"iteration",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1931-L1942 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.current_iteration | 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,
... | python | 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",
")",
":",
"out_cur_iter",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterGetCurrentIteration",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"out_cur_iter",
")... | Get the index of the current iteration.
Returns
-------
cur_iter : int
The index of the current iteration. | [
"Get",
"the",
"index",
"of",
"the",
"current",
"iteration",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1944-L1956 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.num_model_per_iteration | 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.... | python | 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",
")",
":",
"model_per_iter",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterNumModelPerIteration",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"model_per_... | Get number of models per iteration.
Returns
-------
model_per_iter : int
The number of models per iteration. | [
"Get",
"number",
"of",
"models",
"per",
"iteration",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1958-L1970 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.num_trees | 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... | python | 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",
")",
":",
"num_trees",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterNumberOfTotalModel",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"num_trees",
")",
")",
")"... | Get number of weak sub-models.
Returns
-------
num_trees : int
The number of weak sub-models. | [
"Get",
"number",
"of",
"weak",
"sub",
"-",
"models",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1972-L1984 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.eval | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"Dataset",
")",
":",
"raise",
"TypeError",
"(",
"\"Can only eval for Dataset instance\"",
")",
"data_idx",
"=",
"-",
"... | 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,... | [
"Evaluate",
"for",
"data",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L1986-L2022 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.eval_valid | 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... | python | 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",
")",
":",
"return",
"[",
"item",
"for",
"i",
"in",
"range_",
"(",
"1",
",",
"self",
".",
"__num_dataset",
")",
"for",
"item",
"in",
"self",
".",
"__inner_eval",
"(",
"self",
".",
"name_vali... | 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... | [
"Evaluate",
"for",
"validation",
"data",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2043-L2061 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.save_model | 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... | python | 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",
")",
":",
"if",
"num_iteration",
"is",
"None",
":",
"num_iteration",
"=",
"self",
".",
"best_iteration",
"_safe_call",
"(",
"_LIB",
".",
... | 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... | [
"Save",
"Booster",
"to",
"file",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2063-L2090 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.shuffle_models | 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... | python | 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",
")",
":",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterShuffleModels",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"c_int",
"(",
"start_iteration... | 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... | [
"Shuffle",
"models",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2092-L2112 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.model_from_string | 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.
... | python | 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",
")",
":",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
":",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterFree",
"(",
"self",
".",
"handle",
")",
")",
"self",
"... | 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
... | [
"Load",
"Booster",
"from",
"a",
"string",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2114-L2146 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.model_to_string | 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... | python | 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",
")",
":",
"if",
"num_iteration",
"is",
"None",
":",
"num_iteration",
"=",
"self",
".",
"best_iteration",
"buffer_len",
"=",
"1",
"<<",
"20",
"tmp_out_... | 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... | [
"Save",
"Booster",
"to",
"string",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2148-L2192 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.dump_model | 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... | python | 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",
")",
":",
"if",
"num_iteration",
"is",
"None",
":",
"num_iteration",
"=",
"self",
".",
"best_iteration",
"buffer_len",
"=",
"1",
"<<",
"20",
"tmp_out_len",... | 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... | [
"Dump",
"Booster",
"to",
"JSON",
"format",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2194-L2239 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.predict | 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 ... | python | 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",
",",
"... | 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)
... | [
"Make",
"a",
"prediction",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2241-L2288 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.refit | 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... | python | 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",
")",
":",
"if",
"self",
".",
"__set_objective_to_none",
":",
"raise",
"LightGBMError",
"(",
"'Cannot refit due to null objective function.'",
")",
"... | 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 ... | [
"Refit",
"the",
"existing",
"Booster",
"by",
"new",
"data",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2290-L2332 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.get_leaf_output | 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... | python | 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",
")",
":",
"ret",
"=",
"ctypes",
".",
"c_double",
"(",
"0",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterGetLeafValue",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"c_int",
"(... | 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. | [
"Get",
"the",
"output",
"of",
"a",
"leaf",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2334-L2355 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster._to_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 | python | 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",
")",
":",
"predictor",
"=",
"_InnerPredictor",
"(",
"booster_handle",
"=",
"self",
".",
"handle",
",",
"pred_parameter",
"=",
"pred_parameter",
")",
"predictor",
".",
"pandas_categorical",
... | Convert to predictor. | [
"Convert",
"to",
"predictor",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2357-L2361 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.num_feature | 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... | python | 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",
")",
":",
"out_num_feature",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"_safe_call",
"(",
"_LIB",
".",
"LGBM_BoosterGetNumFeature",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"out_num_feature",
")",
"... | Get number of features.
Returns
-------
num_feature : int
The number of features. | [
"Get",
"number",
"of",
"features",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2363-L2375 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.feature_name | 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... | python | 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",
")",
":",
"num_feature",
"=",
"self",
".",
"num_feature",
"(",
")",
"# Get name of features",
"tmp_out_len",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"string_buffers",
"=",
"[",
"ctypes",
".",
"create_string_buffer",
"(",... | Get names of features.
Returns
-------
result : list
List with names of features. | [
"Get",
"names",
"of",
"features",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2377-L2396 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.feature_importance | 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... | python | 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",
")",
":",
"if",
"iteration",
"is",
"None",
":",
"iteration",
"=",
"self",
".",
"best_iteration",
"if",
"importance_type",
"==",
"\"split\"",
":",
... | 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... | [
"Get",
"feature",
"importances",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2398-L2434 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.get_split_value_histogram | 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... | python | 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",
")",
":",
"def",
"add",
"(",
"root",
")",
":",
"\"\"\"Recursively add thresholds.\"\"\"",
"if",
"'split_index'",
"in",
"root",
":",
"... | 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
----
... | [
"Get",
"split",
"value",
"histogram",
"for",
"the",
"specified",
"feature",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2436-L2503 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.__inner_eval | 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:
... | python | 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",
")",
":",
"if",
"data_idx",
">=",
"self",
".",
"__num_dataset",
":",
"raise",
"ValueError",
"(",
"\"Data_idx should be smaller than number of dataset\"",
")",
"self",... | Evaluate training or validation data. | [
"Evaluate",
"training",
"or",
"validation",
"data",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2505-L2536 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.__inner_predict | 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:
... | python | 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",
")",
":",
"if",
"data_idx",
">=",
"self",
".",
"__num_dataset",
":",
"raise",
"ValueError",
"(",
"\"Data_idx should be smaller than number of dataset\"",
")",
"if",
"self",
".",
"__inner_predict_buffer",
"[",
"... | Predict for training and validation dataset. | [
"Predict",
"for",
"training",
"and",
"validation",
"dataset",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2538-L2560 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.__get_eval_info | 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(
... | python | 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",
")",
":",
"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",
"(",
"... | Get inner evaluation count and names. | [
"Get",
"inner",
"evaluation",
"count",
"and",
"names",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2562-L2586 | train |
Microsoft/LightGBM | python-package/lightgbm/basic.py | Booster.set_attr | 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.
... | python | 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",
")",
":",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"string_type",
")",
... | 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",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/basic.py#L2604-L2625 | train |
Microsoft/LightGBM | python-package/lightgbm/libpath.py | find_lib_path | 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... | python | 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",
"(",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'LIGHTGBM_BUILD_DOC'",
",",
"False",
")",
":",
"# we don't need lib_lightgbm while building docs",
"return",
"[",
"]",
"curr_path",
"=",
"os",
".",
"path",
".",
"dirname",
"("... | Find the path to LightGBM library files.
Returns
-------
lib_path: list of strings
List of all found library paths to LightGBM. | [
"Find",
"the",
"path",
"to",
"LightGBM",
"library",
"files",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/libpath.py#L8-L38 | train |
Microsoft/LightGBM | python-package/lightgbm/compat.py | json_default_with_numpy | 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 | python | 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",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"np",
".",
"integer",
",",
"np",
".",
"floating",
",",
"np",
".",
"bool_",
")",
")",
":",
"return",
"obj",
".",
"item",
"(",
")",
"elif",
"isinstance",
... | Convert numpy classes to JSON serializable objects. | [
"Convert",
"numpy",
"classes",
"to",
"JSON",
"serializable",
"objects",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/compat.py#L52-L59 | train |
Microsoft/LightGBM | python-package/lightgbm/callback.py | _format_eval_result | 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:
... | python | 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",
")",
":",
"if",
"len",
"(",
"value",
")",
"==",
"4",
":",
"return",
"'%s\\'s %s: %g'",
"%",
"(",
"value",
"[",
"0",
"]",
",",
"value",
"[",
"1",
"]",
",",
"value",
"[",
"2",... | Format metric string. | [
"Format",
"metric",
"string",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L42-L52 | train |
Microsoft/LightGBM | python-package/lightgbm/callback.py | print_evaluation | 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).... | python | 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",
")",
":",
"def",
"_callback",
"(",
"env",
")",
":",
"if",
"period",
">",
"0",
"and",
"env",
".",
"evaluation_result_list",
"and",
"(",
"env",
".",
"iteration",
"+",
"1",... | 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
... | [
"Create",
"a",
"callback",
"that",
"prints",
"the",
"evaluation",
"results",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L55-L75 | train |
Microsoft/LightGBM | python-package/lightgbm/callback.py | record_evaluation | 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... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"eval_result",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'Eval_result should be a dictionary'",
")",
"eval_result",
".",
"clear",
"(",
")",
"def",
"_init",
"(",
... | 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. | [
"Create",
"a",
"callback",
"that",
"records",
"the",
"evaluation",
"history",
"into",
"eval_result",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L78-L105 | train |
Microsoft/LightGBM | python-package/lightgbm/callback.py | reset_parameter | 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... | python | 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",
")",
":",
"def",
"_callback",
"(",
"env",
")",
":",
"new_parameters",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"[",
"'num_class'",
... | 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... | [
"Create",
"a",
"callback",
"that",
"resets",
"the",
"parameter",
"after",
"the",
"first",
"iteration",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L108-L150 | train |
Microsoft/LightGBM | python-package/lightgbm/callback.py | 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_... | python | 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",
")",
":",
"best_score",
"=",
"[",
"]",
"best_iter",
"=",
"[",
"]",
"best_score_list",
"=",
"[",
"]",
"cmp_op",
"=",
"[",
"]",
"enabled",
... | 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... | [
"Create",
"a",
"callback",
"that",
"activates",
"early",
"stopping",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/callback.py#L153-L236 | train |
Microsoft/LightGBM | python-package/lightgbm/engine.py | train | 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,
... | python | 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"... | 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... | [
"Perform",
"the",
"training",
"with",
"given",
"parameters",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L19-L245 | train |
Microsoft/LightGBM | python-package/lightgbm/engine.py | _make_n_folds | 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... | python | 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",
")",
":",
"full_data",
"=... | Make a n-fold list of Booster from random indices. | [
"Make",
"a",
"n",
"-",
"fold",
"list",
"of",
"Booster",
"from",
"random",
"indices",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L270-L325 | train |
Microsoft/LightGBM | python-package/lightgbm/engine.py | _agg_cv_result | 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]... | python | 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",
")",
":",
"cvmap",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"metric_type",
"=",
"{",
"}",
"for",
"one_result",
"in",
"raw_results",
":",
"for",
"one_line",
... | Aggregate cross-validation results. | [
"Aggregate",
"cross",
"-",
"validation",
"results",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L328-L340 | train |
Microsoft/LightGBM | python-package/lightgbm/engine.py | cv | 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=... | python | 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",
... | 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... | [
"Perform",
"the",
"cross",
"-",
"validation",
"with",
"given",
"paramaters",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L343-L520 | train |
Microsoft/LightGBM | examples/python-guide/logistic_regression.py | log_loss | 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 | python | 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",
")",
":",
"log_likelihood",
"=",
"np",
".",
"sum",
"(",
"labels",
"*",
"np",
".",
"log",
"(",
"preds",
")",
")",
"/",
"len",
"(",
"preds",
")",
"return",
"-",
"log_likelihood"
] | Logarithmic loss with non-necessarily-binary labels. | [
"Logarithmic",
"loss",
"with",
"non",
"-",
"necessarily",
"-",
"binary",
"labels",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/examples/python-guide/logistic_regression.py#L49-L52 | train |
Microsoft/LightGBM | examples/python-guide/logistic_regression.py | experiment | 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... | python | 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",
")",
":",
"np",
".",
"random",
".",
"seed",
"(",
"0",
")",
"nrounds",
"=",
"5",
"lgb_data",
"=",
"data",
"[",
"'lgb_with_'",
"+",
"label_type",
"+",
"'_labels'",
"]",
"params",
"=",... | 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... | [
"Measure",
"performance",
"of",
"an",
"objective",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/examples/python-guide/logistic_regression.py#L55-L90 | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | _check_not_tuple_of_2_elements | 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) | python | 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'",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
"or",
"len",
"(",
"obj",
")",
"!=",
"2",
":",
"raise",
"TypeError",
"(",
"'%s must be a tuple of 2 element... | Check object is not tuple or does not have 2 elements. | [
"Check",
"object",
"is",
"not",
"tuple",
"or",
"does",
"not",
"have",
"2",
"elements",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L18-L21 | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | plot_importance | 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,
... | python | 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",
"=",
"'... | 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 ... | [
"Plot",
"model",
"s",
"feature",
"importances",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L30-L141 | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | plot_metric | 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
----------
... | python | 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",
"=",
"'Iteratio... | 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... | [
"Plot",
"one",
"metric",
"during",
"training",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L144-L265 | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | _to_graphviz | 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... | python | 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",
")",
":",
"if",
"GRAPHVIZ_INSTALLED",
":",
"from",
"graphviz",
"import",
"Digraph",
"else",
":",
"raise",
"ImportError",
... | Convert specified tree to graphviz instance.
See:
- https://graphviz.readthedocs.io/en/stable/api.html#digraph | [
"Convert",
"specified",
"tree",
"to",
"graphviz",
"instance",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L268-L315 | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | create_tree_digraph | 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... | python | 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",
... | 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... | [
"Create",
"a",
"digraph",
"representation",
"of",
"specified",
"tree",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L318-L388 | train |
Microsoft/LightGBM | python-package/lightgbm/plotting.py | plot_tree | 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... | python | 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",... | 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... | [
"Plot",
"specified",
"tree",
"."
] | 8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147 | https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/plotting.py#L391-L456 | train |
facebookresearch/fastText | setup.py | cpp_flag | 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 ... | python | 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",
")",
":",
"standards",
"=",
"[",
"'-std=c++14'",
",",
"'-std=c++11'",
",",
"'-std=c++0x'",
"]",
"for",
"standard",
"in",
"standards",
":",
"if",
"has_flag",
"(",
"compiler",
",",
"[",
"standard",
"]",
")",
":",
"return",... | Return the -std=c++[0x/11/14] compiler flag.
The c++14 is preferred over c++0x/11 (when it is available). | [
"Return",
"the",
"-",
"std",
"=",
"c",
"++",
"[",
"0x",
"/",
"11",
"/",
"14",
"]",
"compiler",
"flag",
".",
"The",
"c",
"++",
"14",
"is",
"preferred",
"over",
"c",
"++",
"0x",
"/",
"11",
"(",
"when",
"it",
"is",
"available",
")",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/setup.py#L99-L110 | train |
facebookresearch/fastText | python/fastText/util/util.py | find_nearest_neighbor | 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 ... | python | 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",
")",
":",
"if",
"cossims",
"is",
"None",
":",
"cossims",
"=",
"np",
".",
"matmul",
"(",
"vectors",
",",
"query",
",",
"out",
"=",
"cossims",
")",... | 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... | [
"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"... | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/util/util.py#L40-L60 | train |
facebookresearch/fastText | python/fastText/FastText.py | train_supervised | 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... | python | 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",
",",
... | 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... | [
"Train",
"a",
"supervised",
"model",
"and",
"return",
"a",
"model",
"object",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L323-L360 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_word_vector | 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) | python | 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",
")",
":",
"dim",
"=",
"self",
".",
"get_dimension",
"(",
")",
"b",
"=",
"fasttext",
".",
"Vector",
"(",
"dim",
")",
"self",
".",
"f",
".",
"getWordVector",
"(",
"b",
",",
"word",
")",
"return",
"n... | Get the vector representation of word. | [
"Get",
"the",
"vector",
"representation",
"of",
"word",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L47-L52 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_sentence_vector | 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 ... | python | 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",
")",
":",
"if",
"text",
".",
"find",
"(",
"'\\n'",
")",
"!=",
"-",
"1",
":",
"raise",
"ValueError",
"(",
"\"predict processes one line at a time (remove \\'\\\\n\\')\"",
")",
"text",
"+=",
"\"\\n\"",
"dim",... | 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. | [
"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... | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L54-L69 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_subwords | 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]) | python | 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'",
")",
":",
"pair",
"=",
"self",
".",
"f",
".",
"getSubwords",
"(",
"word",
",",
"on_unicode_error",
")",
"return",
"pair",
"[",
"0",
"]",
",",
"np",
".",
"array",... | Given a word, get the subwords and their indicies. | [
"Given",
"a",
"word",
"get",
"the",
"subwords",
"and",
"their",
"indicies",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L84-L89 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_input_vector | 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) | python | 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",
")",
":",
"dim",
"=",
"self",
".",
"get_dimension",
"(",
")",
"b",
"=",
"fasttext",
".",
"Vector",
"(",
"dim",
")",
"self",
".",
"f",
".",
"getInputVector",
"(",
"b",
",",
"ind",
")",
"return",
"n... | Given an index, get the corresponding vector of the Input Matrix. | [
"Given",
"an",
"index",
"get",
"the",
"corresponding",
"vector",
"of",
"the",
"Input",
"Matrix",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L91-L98 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.predict | 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... | python | 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'",
")",
":",
"def",
"check",
"(",
"entry",
")",
":",
"if",
"entry",
".",
"find",
"(",
"'\\n'",
")",
"!=",
"-",
"1... | 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... | [
"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"... | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L100-L143 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_input_matrix | 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()) | python | 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",
")",
":",
"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. | [
"Get",
"a",
"copy",
"of",
"the",
"full",
"input",
"matrix",
"of",
"a",
"Model",
".",
"This",
"only",
"works",
"if",
"the",
"model",
"is",
"not",
"quantized",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L145-L152 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_output_matrix | 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()) | python | 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",
")",
":",
"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. | [
"Get",
"a",
"copy",
"of",
"the",
"full",
"output",
"matrix",
"of",
"a",
"Model",
".",
"This",
"only",
"works",
"if",
"the",
"model",
"is",
"not",
"quantized",
"."
] | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L154-L161 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_words | 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.
"""
... | python | 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'",
")",
":",
"pair",
"=",
"self",
".",
"f",
".",
"getVocab",
"(",
"on_unicode_error",
")",
"if",
"include_freq",
":",
"return",
"(",
"pair",
"[",
"... | 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... | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L163-L174 | train |
facebookresearch/fastText | python/fastText/FastText.py | _FastText.get_labels | 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... | python | 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'",
")",
":",
"a",
"=",
"self",
".",
"f",
".",
"getArgs",
"(",
")",
"if",
"a",
".",
"model",
"==",
"model_name",
".",
"supervised",
":",
"pair",
... | 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. | [
"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... | 6dd2e11b5fe82854c4529d2a58d699b2cb182b1b | https://github.com/facebookresearch/fastText/blob/6dd2e11b5fe82854c4529d2a58d699b2cb182b1b/python/fastText/FastText.py#L176-L192 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.