ClassifierRegistry<T>
Helpers & Utilities · AiDotNet.Classification
Registry for creating classifier instances by type name, enabling serialization and deserialization of wrapped classifiers in Meta and MultiLabel classifiers.
For Beginners
When a Meta or MultiLabel classifier wraps other classifiers (e.g., BaggingClassifier wraps an array of base classifiers), we need a way to save and restore those wrapped classifiers. The registry maps classifier type names to concrete types that can be instantiated for deserialization.
How It Works
All built-in AiDotNet classifiers are automatically registered. If you create custom
classifiers, register them with Register before deserializing
models that wrap them.
Usage:
Properties
| Property | Summary |
|---|---|
IReadOnlyCollection<string> RegisteredTypes { get; } |
Returns all registered type names. |
Methods
| Method | Summary |
|---|---|
IClassifier<T> Create(string typeName) |
Creates a new, untrained classifier instance by type name. |
IClassifier<T> DeserializeClassifier(string typeName, string serializedData) |
Deserializes a wrapped classifier from a type name and base64-encoded data. |
ValueTuple<string, string> SerializeClassifier(IClassifier<T> classifier) |
Serializes a wrapped classifier into a type name and base64-encoded data pair. |
bool IsRegistered(string typeName) |
Checks whether a type name is registered. |
string GetTypeName(IClassifier<T> classifier) |
Gets the short type name for a classifier instance. |
void EnsureInitialized() |
Ensures all built-in classifiers are registered. |
void Register() |
Registers a classifier type using generics. |
void Register(string typeName, Type classifierType) |
Registers a classifier type by name and Type object. |