pusion.auto.auto_combiner¶
- class pusion.auto.auto_combiner.AutoCombiner¶
Bases:
pusion.auto.generic_combiner.GenericCombiner
The AutoCombiner allows for automatic decision fusion using all methods provided by the framework, which are applicable to the given problem. The key feature of this combiner is the transparency in terms of it’s outer behaviour. Based on the usage (i.e. method calls) and the automatically detected configuration, the AutoCombiner preselects all compatible methods from pusion.core. The main purpose is to retrieve fusion results obtained by the methods with the best performance without further user interaction.
- train(decision_tensor, true_assignments, **kwargs)¶
Train the AutoCombiner (AC) model. This method detects the configuration based on the
decision_tensor
and trains all trainable combiners that are applicable to this configuration.- Parameters
decision_tensor –
numpy.array of shape (n_classifiers, n_samples, n_classes) or a list of numpy.array elements of shape (n_samples, n_classes’), where n_classes’ is classifier-specific due to the coverage.
Tensor of either crisp or continuous decision outputs by different classifiers per sample.
true_assignments – numpy.array of shape (n_samples, n_classes). Matrix of either crisp or continuous class assignments which are considered true for each sample during the training procedure.
- combine(decision_tensor)¶
Combine decision outputs using the AutoCombiner (AC) model. Both continuous and crisp classification outputs are supported. This procedure involves selecting the best method regarding its classification performance in case of a trained AC.
- Parameters
decision_tensor –
numpy.array of shape (n_classifiers, n_samples, n_classes) or a list of numpy.array elements of shape (n_samples, n_classes’), where n_classes’ is classifier-specific due to the coverage.
Tensor of either crisp or continuous decision outputs by different classifiers per sample.
- Returns
A matrix (numpy.array) of crisp or continuous class assignments which represents fused decisions. Axis 0 represents samples and axis 1 the class labels which are aligned with axis 2 in
decision_tensor
input tensor.
- set_validation_size(validation_size)¶
Set the validation size, based on which the training data is split and the best combiner is selected.
- Parameters
validation_size – A float between 0 and 1.0. Ratio of the validation data set.
- combine_par(decision_tensor)¶
Combine decision outputs by GC. Both continuous and crisp classification outputs are supported. This procedure involves combining decision outputs by each individual method which is applicable to the detected configuration. Each combine procedure is spawned in a separate thread and thus performed in parallel.
- Parameters
decision_tensor –
numpy.array of shape (n_classifiers, n_samples, n_classes) or a list of numpy.array elements of shape (n_samples, n_classes’), where n_classes’ is classifier-specific due to the coverage.
Tensor of either crisp or continuous decision outputs by different classifiers per sample.
- Returns
list of numpy.array of shape (n_samples, n_classifiers). Fusion results obtained by selected fusion methods. The list is aligned with the list of preselected fusion methods (retrievable by
get_combiners()
).
- combine_seq(decision_tensor)¶
Combine decision outputs by GC. Both continuous and crisp classification outputs are supported. This procedure involves combining decision outputs by each individual method which is applicable to the detected configuration. Each combine procedure is initiated in sequence.
- Parameters
decision_tensor –
numpy.array of shape (n_classifiers, n_samples, n_classes) or a list of numpy.array elements of shape (n_samples, n_classes’), where n_classes’ is classifier-specific due to the coverage.
Tensor of either crisp or continuous decision outputs by different classifiers per sample.
- Returns
list of numpy.array of shape (n_samples, n_classifiers). Fusion results obtained by selected fusion methods. The list is aligned with the list of preselected fusion methods (retrievable by
get_combiners()
).
- get_combiner_type_selection()¶
- Returns
list of combiner types established by usage.
- get_combiners()¶
- Returns
list of core methods preselected by the AutoCombiner.
- get_multi_combiner_decision_tensor()¶
- Returns
list of numpy.array of shape (n_samples, n_classifiers). Fusion results obtained by selected fusion methods. The list is aligned with the list of preselected fusion methods (retrievable by
get_combiners()
).
- get_multi_combiner_runtimes()¶
- Returns
A tuple of two lists of tuples describing the train and combine runtimes respectively. Each inner tuple key value indexes the list of preselected fusion methods (retrievable by
get_combiners()
).
- get_pac()¶
- Returns
tuple of detected problem, assignment type and coverage type.
- get_selected_combiner()¶
- Returns
The method selected by the AutoCombiner.
- classmethod obtain(config)¶
Obtain a combiner registered by the framework.
- Parameters
config –
pusion.model.configuration.Configuration
. User-defined configuration.- Returns
A combiner object.
- set_coverage(coverage)¶
Set the coverage in case of complementary-redundant classification data.
- Parameters
coverage – The coverage is described by using a nested list. Each list describes the classifier based on its position. Elements of those lists (integers) describe the actual class coverage of the respective classifier. E.g., with
[[0,1], [0,2,3]]
the classes 0,1 are covered by the first classifier and 0,2,3 are covered by the second one.
- set_evidence(evidence)¶
Set the evidence for evidence based combiners. This method preselects all combiners of type EvidenceBasedCombiner.
- Parameters
evidence – numpy.array of shape (n_classifiers, n_classes, n_classes). Confusion matrices for each of n classifiers.
- set_parallel(parallel=True)¶
Set whether the training and the combining of selected combiners should be executed sequentially or in parallel. :param parallel: If True, training and combining is performed in parallel respectively. Otherwise in sequence.
- train_par(decision_tensor, true_assignments)¶
Train the Generic Combiner by training individual combiners in parallel. This method detects the configuration based on the
decision_tensor
and trains all trainable combiners that are applicable to this configuration.- Parameters
decision_tensor –
numpy.array of shape (n_classifiers, n_samples, n_classes) or a list of numpy.array elements of shape (n_samples, n_classes’), where n_classes’ is classifier-specific due to the coverage.
Tensor of either crisp or continuous decision outputs by different classifiers per sample.
true_assignments – numpy.array of shape (n_samples, n_classes). Matrix of either crisp or continuous class assignments which are considered true for each sample during the training procedure.
- train_seq(decision_tensor, true_assignments)¶
Train the Generic Combiner by training individual combiners in sequence. This method detects the configuration based on the
decision_tensor
and trains all trainable combiners that are applicable to this configuration.- Parameters
decision_tensor –
numpy.array of shape (n_classifiers, n_samples, n_classes) or a list of numpy.array elements of shape (n_samples, n_classes’), where n_classes’ is classifier-specific due to the coverage.
Tensor of either crisp or continuous decision outputs by different classifiers per sample.
true_assignments – numpy.array of shape (n_samples, n_classes). Matrix of either crisp or continuous class assignments which are considered true for each sample during the training procedure.
- get_eval_metric()¶
- Returns
The metric used for the selection of the best performing combiner.