RAkELClassifier<T>

Models & Types · AiDotNet.Classification.MultiLabel

Implements RAkEL (Random k-Labelsets) for multi-label classification.

Inheritance: MultiLabelClassifierBase<T> → RAkELClassifier<T>

For Beginners

RAkEL solves multi-label classification by training multiple Label Powerset classifiers on random subsets of k labels each. This captures label correlations (like Label Powerset) while avoiding the exponential explosion of label combinations.

How It Works

How it works:

  • Randomly partition labels into overlapping subsets of size k
  • Train a Label Powerset classifier on each subset
  • Combine predictions by voting across all classifiers that predict each label

Key parameters:

  • k: Size of each labelset (default: 3). Larger k captures more correlations but has more classes.
  • numLabelsets: Number of random labelsets to create (default: 2*numLabels)

Reference: Tsoumakas et al., “Random k-Labelsets for Multilabel Classification” (2011)

Example

var features = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
var labels = new Matrix<double>(new double[,] { { 1.0, 0.0 }, { 0.0, 1.0 }, { 1.0, 1.0 }, { 0.0, 0.0 } });
var newSample = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
// Use AiModelBuilder facade for rakelclassifier classification
var builder = new AiModelBuilder<double, Matrix<double>, Matrix<double>>()
    .ConfigureModel(new RAkELClassifier<double>(labelsetSize: 3));
            
var result = builder.Build(features, labels);
var prediction = result.Predict(newSample);

Constructors

Constructor Summary
RAkELClassifier(int labelsetSize, int numLabelsets, int? seed, ClassifierOptions<T> options, IRegularization<T, Matrix<T>, Vector<T>> regularization) Creates a new RAkEL classifier.

Properties

Property Summary
int LabelsetSize { get; set; } Gets the size of each labelset (k parameter).
int NumLabelsets { get; set; } Gets the number of labelsets to create.

Methods

Method Summary
Matrix<T> PredictMultiLabelProbabilities(Matrix<T> input) Predicts multi-label probabilities using RAkEL voting.