imbalanced_svr.SPBoDF#

class imbalanced_spdf.SPBoDF(n_trees=40, weight=1, pen=0, maximal_leaves=None, random_state=23)[source]#

Shape Penalty Boosting Decision Forest (SPBoDF)

This class implements a boosting ensemble method for imbalanced_spdf data using SVR (Surface-to-Volume Regularization) trees. The ensemble is trained to optimize decision boundaries, balancing interpretability with generalization by penalizing irregular decision surfaces.

Parameters:
  • n_trees (int, default=40) – The number of trees in the ensemble. Each tree represents one boosting round.

  • weight (float, default=1) – Weight multiplier for the minority class to address class imbalance. Denoted by λ in the associated research paper.

  • pen (float, default=0) – Regularization penalty for controlling the shape of the decision set, represented as α_n in the research paper.

  • maximal_leaves (int or float, default=None) – Maximum number of leaves allowed for each tree. If None, defaults to 2 * np.sqrt(n_samples) * 0.3333 dynamically for each boosting round.

  • random_state (int, default=23) – Random seed for reproducibility.

estimators_[source]#

List of fitted tree estimators in the ensemble.

Type:

list

estimator_weights_[source]#

List of weights associated with each tree in the ensemble.

Type:

list

columns_to_take_[source]#

List of feature subsets selected for each tree, useful for analyzing feature importance.

Type:

list

classes_[source]#

Unique class labels observed during training.

Type:

ndarray of shape (n_classes,)

__init__(n_trees=40, weight=1, pen=0, maximal_leaves=None, random_state=23)[source]#

Methods

__init__([n_trees, weight, pen, ...])

fit(X, y)

Train the SPBoDF ensemble on the given dataset.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict labels for input samples using the trained ensemble.

score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

fit(X, y)[source]#

Train the SPBoDF ensemble on the given dataset.

Parameters:
  • X (ndarray of shape (n_samples, n_features)) – Feature matrix for training.

  • y (ndarray of shape (n_samples,)) – Target labels for training.

Returns:

self – Returns the instance of the fitted ensemble.

Return type:

SPBoDF

get_metadata_routing()[source]#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)[source]#

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 – Parameter names mapped to their values.

Return type:

dict

predict(X)[source]#

Predict labels for input samples using the trained ensemble.

Parameters:

X (ndarray of shape (n_samples, n_features)) – Input features for prediction.

Returns:

y_pred – Predicted labels.

Return type:

ndarray of shape (n_samples,)

score(X, y, sample_weight=None)[source]#

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.

  • sample_weight (array-like of shape (n_samples,), default=None) – Sample weights.

Returns:

score – Mean accuracy of self.predict(X) w.r.t. y.

Return type:

float

set_params(**params)[source]#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SPBoDF[source]#

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object