index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
4,529
optbinning.binning.binning_process
_transform
null
def _transform(self, X, metric, metric_special, metric_missing, show_digits, check_input): # Check X dtype if not isinstance(X, (pd.DataFrame, np.ndarray)): raise TypeError("X must be a pandas.DataFrame or numpy.ndarray.") n_samples, n_variables = X.shape mask = self.get_support()...
(self, X, metric, metric_special, metric_missing, show_digits, check_input)
4,530
optbinning.binning.binning_process
_transform_disk
null
def _transform_disk(self, input_path, output_path, chunksize, metric, metric_special, metric_missing, show_digits, **kwargs): # check input_path and output_path extensions input_extension = input_path.split(".")[1] output_extension = output_path.split(".")[1] if input_extension != "c...
(self, input_path, output_path, chunksize, metric, metric_special, metric_missing, show_digits, **kwargs)
4,531
sklearn.base
_validate_data
Validate input data and set or check the `n_features_in_` attribute. Parameters ---------- X : {array-like, sparse matrix, dataframe} of shape (n_samples, n_features), default='no validation' The input samples. If `'no_validation'`, no validation is perfo...
def _validate_data( self, X="no_validation", y="no_validation", reset=True, validate_separately=False, cast_to_ndarray=True, **check_params, ): """Validate input data and set or check the `n_features_in_` attribute. Parameters ---------- X : {array-like, sparse matrix, datafr...
(self, X='no_validation', y='no_validation', reset=True, validate_separately=False, cast_to_ndarray=True, **check_params)
4,532
sklearn.base
_validate_params
Validate types and values of constructor parameters The expected type and values must be defined in the `_parameter_constraints` class attribute, which is a dictionary `param_name: list of constraints`. See the docstring of `validate_parameter_constraints` for a description of the accep...
def _validate_params(self): """Validate types and values of constructor parameters The expected type and values must be defined in the `_parameter_constraints` class attribute, which is a dictionary `param_name: list of constraints`. See the docstring of `validate_parameter_constraints` for a descriptio...
(self)
4,533
optbinning.binning.binning_process
fit
Fit the binning process. Fit the optimal binning to all variables according to the given training data. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples. .. versionch...
def fit(self, X, y, sample_weight=None, check_input=False): """Fit the binning process. Fit the optimal binning to all variables according to the given training data. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where n_samples is th...
(self, X, y, sample_weight=None, check_input=False)
4,534
optbinning.binning.binning_process
fit_disk
Fit the binning process according to the given training data on disk. Parameters ---------- input_path : str Any valid string path to a file with extension .csv or .parquet. target : str Target column. **kwargs : keyword arguments Ke...
def fit_disk(self, input_path, target, **kwargs): """Fit the binning process according to the given training data on disk. Parameters ---------- input_path : str Any valid string path to a file with extension .csv or .parquet. target : str Target column. **kwargs : keyword ar...
(self, input_path, target, **kwargs)
4,535
optbinning.binning.binning_process
fit_from_dict
Fit the binning process from a dict of OptimalBinning objects already fitted. Parameters ---------- dict_optb : dict Dictionary with OptimalBinning objects for binary, continuous or multiclass target. All objects must share the same class. Returns ...
def fit_from_dict(self, dict_optb): """Fit the binning process from a dict of OptimalBinning objects already fitted. Parameters ---------- dict_optb : dict Dictionary with OptimalBinning objects for binary, continuous or multiclass target. All objects must share the same class. R...
(self, dict_optb)
4,536
optbinning.binning.binning_process
fit_transform
Fit the binning process according to the given training data, then transform it. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples. y : array-like of shape (n_samples,) ...
def fit_transform(self, X, y, sample_weight=None, metric=None, metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Fit the binning process according to the given training data, then transform it. Parameters ---------- X : {array-like, sparse ...
(self, X, y, sample_weight=None, metric=None, metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,537
optbinning.binning.binning_process
fit_transform_disk
Fit the binning process according to the given training data on disk, then transform it and save to comma-separated values (csv) file. Parameters ---------- input_path : str Any valid string path to a file with extension .csv. output_path : str Any valid...
def fit_transform_disk(self, input_path, output_path, target, chunksize, metric=None, metric_special=0, metric_missing=0, show_digits=2, **kwargs): """Fit the binning process according to the given training data on disk, then transform it and save to comma-separated...
(self, input_path, output_path, target, chunksize, metric=None, metric_special=0, metric_missing=0, show_digits=2, **kwargs)
4,538
optbinning.binning.binning_process
get_binned_variable
Return optimal binning object for a given variable name. Parameters ---------- name : string The variable name.
def get_binned_variable(self, name): """Return optimal binning object for a given variable name. Parameters ---------- name : string The variable name. """ self._check_is_fitted() if not isinstance(name, str): raise TypeError("name must be a string.") if name in self.vari...
(self, name)
4,539
sklearn.utils._metadata_requests
get_metadata_routing
Get metadata routing of this object. Please check :ref:`User Guide <metadata_routing>` on how the routing mechanism works. Returns ------- routing : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing informat...
def get_metadata_routing(self): """Get metadata routing of this object. Please check :ref:`User Guide <metadata_routing>` on how the routing mechanism works. Returns ------- routing : MetadataRequest A :class:`~sklearn.utils.metadata_routing.MetadataRequest` encapsulating routing...
(self)
4,540
sklearn.base
get_params
Get parameters for this estimator. Parameters ---------- deep : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. Returns ------- params : dict Parameter n...
def get_params(self, deep=True): """ Get parameters for this estimator. Parameters ---------- deep : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators. Returns ------- params : dict Parameter nam...
(self, deep=True)
4,541
optbinning.binning.binning_process
get_support
Get a mask, or integer index, or names of the variables selected. Parameters ---------- indices : boolean (default=False) If True, the return value will be an array of integers, rather than a boolean mask. names : boolean (default=False) If True, the...
def get_support(self, indices=False, names=False): """Get a mask, or integer index, or names of the variables selected. Parameters ---------- indices : boolean (default=False) If True, the return value will be an array of integers, rather than a boolean mask. names : boolean (default...
(self, indices=False, names=False)
4,542
optbinning.binning.binning_process
information
Print overview information about the options settings and statistics. Parameters ---------- print_level : int (default=1) Level of details.
def information(self, print_level=1): """Print overview information about the options settings and statistics. Parameters ---------- print_level : int (default=1) Level of details. """ self._check_is_fitted() if not isinstance(print_level, numbers.Integral) or print_level < 0: ...
(self, print_level=1)
4,543
optbinning.binning.binning_process
save
Save binning process to pickle file. Parameters ---------- path : str Pickle file path.
def save(self, path): """Save binning process to pickle file. Parameters ---------- path : str Pickle file path. """ if not isinstance(path, str): raise TypeError("path must be a string.") with open(path, "wb") as f: pickle.dump(self, f)
(self, path)
4,544
sklearn.utils._metadata_requests
set_fit_request
Request metadata passed to the ``fit`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each parameter...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.binning_process.BinningProcess, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$') -> optbinning.binning.binning_process.BinningProcess
4,545
sklearn.base
set_params
Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of a nested object. ...
def set_params(self, **params): """Set the parameters of this estimator. The method works on simple estimators as well as on nested objects (such as :class:`~sklearn.pipeline.Pipeline`). The latter have parameters of the form ``<component>__<parameter>`` so that it's possible to update each componen...
(self, **params)
4,546
sklearn.utils._metadata_requests
set_transform_request
Request metadata passed to the ``transform`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each par...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.binning_process.BinningProcess, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', metric: Union[bool, NoneType, str] = '$UNCHANGED$', metric_missing: Union[bool, NoneType, str] = '$UNCHANGED$', metric_special: Union[bool, NoneType, str] = '$UNCHANGED$', show_digits: Union[bool, NoneT...
4,547
optbinning.binning.binning_process
summary
Binning process summary with main statistics for all binned variables. Parameters ---------- df_summary : pandas.DataFrame Binning process summary.
def summary(self): """Binning process summary with main statistics for all binned variables. Parameters ---------- df_summary : pandas.DataFrame Binning process summary. """ self._check_is_fitted() if self._is_updated: self._binning_selection_criteria() self._is_u...
(self)
4,548
optbinning.binning.binning_process
transform
Transform given data to metric using bins from each fitted optimal binning. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples. metric : str or None, (default=None) ...
def transform(self, X, metric=None, metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Transform given data to metric using bins from each fitted optimal binning. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Train...
(self, X, metric=None, metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,549
optbinning.binning.binning_process
transform_disk
Transform given data on disk to metric using bins from each fitted optimal binning. Save to comma-separated values (csv) file. Parameters ---------- input_path : str Any valid string path to a file with extension .csv. output_path : str Any valid string ...
def transform_disk(self, input_path, output_path, chunksize, metric=None, metric_special=0, metric_missing=0, show_digits=2, **kwargs): """Transform given data on disk to metric using bins from each fitted optimal binning. Save to comma-separated values (csv) file. Para...
(self, input_path, output_path, chunksize, metric=None, metric_special=0, metric_missing=0, show_digits=2, **kwargs)
4,550
optbinning.binning.binning_process
update_binned_variable
Update optimal binning object for a given variable. Parameters ---------- name : string The variable name. optb : object The optimal binning object already fitted.
def update_binned_variable(self, name, optb): """Update optimal binning object for a given variable. Parameters ---------- name : string The variable name. optb : object The optimal binning object already fitted. """ self._check_is_fitted() if not isinstance(name, str): ...
(self, name, optb)
4,551
optbinning.binning.distributed.binning_process_sketch
BinningProcessSketch
Binning process over data streams to compute optimal binning of variables with respect to a binary target. Parameters ---------- variable_names : array-like List of variable names. max_n_prebins : int (default=20) The maximum number of bins after pre-binning (prebins). min_n_b...
class BinningProcessSketch(BaseSketch, BaseEstimator, BaseBinningProcess): """Binning process over data streams to compute optimal binning of variables with respect to a binary target. Parameters ---------- variable_names : array-like List of variable names. max_n_prebins : int (defaul...
(variable_names, max_n_prebins=20, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, max_pvalue=None, max_pvalue_policy='consecutive', selection_criteria=None, categorical_variables=None, special_codes=None, split_digits=None, binning_fit_params=None, binning_transform_params=None, verbose=False)
4,553
optbinning.binning.distributed.binning_process_sketch
__init__
null
def __init__(self, variable_names, max_n_prebins=20, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, max_pvalue=None, max_pvalue_policy="consecutive", selection_criteria=None, categorical_variables=None, special_codes=None, split_digits=None, ...
(self, variable_names, max_n_prebins=20, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, max_pvalue=None, max_pvalue_policy='consecutive', selection_criteria=None, categorical_variables=None, special_codes=None, split_digits=None, binning_fit_params=None, binning_transform_params=None, verbose=F...
4,559
optbinning.binning.distributed.base
_check_is_solved
null
def _check_is_solved(self): if not self._is_solved: raise NotSolvedError("This {} instance is not solved yet. Call " "'solve' with appropriate arguments." .format(self.__class__.__name__))
(self)
4,570
optbinning.binning.distributed.binning_process_sketch
add
Add new data X, y to the binning sketch of each variable. Parameters ---------- X : pandas.DataFrame, shape (n_samples, n_features) y : array-like of shape (n_samples,) Target vector relative to x. check_input : bool (default=False) Whether to check inp...
def add(self, X, y, check_input=False): """Add new data X, y to the binning sketch of each variable. Parameters ---------- X : pandas.DataFrame, shape (n_samples, n_features) y : array-like of shape (n_samples,) Target vector relative to x. check_input : bool (default=False) Whet...
(self, X, y, check_input=False)
4,571
optbinning.binning.distributed.binning_process_sketch
get_binned_variable
Return optimal binning sketch object for a given variable name. Parameters ---------- name : string The variable name.
def get_binned_variable(self, name): """Return optimal binning sketch object for a given variable name. Parameters ---------- name : string The variable name. """ self._check_is_solved() if not isinstance(name, str): raise TypeError("name must be a string.") if name in se...
(self, name)
4,574
optbinning.binning.distributed.binning_process_sketch
get_support
Get a mask, or integer index, or names of the variables selected. Parameters ---------- indices : boolean (default=False) If True, the return value will be an array of integers, rather than a boolean mask. names : boolean (default=False) If True, the...
def get_support(self, indices=False, names=False): """Get a mask, or integer index, or names of the variables selected. Parameters ---------- indices : boolean (default=False) If True, the return value will be an array of integers, rather than a boolean mask. names : boolean (default...
(self, indices=False, names=False)
4,575
optbinning.binning.distributed.binning_process_sketch
information
Print overview information about the options settings and statistics. Parameters ---------- print_level : int (default=1) Level of details.
def information(self, print_level=1): """Print overview information about the options settings and statistics. Parameters ---------- print_level : int (default=1) Level of details. """ self._check_is_solved() if not isinstance(print_level, numbers.Integral) or print_level < 0: ...
(self, print_level=1)
4,576
optbinning.binning.distributed.binning_process_sketch
merge
Merge current instance with another BinningProcessSketch instance. Parameters ---------- bpsketch : object BinningProcessSketch instance.
def merge(self, bpsketch): """Merge current instance with another BinningProcessSketch instance. Parameters ---------- bpsketch : object BinningProcessSketch instance. """ if not self.mergeable(bpsketch): raise Exception("bpsketch does not share signature.") for name in self....
(self, bpsketch)
4,577
optbinning.binning.distributed.binning_process_sketch
mergeable
Check whether two BinningProcessSketch instances can be merged. Parameters ---------- bpsketch : object BinningProcessSketch instance. Returns ------- mergeable : bool
def mergeable(self, bpsketch): """Check whether two BinningProcessSketch instances can be merged. Parameters ---------- bpsketch : object BinningProcessSketch instance. Returns ------- mergeable : bool """ return self.get_params() == bpsketch.get_params()
(self, bpsketch)
4,581
optbinning.binning.distributed.binning_process_sketch
solve
Solve optimal binning for all variables using added data. Returns ------- self : BinningProcessSketch Current fitted binning process.
def solve(self): """Solve optimal binning for all variables using added data. Returns ------- self : BinningProcessSketch Current fitted binning process. """ time_init = time.perf_counter() # Check if data was added if not self._n_add: raise NotDataAddedError( ...
(self)
4,582
optbinning.binning.distributed.binning_process_sketch
summary
Binning process summary with main statistics for all binned variables. Parameters ---------- df_summary : pandas.DataFrame Binning process summary.
def summary(self): """Binning process summary with main statistics for all binned variables. Parameters ---------- df_summary : pandas.DataFrame Binning process summary. """ self._check_is_solved() df_summary = pd.DataFrame.from_dict(self._variable_stats).T df_summary.reset_i...
(self)
4,583
optbinning.binning.distributed.binning_process_sketch
transform
Transform given data to metric using bins from each fitted optimal binning. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training vector, where n_samples is the number of samples. metric : str (default="woe") The...
def transform(self, X, metric="woe", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Transform given data to metric using bins from each fitted optimal binning. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Trai...
(self, X, metric='woe', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,584
optbinning.binning.continuous_binning
ContinuousOptimalBinning
Optimal binning of a numerical or categorical variable with respect to a continuous target. Parameters ---------- name : str, optional (default="") The variable name. dtype : str, optional (default="numerical") The variable data type. Supported data types are "numerical" for ...
class ContinuousOptimalBinning(OptimalBinning): """Optimal binning of a numerical or categorical variable with respect to a continuous target. Parameters ---------- name : str, optional (default="") The variable name. dtype : str, optional (default="numerical") The variable dat...
(name='', dtype='numerical', prebinning_method='cart', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend='auto', min_mean_diff=0, max_pvalue=None, max_pvalue_policy='consecutive', gamma=0, outlier_detector=None, outlier_params=None, cat_cutof...
4,586
optbinning.binning.continuous_binning
__init__
null
def __init__(self, name="", dtype="numerical", prebinning_method="cart", max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend="auto", min_mean_diff=0, max_pvalue=None, max_pvalue_policy="consec...
(self, name='', dtype='numerical', prebinning_method='cart', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend='auto', min_mean_diff=0, max_pvalue=None, max_pvalue_policy='consecutive', gamma=0, outlier_detector=None, outlier_params=None, cat...
4,593
optbinning.binning.continuous_binning
_compute_prebins
null
def _compute_prebins(self, splits_prebinning, x, y, sw): n_splits = len(splits_prebinning) if not n_splits: return splits_prebinning, np.array([]), np.array([]) if self.dtype == "categorical" and self.user_splits is not None: indices = np.digitize(x, splits_prebinning, right=True) n_...
(self, splits_prebinning, x, y, sw)
4,594
optbinning.binning.continuous_binning
_fit
null
def _fit(self, x, y, sample_weight, check_input): time_init = time.perf_counter() if self.verbose: logger.info("Optimal binning started.") logger.info("Options: check parameters.") _check_parameters(**self.get_params()) # Pre-processing if self.verbose: logger.info("Pre-proce...
(self, x, y, sample_weight, check_input)
4,595
optbinning.binning.continuous_binning
_fit_optimizer
null
def _fit_optimizer(self, splits, n_records, sums, ssums, stds): if self.verbose: logger.info("Optimizer started.") time_init = time.perf_counter() if len(n_records) <= 1: self._status = "OPTIMAL" self._splits_optimal = splits self._solution = np.zeros(len(splits)).astype(bool...
(self, splits, n_records, sums, ssums, stds)
4,596
optbinning.binning.binning
_fit_prebinning
null
def _fit_prebinning(self, x, y, y_missing, x_special, y_special, y_others, class_weight=None, sw_clean=None, sw_missing=None, sw_special=None, sw_others=None): min_bin_size = int(np.ceil(self.min_prebin_size * self._n_samples)) prebinning = PreBinning(method=self.prebinni...
(self, x, y, y_missing, x_special, y_special, y_others, class_weight=None, sw_clean=None, sw_missing=None, sw_special=None, sw_others=None)
4,601
optbinning.binning.continuous_binning
_prebinning_refinement
null
def _prebinning_refinement(self, splits_prebinning, x, y, y_missing, x_special, y_special, y_others, sw_clean, sw_missing, sw_special, sw_others): # Compute n_records, sum and std for special, missing and others [self._n_records_special, self._sum_special, s...
(self, splits_prebinning, x, y, y_missing, x_special, y_special, y_others, sw_clean, sw_missing, sw_special, sw_others)
4,606
optbinning.binning.continuous_binning
fit
Fit the optimal binning according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target vector relative to x. sample_...
def fit(self, x, y, sample_weight=None, check_input=False): """Fit the optimal binning according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Targ...
(self, x, y, sample_weight=None, check_input=False)
4,607
optbinning.binning.continuous_binning
fit_transform
Fit the optimal binning according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target vector rela...
def fit_transform(self, x, y, sample_weight=None, metric="mean", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Fit the optimal binning according to the given training data, then transform it. Parameters ---------- x : array-like, shape ...
(self, x, y, sample_weight=None, metric='mean', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,610
optbinning.binning.binning
information
Print overview information about the options settings, problem statistics, and the solution of the computation. Parameters ---------- print_level : int (default=1) Level of details.
def information(self, print_level=1): """Print overview information about the options settings, problem statistics, and the solution of the computation. Parameters ---------- print_level : int (default=1) Level of details. """ self._check_is_fitted() if not isinstance(print_level...
(self, print_level=1)
4,611
optbinning.binning.continuous_binning
read_json
Read json file containing split points and set them as the new split points. Parameters ---------- path: The path of the json file.
def read_json(self, path): """ Read json file containing split points and set them as the new split points. Parameters ---------- path: The path of the json file. """ if path is None: raise ValueError('Specify the path for the json file.') self._is_fitted = True with open...
(self, path)
4,612
sklearn.utils._metadata_requests
set_fit_request
Request metadata passed to the ``fit`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each parameter...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.continuous_binning.ContinuousOptimalBinning, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', sample_weight: Union[bool, NoneType, str] = '$UNCHANGED$', x: Union[bool, NoneType, str] = '$UNCHANGED$') -> optbinning.binning.continuous_binning.ContinuousOptimalBinning
4,614
sklearn.utils._metadata_requests
set_transform_request
Request metadata passed to the ``transform`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each par...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.continuous_binning.ContinuousOptimalBinning, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', metric: Union[bool, NoneType, str] = '$UNCHANGED$', metric_missing: Union[bool, NoneType, str] = '$UNCHANGED$', metric_special: Union[bool, NoneType, str] = '$UNCHANGED$', show_digits: Unio...
4,615
optbinning.binning.continuous_binning
to_json
Save optimal bins and/or splits points and transformation depending on the target type. Parameters ---------- path: The path where the json is going to be saved.
def to_json(self, path): """ Save optimal bins and/or splits points and transformation depending on the target type. Parameters ---------- path: The path where the json is going to be saved. """ if path is None: raise ValueError('Specify the path for the json file.') table = ...
(self, path)
4,616
optbinning.binning.continuous_binning
transform
Transform given data to mean using bins from the fitted optimal binning. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. metric : str (default="mean"): The metric used to transform the...
def transform(self, x, metric="mean", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Transform given data to mean using bins from the fitted optimal binning. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples i...
(self, x, metric='mean', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,617
optbinning.binning.multidimensional.continuous_binning_2d
ContinuousOptimalBinning2D
Optimal binning of two numerical variables with respect to a continuous target. Parameters ---------- name_x : str, optional (default="") The name of variable x. name_y : str, optional (default="") The name of variable y. dtype_x : str, optional (default="numerical") T...
class ContinuousOptimalBinning2D(OptimalBinning2D): """Optimal binning of two numerical variables with respect to a continuous target. Parameters ---------- name_x : str, optional (default="") The name of variable x. name_y : str, optional (default="") The name of variable y. ...
(name_x='', name_y='', dtype_x='numerical', dtype_y='numerical', prebinning_method='cart', strategy='grid', solver='cp', max_n_prebins_x=5, max_n_prebins_y=5, min_prebin_size_x=0.05, min_prebin_size_y=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend_x=None, monotonic_trend_y...
4,619
optbinning.binning.multidimensional.continuous_binning_2d
__init__
null
def __init__(self, name_x="", name_y="", dtype_x="numerical", dtype_y="numerical", prebinning_method="cart", strategy="grid", solver="cp", max_n_prebins_x=5, max_n_prebins_y=5, min_prebin_size_x=0.05, min_prebin_size_y=0.05, min_n_bins=None, max_n_bins=None, ...
(self, name_x='', name_y='', dtype_x='numerical', dtype_y='numerical', prebinning_method='cart', strategy='grid', solver='cp', max_n_prebins_x=5, max_n_prebins_y=5, min_prebin_size_x=0.05, min_prebin_size_y=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend_x=None, monotonic_t...
4,626
optbinning.binning.binning
_compute_prebins
null
def _compute_prebins(self, splits_prebinning, x, y0, y1, sw): n_splits = len(splits_prebinning) if not n_splits: return splits_prebinning, np.array([]), np.array([]) if self.dtype == "categorical" and self.user_splits is not None: indices = np.digitize(x, splits_prebinning, right=True) ...
(self, splits_prebinning, x, y0, y1, sw)
4,627
optbinning.binning.multidimensional.continuous_binning_2d
_fit
null
def _fit(self, x, y, z, check_input): time_init = time.perf_counter() if self.verbose: logger.info("Optimal binning started.") logger.info("Options: check parameters.") _check_parameters(**self.get_params()) # Pre-processing if self.verbose: logger.info("Pre-processing starte...
(self, x, y, z, check_input)
4,628
optbinning.binning.multidimensional.continuous_binning_2d
_fit_optimizer
null
def _fit_optimizer(self, splits_x, splits_y, R, S, SS): if self.verbose: logger.info("Optimizer started.") time_init = time.perf_counter() # Min/max number of bins (bin size) if self.min_bin_size is not None: min_bin_size = int(np.ceil(self.min_bin_size * self._n_samples)) else: ...
(self, splits_x, splits_y, R, S, SS)
4,629
optbinning.binning.multidimensional.binning_2d
_fit_prebinning
null
def _fit_prebinning(self, dtype, x, z, max_n_prebins, min_prebin_size): # Pre-binning algorithm min_bin_size = int(np.ceil(min_prebin_size * self._n_samples)) prebinning = PreBinning(method=self.prebinning_method, n_bins=max_n_prebins, min_bin_size=min...
(self, dtype, x, z, max_n_prebins, min_prebin_size)
4,634
optbinning.binning.multidimensional.continuous_binning_2d
_prebinning_matrices
null
def _prebinning_matrices(self, splits_x, splits_y, x_clean, y_clean, z_clean, x_missing, y_missing, z_missing, x_special, y_special, z_special): self._n_records_missing = len(z_missing) self._n_records_special = len(z_special) self._sum_missing = np.sum(z_mi...
(self, splits_x, splits_y, x_clean, y_clean, z_clean, x_missing, y_missing, z_missing, x_special, y_special, z_special)
4,635
optbinning.binning.binning
_prebinning_refinement
null
def _prebinning_refinement(self, splits_prebinning, x, y, y_missing, x_special, y_special, y_others, sw_clean, sw_missing, sw_special, sw_others): y0 = (y == 0) y1 = ~y0 # Compute n_nonevent and n_event for special, missing and others. self._n_noneve...
(self, splits_prebinning, x, y, y_missing, x_special, y_special, y_others, sw_clean, sw_missing, sw_special, sw_others)
4,638
optbinning.binning.multidimensional.binning_2d
_splits_xy_optimal
null
def _splits_xy_optimal(self, selected_rows, splits_x, splits_y, P): bins_x = np.concatenate([[-np.inf], splits_x, [np.inf]]) bins_y = np.concatenate([[-np.inf], splits_y, [np.inf]]) bins_str_x = np.array([[bins_x[i], bins_x[i+1]] for i in range(len(bins_x) - 1)]) bins_str_y = ...
(self, selected_rows, splits_x, splits_y, P)
4,641
optbinning.binning.multidimensional.continuous_binning_2d
fit
Fit the optimal binning 2D according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector x, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Training vector y, where n_samples is th...
def fit(self, x, y, z, check_input=False): """Fit the optimal binning 2D according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector x, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Training vector ...
(self, x, y, z, check_input=False)
4,642
optbinning.binning.multidimensional.continuous_binning_2d
fit_transform
Fit the optimal binning 2D according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training vector x, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Training vect...
def fit_transform(self, x, y, z, metric="mean", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Fit the optimal binning 2D according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training ...
(self, x, y, z, metric='mean', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,646
optbinning.binning.binning
read_json
Read json file containing split points and set them as the new split points. Parameters ---------- path: The path of the json file.
def read_json(self, path): """ Read json file containing split points and set them as the new split points. Parameters ---------- path: The path of the json file. """ self._is_fitted = True with open(path, "r") as read_file: bin_table_attr = json.load(read_file) for key i...
(self, path)
4,647
sklearn.utils._metadata_requests
set_fit_request
Request metadata passed to the ``fit`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each parameter...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.multidimensional.continuous_binning_2d.ContinuousOptimalBinning2D, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', x: Union[bool, NoneType, str] = '$UNCHANGED$', z: Union[bool, NoneType, str] = '$UNCHANGED$') -> optbinning.binning.multidimensional.continuous_binning_2d.ContinuousOp...
4,650
optbinning.binning.binning
to_json
Save optimal bins and/or splits points and transformation depending on the target type. Parameters ---------- path: The path where the json is going to be saved.
def to_json(self, path): """ Save optimal bins and/or splits points and transformation depending on the target type. Parameters ---------- path: The path where the json is going to be saved. """ if path is None: raise ValueError('Specify the path for the json file') table = s...
(self, path)
4,651
optbinning.binning.multidimensional.continuous_binning_2d
transform
Transform given data to mean using bins from the fitted optimal binning 2D. Parameters ---------- x : array-like, shape = (n_samples,) Training vector x, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Training vector y, wh...
def transform(self, x, y, metric="mean", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Transform given data to mean using bins from the fitted optimal binning 2D. Parameters ---------- x : array-like, shape = (n_samples,) Training vector x, where n_s...
(self, x, y, metric='mean', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,652
optbinning.binning.piecewise.continuous_binning
ContinuousOptimalPWBinning
Optimal Piecewise binning of a numerical variable with respect to a binary target. Parameters ---------- name : str, optional (default="") The variable name. objective : str, optional (default="l2") The objective function. Supported objectives are "l2", "l1", "huber" and "q...
class ContinuousOptimalPWBinning(BasePWBinning): """Optimal Piecewise binning of a numerical variable with respect to a binary target. Parameters ---------- name : str, optional (default="") The variable name. objective : str, optional (default="l2") The objective function. Sup...
(name='', objective='l2', degree=1, continuous=True, continuous_deriv=True, prebinning_method='cart', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend='auto', n_subsamples=None, max_pvalue=None, max_pvalue_policy='consecutive', outlier_detec...
4,654
optbinning.binning.piecewise.continuous_binning
__init__
null
def __init__(self, name="", objective="l2", degree=1, continuous=True, continuous_deriv=True, prebinning_method="cart", max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend="auto", n_subsamples...
(self, name='', objective='l2', degree=1, continuous=True, continuous_deriv=True, prebinning_method='cart', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend='auto', n_subsamples=None, max_pvalue=None, max_pvalue_policy='consecutive', outlier...
4,661
optbinning.binning.piecewise.continuous_binning
_fit
null
def _fit(self, x, y, lb, ub, check_input): time_init = time.perf_counter() if self.verbose: logger.info("Optimal piecewise binning started.") logger.info("Options: check parameters.") _check_parameters(**self.get_params(deep=False), estimator=None, problem_type=self._pr...
(self, x, y, lb, ub, check_input)
4,662
optbinning.binning.piecewise.base
_fit_binning
null
def _fit_binning(self, x, y, prediction, lb, ub): if self.verbose: logger.info("Pre-binning: optimal binning started.") time_prebinning = time.perf_counter() # Determine optimal split points monotonic_trend = self.monotonic_trend if self.monotonic_trend in ("concave", "convex"): mono...
(self, x, y, prediction, lb, ub)
4,663
optbinning.binning.piecewise.base
_fit_preprocessing
null
def _fit_preprocessing(self, x, y, check_input): return split_data(dtype="numerical", x=x, y=y, special_codes=self.special_codes, user_splits=self.user_splits, check_input=check_input, outlier_detector=self.outlier_detector, ...
(self, x, y, check_input)
4,672
optbinning.binning.piecewise.base
fit
Fit the optimal piecewise binning according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target vector relative to x...
def fit(self, x, y, lb=None, ub=None, check_input=False): """Fit the optimal piecewise binning according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) ...
(self, x, y, lb=None, ub=None, check_input=False)
4,673
optbinning.binning.piecewise.continuous_binning
fit_transform
Fit the optimal piecewise binning according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target v...
def fit_transform(self, x, y, metric_special=0, metric_missing=0, lb=None, ub=None, check_input=False): """Fit the optimal piecewise binning according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, ...
(self, x, y, metric_special=0, metric_missing=0, lb=None, ub=None, check_input=False)
4,676
optbinning.binning.piecewise.base
information
Print overview information about the options settings, problem statistics, and the solution of the computation. Parameters ---------- print_level : int (default=1) Level of details.
def information(self, print_level=1): """Print overview information about the options settings, problem statistics, and the solution of the computation. Parameters ---------- print_level : int (default=1) Level of details. """ self._check_is_fitted() if not isinstance(print_level...
(self, print_level=1)
4,677
sklearn.utils._metadata_requests
set_fit_request
Request metadata passed to the ``fit`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each parameter...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.piecewise.continuous_binning.ContinuousOptimalPWBinning, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', lb: Union[bool, NoneType, str] = '$UNCHANGED$', ub: Union[bool, NoneType, str] = '$UNCHANGED$', x: Union[bool, NoneType, str] = '$UNCHANGED$') -> optbinning.binning.piecewise.co...
4,679
sklearn.utils._metadata_requests
set_transform_request
Request metadata passed to the ``transform`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each par...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.piecewise.continuous_binning.ContinuousOptimalPWBinning, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', lb: Union[bool, NoneType, str] = '$UNCHANGED$', metric_missing: Union[bool, NoneType, str] = '$UNCHANGED$', metric_special: Union[bool, NoneType, str] = '$UNCHANGED$', ub: Union...
4,680
optbinning.binning.piecewise.continuous_binning
transform
Transform given data using bins from the fitted optimal piecewise binning. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. metric_special : float or str (default=0) The metric value to...
def transform(self, x, metric_special=0, metric_missing=0, lb=None, ub=None, check_input=False): """Transform given data using bins from the fitted optimal piecewise binning. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the numb...
(self, x, metric_special=0, metric_missing=0, lb=None, ub=None, check_input=False)
4,681
optbinning.binning.mdlp
MDLP
Minimum Description Length Principle (MDLP) discretization algorithm. Parameters ---------- min_samples_split : int (default=2) The minimum number of samples required to split an internal node. min_samples_leaf : int (default=2) The minimum number of samples required to be at a le...
class MDLP(BaseEstimator): """ Minimum Description Length Principle (MDLP) discretization algorithm. Parameters ---------- min_samples_split : int (default=2) The minimum number of samples required to split an internal node. min_samples_leaf : int (default=2) The minimum number...
(min_samples_split=2, min_samples_leaf=2, max_candidates=32)
4,683
optbinning.binning.mdlp
__init__
null
def __init__(self, min_samples_split=2, min_samples_leaf=2, max_candidates=32): self.min_samples_split = min_samples_split self.min_samples_leaf = min_samples_leaf self.max_candidates = max_candidates # auxiliary self._splits = [] self._is_fitted = None
(self, min_samples_split=2, min_samples_leaf=2, max_candidates=32)
4,689
optbinning.binning.mdlp
_entropy
null
def _entropy(self, x): n = len(x) ns1 = np.sum(x) ns0 = n - ns1 p = np.array([ns0, ns1]) / n return -special.xlogy(p, p).sum()
(self, x)
4,690
optbinning.binning.mdlp
_entropy_gain
null
def _entropy_gain(self, y, y1, y2): n = len(y) n1 = len(y1) n2 = n - n1 ent_y = self._entropy(y) ent_y1 = self._entropy(y1) ent_y2 = self._entropy(y2) return ent_y - (n1 * ent_y1 + n2 * ent_y2) / n
(self, y, y1, y2)
4,691
optbinning.binning.mdlp
_find_split
null
def _find_split(self, u_x, x, y): n_x = len(x) u_x = np.unique(0.5 * (x[1:] + x[:-1])[(y[1:] - y[:-1]) != 0]) if len(u_x) > self.max_candidates: percentiles = np.linspace(1, 100, self.max_candidates) splits = np.percentile(u_x, percentiles) else: splits = u_x max_entropy_gain...
(self, u_x, x, y)
4,692
optbinning.binning.mdlp
_fit
null
def _fit(self, x, y): _check_parameters(**self.get_params()) x = check_array(x, ensure_2d=False, force_all_finite=True) y = check_array(y, ensure_2d=False, force_all_finite=True) idx = np.argsort(x) x = x[idx] y = y[idx] self._recurse(x, y, 0) self._is_fitted = True return self
(self, x, y)
4,697
optbinning.binning.mdlp
_recurse
null
def _recurse(self, x, y, id): u_x = np.unique(x) n_x = len(u_x) n_y = len(np.bincount(y)) split = self._find_split(u_x, x, y) if split is not None: self._splits.append(split) t = np.searchsorted(x, split, side="right") if not self._terminate(n_x, n_y, y, y[:t], y[t:]): ...
(self, x, y, id)
4,700
optbinning.binning.mdlp
_terminate
null
def _terminate(self, n_x, n_y, y, y1, y2): splittable = (n_x >= self.min_samples_split) and (n_y >= 2) n = len(y) n1 = len(y1) n2 = n - n1 ent_y = self._entropy(y) ent_y1 = self._entropy(y1) ent_y2 = self._entropy(y2) gain = ent_y - (n1 * ent_y1 + n2 * ent_y2) / n k = len(np.bincount...
(self, n_x, n_y, y, y1, y2)
4,703
optbinning.binning.mdlp
fit
Fit MDLP discretization algorithm. Parameters ---------- x : array-like, shape = (n_samples) Data samples, where n_samples is the number of samples. y : array-like, shape = (n_samples) Target vector relative to x. Returns ------- self : ...
def fit(self, x, y): """Fit MDLP discretization algorithm. Parameters ---------- x : array-like, shape = (n_samples) Data samples, where n_samples is the number of samples. y : array-like, shape = (n_samples) Target vector relative to x. Returns ------- self : MDLP ""...
(self, x, y)
4,706
sklearn.utils._metadata_requests
set_fit_request
Request metadata passed to the ``fit`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each parameter...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.mdlp.MDLP, *, x: Union[bool, NoneType, str] = '$UNCHANGED$') -> optbinning.binning.mdlp.MDLP
4,708
optbinning.binning.multiclass_binning
MulticlassOptimalBinning
Optimal binning of a numerical variable with respect to a multiclass or multilabel target. **Note that the maximum number of classes is set to 100**. To ease visualization of the binning table, a set of 100 maximally distinct colors is generated using the library `glasbey <https://github.com/taketw...
class MulticlassOptimalBinning(OptimalBinning): """Optimal binning of a numerical variable with respect to a multiclass or multilabel target. **Note that the maximum number of classes is set to 100**. To ease visualization of the binning table, a set of 100 maximally distinct colors is generated us...
(name='', prebinning_method='cart', solver='cp', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend='auto', min_event_rate_diff=0, max_pvalue=None, max_pvalue_policy='consecutive', outlier_detector=None, outlier_params=None, user_splits=None, ...
4,710
optbinning.binning.multiclass_binning
__init__
null
def __init__(self, name="", prebinning_method="cart", solver="cp", max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend="auto", min_event_rate_diff=0, max_pvalue=None, max_pvalue_p...
(self, name='', prebinning_method='cart', solver='cp', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, monotonic_trend='auto', min_event_rate_diff=0, max_pvalue=None, max_pvalue_policy='consecutive', outlier_detector=None, outlier_params=None, user_splits=...
4,717
optbinning.binning.multiclass_binning
_compute_prebins
null
def _compute_prebins(self, splits_prebinning, x, y): n_splits = len(splits_prebinning) if not n_splits: return splits_prebinning, np.array([]), np.array([]) indices = np.digitize(x, splits_prebinning, right=False) n_bins = n_splits + 1 n_nonevent = np.empty((n_bins, self._n_classes), dtype=n...
(self, splits_prebinning, x, y)
4,718
optbinning.binning.multiclass_binning
_fit
null
def _fit(self, x, y, check_input): time_init = time.perf_counter() if self.verbose: logger.info("Optimal binning started.") logger.info("Options: check parameters.") _check_parameters(**self.get_params()) # Pre-processing if self.verbose: logger.info("Pre-processing started."...
(self, x, y, check_input)
4,719
optbinning.binning.multiclass_binning
_fit_optimizer
null
def _fit_optimizer(self, splits, n_nonevent, n_event): if self.verbose: logger.info("Optimizer started.") time_init = time.perf_counter() if not len(n_nonevent): self._status = "OPTIMAL" self._splits_optimal = splits self._solution = np.zeros(len(splits), dtype=bool) ...
(self, splits, n_nonevent, n_event)
4,725
optbinning.binning.multiclass_binning
_prebinning_refinement
null
def _prebinning_refinement(self, splits_prebinning, x, y, y_missing, x_special, y_special, y_others=None, sw_clean=None, sw_missing=None, sw_special=None, sw_others=None): self._classes = np.unique(y) self._n_classes = len(self._cl...
(self, splits_prebinning, x, y, y_missing, x_special, y_special, y_others=None, sw_clean=None, sw_missing=None, sw_special=None, sw_others=None)
4,730
optbinning.binning.multiclass_binning
fit
Fit the optimal binning according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target vector relative to x. check_i...
def fit(self, x, y, check_input=False): """Fit the optimal binning according to the given training data. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target vector relative t...
(self, x, y, check_input=False)
4,731
optbinning.binning.multiclass_binning
fit_transform
Fit the optimal binning according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. y : array-like, shape = (n_samples,) Target vector rela...
def fit_transform(self, x, y, metric="mean_woe", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Fit the optimal binning according to the given training data, then transform it. Parameters ---------- x : array-like, shape = (n_samples,) Training ve...
(self, x, y, metric='mean_woe', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,735
optbinning.binning.multiclass_binning
read_json
Read json file containing split points and set them as the new split points. Parameters ---------- path: The path of the json file.
def read_json(self, path): """ Read json file containing split points and set them as the new split points. Parameters ---------- path: The path of the json file. """ if path is None: raise ValueError('Specify the path for the json file.') self._is_fitted = True with open...
(self, path)
4,736
sklearn.utils._metadata_requests
set_fit_request
Request metadata passed to the ``fit`` method. Note that this method is only relevant if ``enable_metadata_routing=True`` (see :func:`sklearn.set_config`). Please see :ref:`User Guide <metadata_routing>` on how the routing mechanism works. The options for each parameter...
def __get__(self, instance, owner): # we would want to have a method which accepts only the expected args def func(**kw): """Updates the request for provided parameters This docstring is overwritten below. See REQUESTER_DOC for expected functionality """ if not _routing_e...
(self: optbinning.binning.multiclass_binning.MulticlassOptimalBinning, *, check_input: Union[bool, NoneType, str] = '$UNCHANGED$', x: Union[bool, NoneType, str] = '$UNCHANGED$') -> optbinning.binning.multiclass_binning.MulticlassOptimalBinning
4,739
optbinning.binning.multiclass_binning
to_json
Save optimal bins and/or splits points and transformation depending on the target type. Parameters ---------- path: The path where the json is going to be saved.
def to_json(self, path): """ Save optimal bins and/or splits points and transformation depending on the target type. Parameters ---------- path: The path where the json is going to be saved. """ if path is None: raise ValueError('Specify the path for the json file.') table = ...
(self, path)
4,740
optbinning.binning.multiclass_binning
transform
Transform given data to mean Weight of Evidence (WoE) or weighted mean WoE using bins from the fitted optimal binning. Parameters ---------- x : array-like, shape = (n_samples,) Training vector, where n_samples is the number of samples. metric : str, optional (defau...
def transform(self, x, metric="mean_woe", metric_special=0, metric_missing=0, show_digits=2, check_input=False): """Transform given data to mean Weight of Evidence (WoE) or weighted mean WoE using bins from the fitted optimal binning. Parameters ---------- x : array-like, shape = (n_sa...
(self, x, metric='mean_woe', metric_special=0, metric_missing=0, show_digits=2, check_input=False)
4,741
optbinning.binning.binning
OptimalBinning
Optimal binning of a numerical or categorical variable with respect to a binary target. Parameters ---------- name : str, optional (default="") The variable name. dtype : str, optional (default="numerical") The variable data type. Supported data types are "numerical" for co...
class OptimalBinning(BaseOptimalBinning): """Optimal binning of a numerical or categorical variable with respect to a binary target. Parameters ---------- name : str, optional (default="") The variable name. dtype : str, optional (default="numerical") The variable data type. Su...
(name='', dtype='numerical', prebinning_method='cart', solver='cp', divergence='iv', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, min_bin_n_nonevent=None, max_bin_n_nonevent=None, min_bin_n_event=None, max_bin_n_event=None, monotonic_trend='auto', min_e...
4,743
optbinning.binning.binning
__init__
null
def __init__(self, name="", dtype="numerical", prebinning_method="cart", solver="cp", divergence="iv", max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, min_bin_n_nonevent=None, max_bin_n_nonevent=None, min...
(self, name='', dtype='numerical', prebinning_method='cart', solver='cp', divergence='iv', max_n_prebins=20, min_prebin_size=0.05, min_n_bins=None, max_n_bins=None, min_bin_size=None, max_bin_size=None, min_bin_n_nonevent=None, max_bin_n_nonevent=None, min_bin_n_event=None, max_bin_n_event=None, monotonic_trend='auto',...
4,751
optbinning.binning.binning
_fit
null
def _fit(self, x, y, sample_weight, check_input): time_init = time.perf_counter() if self.verbose: logger.info("Optimal binning started.") logger.info("Options: check parameters.") _check_parameters(**self.get_params()) # Pre-processing if self.verbose: logger.info("Pre-proce...
(self, x, y, sample_weight, check_input)