ensemble_learner.base_bagging
Base functions and classes for bagging models using hyperbox-based models.
- class hbbrain.numerical_data.ensemble_learner.base_bagging.BaseBagging(base_estimator=None, n_estimators=10, *, max_samples=0.5, bootstrap=False, class_balanced=False, n_jobs=None, random_state=None)[source]
Bases:
BaseEnsemble
Base class for Bagging meta-estimator. Warning: This class should not be used directly. Use derived classes instead.
- Attributes:
estimators_samples_
The subset of drawn samples for each base estimator.
Methods
fit
(X, y)Build a Bagging ensemble of estimators from the training set (X, y).
Get total number of hyperboxes in all base learners.
get_params
([deep])Get parameters for this estimator.
set_params
(**params)Set the parameters of this estimator.
simple_pruning_base_estimators
(X_val, y_val)Simply prune low qualitied hyperboxes based on a pre-defined accuracy threshold for each hyperbox.
- property estimators_samples_[source]
The subset of drawn samples for each base estimator. Returns a dynamically generated list of indices identifying the samples used for fitting each member of the ensemble, i.e., the in-bag samples.
Note
The list is re-created at each call to the property in order to reduce the object memory footprint by not storing the sampling data. Thus fetching the property may be slower than expected.
- fit(X, y)[source]
Build a Bagging ensemble of estimators from the training set (X, y).
- Parameters:
- Xarray-like of shape (n_samples, n_features)
The training input samples.
- yarray-like of shape (n_samples,)
The real class labels
- Returns:
- selfobject
Fitted estimator.
- get_n_hyperboxes()[source]
Get total number of hyperboxes in all base learners.
- Returns:
- n_hyperboxesint
Total number of hyperboxes in all base learners.
- simple_pruning_base_estimators(X_val, y_val, acc_threshold=0.5, keep_empty_boxes=False)[source]
Simply prune low qualitied hyperboxes based on a pre-defined accuracy threshold for each hyperbox. This operation is applied for all base estimators.
- Parameters:
- X_valarray-like of shape (n_samples, n_features)
The data matrix contains validation patterns.
- y_valndarray of shape (n_samples,)
A vector contains the true class label corresponding to each validation pattern.
- acc_thresholdfloat, optional, default=0.5
The minimum accuracy for each hyperbox to be kept unchanged.
- keep_empty_boxesboolean, optional, default=False
Whether to keep the hyperboxes which do not join the prediction process on the validation set. If True, keep them, else the decision for keeping or removing based on the classification accuracy on the validation dataset
- Returns:
- self
A bagging model with base estimators prunned.