crowdkit.aggregation.multilabel.binary_relevance.BinaryRelevance
| Source code
BinaryRelevance(self, base_aggregator: BaseClassificationAggregator = ...)
Simple aggregation algorithm for multi-label classification.
Binary Relevance is a straightforward approach for multi-label classification aggregation: each label is treated as a class in binary classification problem and aggregated separately using aggregation algorithms for classification, e.g. Majority Vote or Dawid Skene.
If this method is used for single-label classification, the output of the BinaryRelevance method may differ from the output of the basic aggregator used for its intended purpose, since each class generates a binary classification task, and therefore it is considered separately. For example, some objects may not have labels.
Parameters | Type | Description |
---|---|---|
base_aggregator | BaseClassificationAggregator | Aggregator instance that will be used for each binary classification. All class parameters will be copied, except for the results of previous fit. |
labels_ | Optional[Series] | Tasks' labels. A pandas.Series indexed by |
aggregators_ | Dict[str, BaseClassificationAggregator] | Labels' aggregators matched to classes. A dictionary that matches aggregators to classes. The key is the class found in the source data, and the value is the aggregator used for this class. The set of keys is all the classes that are in the input data. |
Examples:
import pandas as pdfrom crowdkit.aggregation import BinaryRelevance, DawidSkenedf = pd.DataFrame( [ ['t1', 'w1', ['house', 'tree']], ['t1', 'w2', ['house']], ['t1', 'w3', ['house', 'tree', 'grass']], ['t2', 'w1', ['car']], ['t2', 'w2', ['car', 'human']], ['t2', 'w3', ['train']] ])df.columns = ['task', 'worker', 'label']result = BinaryRelevance(DawidSkene(n_iter=10)).fit_predict(df)
Method | Description |
---|---|
fit | Fit the aggregators. |
fit_predict | Fit the model and return aggregated results. |
Last updated: March 31, 2023