alpbench.util.ensemble_constructor¶
Classes
|
This class is used to create an ensemble of estimators. |
- class alpbench.util.ensemble_constructor.Ensemble(estimator, num_estimators, max_neighbors=None)[source]¶
Bases:
objectThis class is used to create an ensemble of estimators. The ensemble can be used to predict the probabilities of the ensemble members and the classes of the ensemble members.
- Parameters:
estimator – object
num_estimators – int
max_neighbors – int (for k nearest neighbors) else None
- estimator¶
object (the estimator to construct the ensemble of)
- num_estimators¶
int (the number of estimators in the ensemble)
- max_neighbors¶
int (for k nearest neighbors)
- random_states¶
list (random states for the ensemble members)
- estimators_¶
list (list containing the ensemble members)
- learner_fqn¶
str (fully qualified name of the estimator)
- fit(X, y)[source]¶
Fits the ensemble and sets the attributes of the class.
- Parameters:
X (array-like of shape (n_samples, n_features)) – The training input samples.
y (array-like of shape (n_samples,)) –
integers. (The target values (class labels) as) –
- Return type:
None
- predict(X, alpha=None)[source]¶
Predicts the classes of the ensemble members.
- Parameters:
X (array-like of shape (n_samples, n_features)) – The training input samples. alpha : float, optional (default=None) The threshold for the normalized likelihoods of the ensemble members.
- Returns:
preds
- Return type:
predicted classes, array-like of shape (n_samples, n_estimators)
- predict_proba(X, alpha=None)[source]¶
Predicts the probabilities of the ensemble members.
- Parameters:
X (array-like of shape (n_samples, n_features)) – The training input samples. alpha : float, optional (default=None) The threshold for the normalized likelihoods of the ensemble members.
- Returns:
preds
- Return type:
predicted probabilities, array-like of shape (n_samples, n_classes, n_estimators)