Voting ensemble implementations for classification and regression.
Classes
VotingClassifier for combining heterogeneous classifiers via voting rules.
__init__( self, classifiers: List[Any] = None, combination_rule: str = 'average', )
Overview
The algorithm proceeds as follows:
- Train each of the L base classifiers independently on the full training set
- To predict, collect outputs (predictions or probabilities) from all classifiers
- Apply the selected combination rule to aggregate the outputs
- Return the class with the highest aggregated score
Theory
Let p_l(k|x) denote the posterior probability estimate from classifier h_l for class k given input x. The combination rules are:
Average rule:
Product rule:
Majority voting rule:
Median rule:
Parameters
classifiers
combination_rule
Attributes
estimators_
classes_
fit().
Notes
Complexity:
- Training: O(\sum_{l=1}^{L} C_l) where C_l is the training
- Prediction: O(\sum_{l=1}^{L} C_l^{\text{pred}}) per sample
- When you have multiple diverse classifiers with comparable performance
- When you want a simple combination without learning combination weights
- When base classifiers make independent errors (low correlation)
- As a baseline before trying more complex methods like stacking
References
See Also
Basic usage for combining classifiers with voting:
>>> from tuiml.algorithms.ensemble import VotingClassifier
>>> import numpy as np
>>>
>>> # Create sample training data
>>> X_train = np.array([[1, 2], [2, 3], [3, 1], [4, 3], [5, 2]])
>>> y_train = np.array([0, 0, 1, 1, 1])
>>>
>>> # Fit the Voting classifier with average rule
>>> clf = VotingClassifier(
... classifiers=['NaiveBayesClassifier', 'DecisionTreeClassifier'],
... combination_rule='average'
... )
>>> clf.fit(X_train, y_train)
VotingClassifier(...)
>>> predictions = clf.predict(X_train)
Methods
get_parameter_schema
(cls) -> Dict[str, Dict[str, Any]]
get_capabilities
(cls) -> List[str]
get_complexity
(cls) -> str
get_references
(cls) -> List[str]
__repr__
(self) -> str
VotingRegressor for combining heterogeneous regressors via aggregation rules.
__init__( self, regressors: List[Any] = None, combination_rule: str = 'average', )
Overview
The algorithm proceeds as follows:
- Train each of the L base regressors independently on the full training set
- To predict, collect outputs (predictions) from all regressors
- Apply the selected combination rule to aggregate the outputs
Theory
Let h_l(x) denote the prediction from regressor h_l for input x. The combination rules are:
Average rule:
Median rule:
Max / Min rules:
Parameters
regressors
combination_rule
Attributes
estimators_
Notes
Complexity:
- Training: O(\sum_{l=1}^{L} C_l) where C_l is the training
- Prediction: O(\sum_{l=1}^{L} C_l^{\text{pred}}) per sample
- When you have multiple diverse regressors with comparable performance
- When you want a simple combination without learning combination weights
- When base regressors make independent errors (low correlation)
- As a baseline before trying more complex methods like stacking
References
See Also
Basic usage for combining regressors with voting:
>>> from tuiml.algorithms.ensemble import VotingRegressor
>>> import numpy as np
>>>
>>> # Create sample training data
>>> X_train = np.array([[1, 2], [2, 3], [3, 1], [4, 3], [5, 2]])
>>> y_train = np.array([1.5, 2.3, 3.1, 4.2, 5.0])
>>>
>>> # Fit the Voting regressor with average rule
>>> reg = VotingRegressor(
... regressors=['GradientBoostingRegressor'],
... combination_rule='average'
... )
>>> reg.fit(X_train, y_train)
VotingRegressor(...)
>>> predictions = reg.predict(X_train)