brew.selection.dynamic package

Submodules

brew.selection.dynamic.base module

class brew.selection.dynamic.base.DCS(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: object

get_neighbors(x, return_distance=False)
select(ensemble, x)

brew.selection.dynamic.knora module

class brew.selection.dynamic.knora.KNORA(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: brew.selection.dynamic.base.DCS

class brew.selection.dynamic.knora.KNORA_ELIMINATE(Xval, yval, K=5, weighted=False, knn=None, v2007=False)[source]

Bases: brew.selection.dynamic.knora.KNORA

K-nearest-oracles Eliminate.

The KNORA Eliminate reduces the neighborhood until finds an ensemble of classifiers that correctly classify all neighbors.

`Xval`

array-like, shape = [indeterminated, n_features]

Validation set.

`yval`

array-like, shape = [indeterminated]

Labels of the validation set.

`knn`

sklearn KNeighborsClassifier,

Classifier used to find neighborhood.

`weighted`

bool, (makes no difference in knora_eliminate)

Bool that defines if the classifiers uses weights or not

Examples

>>> from brew.selection.dynamic.knora import KNORA_ELIMINATE
>>> from brew.generation.bagging import Bagging
>>> from brew.base import EnsembleClassifier
>>>
>>> from sklearn.tree import DecisionTreeClassifier
>>> import numpy as np
>>>
>>> X = np.array([[-1, 0], [-0.8, 1], [-0.8, -1], [-0.5, 0] , [0.5, 0], [1, 0], [0.8, 1], [0.8, -1]])
>>> y = np.array([1, 1, 1, 2, 1, 2, 2, 2])
>>>
>>> dt = DecisionTreeClassifier(max_depth=1, min_samples_leaf=1)
>>> bag = Bagging(base_classifier=dt, n_classifiers=10)
>>> bag.fit(X, y)
>>>
>>> ke = KNORA_ELIMINATE(X, y, K=5)
>>>
>>> clf = EnsembleClassifier(bag.ensemble, selector=ke)
>>> clf.predict([-1.1,-0.5])
[1]

See also

brew.selection.dynamic.knora.KNORA_UNION
KNORA Union.
brew.selection.dynamic.lca.LCA
Local Class Accuracy.
brew.selection.dynamic.ola.OLA
Overall Local Accuracy.

References

Ko, Albert HR, Robert Sabourin, and Alceu Souza Britto Jr. “From dynamic classifier selection to dynamic ensemble selection.” Pattern Recognition 41.5 (2008): 1718-1731.

Britto, Alceu S., Robert Sabourin, and Luiz ES Oliveira. “Dynamic selection of classifiers—A comprehensive review.” Pattern Recognition 47.11 (2014): 3665-3680.

Hung-Ren Ko, A., Robert Sabourin, and A. de Souza Britto. “K-nearest oracle for dynamic ensemble selection.” Document Analysis and Recognition, 2007. ICDAR 2007. Ninth International Conference on. Vol. 1. IEEE, 2007

select(ensemble, x)[source]
class brew.selection.dynamic.knora.KNORA_UNION(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: brew.selection.dynamic.knora.KNORA

K-nearest-oracles Union.

The KNORA union reduces the neighborhood until finds an ensemble of classifiers that correctly classify all neighbors.

`Xval`

array-like, shape = [indeterminated, n_features]

Validation set.

`yval`

array-like, shape = [indeterminated]

Labels of the validation set.

`knn`

sklearn KNeighborsClassifier,

Classifier used to find neighborhood.

`weighted`

bool, (makes no difference in knora_eliminate)

Bool that defines if the classifiers uses weights or not

Examples

>>> from brew.selection.dynamic.knora import KNORA_UNION
>>> from brew.generation.bagging import Bagging
>>> from brew.base import EnsembleClassifier
>>>
>>> from sklearn.tree import DecisionTreeClassifier
>>> import numpy as np
>>>
>>> X = np.array([[-1, 0], [-0.8, 1], [-0.8, -1], [-0.5, 0] , [0.5, 0], [1, 0], [0.8, 1], [0.8, -1]])
>>> y = np.array([1, 1, 1, 2, 1, 2, 2, 2])
>>>
>>> dt = DecisionTreeClassifier(max_depth=1, min_samples_leaf=1)
>>> bag = Bagging(base_classifier=dt, n_classifiers=10)
>>> bag.fit(X, y)
>>>
>>> ku = KNORA_UNION(X, y, K=5)
>>>
>>> clf = EnsembleClassifier(bag.ensemble, selector=ku)
>>> clf.predict([-1.1,-0.5])
[1]

See also

brew.selection.dynamic.knora.KNORA_ELIMINATE
Knora Eliminate.
brew.selection.dynamic.lca.LCA
Local Class Accuracy.
brew.selection.dynamic.ola.OLA
Overall Local Accuracy.

References

Ko, Albert HR, Robert Sabourin, and Alceu Souza Britto Jr. “From dynamic classifier selection to dynamic ensemble selection.” Pattern Recognition 41.5 (2008): 1718-1731.

Britto, Alceu S., Robert Sabourin, and Luiz ES Oliveira. “Dynamic selection of classifiers—A comprehensive review.” Pattern Recognition 47.11 (2014): 3665-3680.

Hung-Ren Ko, A., Robert Sabourin, and A. de Souza Britto. “K-nearest oracle for dynamic ensemble selection.” Document Analysis and Recognition, 2007. ICDAR 2007. Ninth International Conference on. Vol. 1. IEEE, 2007.

select(ensemble, x)[source]

brew.selection.dynamic.lca module

class brew.selection.dynamic.lca.LCA(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: brew.selection.dynamic.base.DCS

Local Class Accuracy.

The Local Class Accuracy selects the best classifier for a sample using it’s K nearest neighbors.

`Xval`

array-like, shape = [indeterminated, n_features]

Validation set.

`yval`

array-like, shape = [indeterminated]

Labels of the validation set.

`knn`

sklearn KNeighborsClassifier,

Classifier used to find neighborhood.

Examples

>>> from brew.selection.dynamic.lca import LCA
>>> from brew.generation.bagging import Bagging
>>> from brew.base import EnsembleClassifier
>>>
>>> from sklearn.tree import DecisionTreeClassifier
>>> import numpy as np
>>>
>>> X = np.array([[-1, 0], [-0.8, 1], [-0.8, -1], [-0.5, 0] , [0.5, 0], [1, 0], [0.8, 1], [0.8, -1]])
>>> y = np.array([1, 1, 1, 2, 1, 2, 2, 2])
>>>
>>> bag = Bagging(base_classifier=DecisionTreeClassifier(max_depth=1, min_samples_leaf=1), n_classifiers=10)
>>> bag.fit(X, y)
>>>
>>> lca = LCA(X, y, K=3)
>>>
>>> clf = EnsembleClassifier(bag.ensemble, selector=lca)
>>> clf.predict([-1.1,-0.5])
[1]

See also

brew.selection.dynamic.ola.OLA
Overall Local Accuracy.

References

Woods, Kevin, Kevin Bowyer, and W. Philip Kegelmeyer Jr. “Combination of multiple classifiers using local accuracy estimates.” Computer Vision and Pattern Recognition, 1996. Proceedings CVPR‘96, 1996 IEEE Computer Society Conference on. IEEE, 1996.

Ko, Albert HR, Robert Sabourin, and Alceu Souza Britto Jr. “From dynamic classifier selection to dynamic ensemble selection.” Pattern Recognition 41.5 (2008): 1718-1731.

select(ensemble, x)[source]
class brew.selection.dynamic.lca.LCA2(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: brew.selection.dynamic.base.DCS

select(ensemble, x)

brew.selection.dynamic.ola module

class brew.selection.dynamic.ola.OLA(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: brew.selection.dynamic.base.DCS

Overall Local Accuracy.

The Overall Local Accuracy selects the best classifier for a sample using it’s K nearest neighbors.

`Xval`

array-like, shape = [indeterminated, n_features]

Validation set.

`yval`

array-like, shape = [indeterminated]

Labels of the validation set.

`knn`

sklearn KNeighborsClassifier,

Classifier used to find neighborhood.

Examples

>>> from brew.selection.dynamic.ola import OLA
>>> from brew.generation.bagging import Bagging
>>> from brew.base import EnsembleClassifier
>>>
>>> from sklearn.tree import DecisionTreeClassifier
>>> import numpy as np
>>>
>>> X = np.array([[-1, 0], [-0.8, 1], [-0.8, -1], [-0.5, 0] , [0.5, 0], [1, 0], [0.8, 1], [0.8, -1]])
>>> y = np.array([1, 1, 1, 2, 1, 2, 2, 2])
>>>
>>> bag = Bagging(base_classifier=DecisionTreeClassifier(max_depth=1, min_samples_leaf=1), n_classifiers=10)
>>> bag.fit(X, y)
>>>
>>> ola = OLA(X, y, K=3)
>>>
>>> clf = EnsembleClassifier(bag.ensemble, selector=ola)
>>> clf.predict([-1.1,-0.5])
[1]

See also

brew.selection.dynamic.lca.LCA
Local Class Accuracy.

References

Woods, Kevin, Kevin Bowyer, and W. Philip Kegelmeyer Jr. “Combination of multiple classifiers using local accuracy estimates.” Computer Vision and Pattern Recognition, 1996. Proceedings CVPR‘96, 1996 IEEE Computer Society Conference on. IEEE, 1996.

Ko, Albert HR, Robert Sabourin, and Alceu Souza Britto Jr. “From dynamic classifier selection to dynamic ensemble selection.” Pattern Recognition 41.5 (2008): 1718-1731.

select(ensemble, x)[source]
class brew.selection.dynamic.ola.OLA2(Xval, yval, K=5, weighted=False, knn=None)[source]

Bases: brew.selection.dynamic.base.DCS

select(ensemble, x)[source]

Module contents