MCPcopy Create free account
hub / github.com/modAL-python/modAL / Committee

Class Committee

modAL/models/learners.py:438–629  ·  view source on GitHub ↗

This class is an abstract model of a committee-based active learning algorithm. Args: learner_list: A list of ActiveLearners forming the Committee. query_strategy: Query strategy function. Committee supports disagreement-based query strategies from :mod:`modAL.di

Source from the content-addressed store, hash-verified

436
437
438class Committee(BaseCommittee):
439 """
440 This class is an abstract model of a committee-based active learning algorithm.
441 Args:
442 learner_list: A list of ActiveLearners forming the Committee.
443 query_strategy: Query strategy function. Committee supports disagreement-based query strategies from
444 :mod:`modAL.disagreement`, but uncertainty-based ones from :mod:`modAL.uncertainty` are also supported.
445 on_transformed: Whether to transform samples with the pipeline defined by each learner's estimator
446 when applying the query strategy.
447 Attributes:
448 classes_: Class labels known by the Committee.
449 n_classes_: Number of classes known by the Committee.
450 Examples:
451 >>> from sklearn.datasets import load_iris
452 >>> from sklearn.neighbors import KNeighborsClassifier
453 >>> from sklearn.ensemble import RandomForestClassifier
454 >>> from modAL.models import ActiveLearner, Committee
455 >>>
456 >>> iris = load_iris()
457 >>>
458 >>> # initialize ActiveLearners
459 >>> learner_1 = ActiveLearner(
460 ... estimator=RandomForestClassifier(),
461 ... X_training=iris['data'][[0, 50, 100]], y_training=iris['target'][[0, 50, 100]]
462 ... )
463 >>> learner_2 = ActiveLearner(
464 ... estimator=KNeighborsClassifier(n_neighbors=3),
465 ... X_training=iris['data'][[1, 51, 101]], y_training=iris['target'][[1, 51, 101]]
466 ... )
467 >>>
468 >>> # initialize the Committee
469 >>> committee = Committee(
470 ... learner_list=[learner_1, learner_2]
471 ... )
472 >>>
473 >>> # querying for labels
474 >>> query_idx, query_sample = committee.query(iris['data'])
475 >>>
476 >>> # ...obtaining new labels from the Oracle...
477 >>>
478 >>> # teaching newly labelled examples
479 >>> committee.teach(
480 ... X=iris['data'][query_idx].reshape(1, -1),
481 ... y=iris['target'][query_idx].reshape(1, )
482 ... )
483 """
484 def __init__(self, learner_list: List[ActiveLearner], query_strategy: Callable = vote_entropy_sampling,
485 on_transformed: bool = False) -> None:
486 super().__init__(learner_list, query_strategy, on_transformed)
487 self._set_classes()
488
489 def _set_classes(self):
490 """
491 Checks the known class labels by each learner, merges the labels and returns a mapping which maps the learner's
492 classes to the complete label list.
493 """
494 # assemble the list of known classes from each learner
495 try:

Callers 7

ensemble.pyFile · 0.90
bagging.pyFile · 0.90
modAL_QBCFunction · 0.90
ensemble.pyFile · 0.90
bagging.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…