MultiLabelClassifierBase<T>

Base Classes · AiDotNet.Classification.MultiLabel

Base class for multi-label classification models.

Implements: IModelShape, IMultiLabelClassifier<T>, IParameterChunkSource<T>, IParameterManifestProvider

Known derived types: BinaryRelevance<T>, ClassifierChainClassifier<T>, LabelPowerset<T>, MLkNNClassifier<T>, RAkELClassifier<T>

For Beginners

This base class provides common functionality for multi-label classifiers. Multi-label classification assigns multiple labels to each sample, unlike traditional classification which assigns exactly one label.

Properties

Property Summary
ClassificationTaskType TaskType { get; set; } Gets or sets the classification task type.
ILossFunction<T> DefaultLossFunction { get; }
ParameterLayoutSnapshot ParameterLayout { get; }
bool SupportsParameterInitialization { get; }
int NumClasses { get; set; } Gets or sets the number of classes (typically 2 for binary classification per label).
int NumFeatures { get; set; } Gets or sets the number of features.
int NumLabels { get; set; } Gets or sets the number of possible labels.
long ParameterCount { get; }
string[] FeatureNames { get; set; } Gets or sets the feature names.
string[] LabelNames { get; set; } Gets or sets the label names if available.

Methods

Method Summary
Dictionary<string, T> GetFeatureImportance()
DynamicShapeInfo GetDynamicShapeInfo()
IEnumerable<ParameterChunk<T>> GetParameterStateChunks() Enumerates canonical persistent state without flattening tensor-backed components.
IEnumerable<Tensor<T>> GetParameterChunks() Streams state in the same order as the parameter manifest.
IEnumerable<int> GetActiveFeatureIndices()
IFullModel<T, Matrix<T>, Matrix<T>> Clone()
IFullModel<T, Matrix<T>, Matrix<T>> DeepCopy()
IFullModel<T, Matrix<T>, Matrix<T>> WithParameters(Vector<T> parameters)
Matrix<T> Predict(Matrix<T> features) Predicts binary label indicators for input samples.
Matrix<T> PredictMultiLabelProbabilities(Matrix<T> input) Core probability prediction implementation to be overridden by derived classes.
Matrix<T> PredictProbabilities(Matrix<T> features) Predicts label probabilities for input samples.
ModelMetadata<T> GetModelMetadata()
ModelOptions GetOptions()
Vector<T> ComputeGradients(Matrix<T> input, Matrix<T> target, ILossFunction<T> lossFunction)
Vector<T> GetParameters()
Vector<T> SanitizeParameters(Vector<T> parameters)
bool IsFeatureUsed(int featureIndex)
byte[] Serialize()
int[] GetInputShape()
int[] GetOutputShape()
void ApplyGradients(Vector<T> gradients, T learningRate)
void Deserialize(byte[] modelData)
void Dispose()
void LoadModel(string path)
void LoadState(Stream stream)
void SaveModel(string path)
void SaveState(Stream stream)
void SetActiveFeatureIndices(IEnumerable<int> featureIndices)
void SetParameterChunks(IEnumerable<Tensor<T>> chunks) Restores tensor-backed chunks on their device and retains custom-setter semantics.
void SetParameters(Vector<T> parameters)
void Train(Matrix<T> features, Matrix<T> labels) Trains the multi-label classifier.