MarginSampling<T>
Models & Types · AiDotNet.ActiveLearning
Implements margin sampling for active learning sample selection.
Implements: IActiveLearningStrategy<T>
For Beginners
Margin sampling selects samples where the difference between the top two predicted class probabilities is smallest. A small margin indicates the model is uncertain between two classes, suggesting the sample is near the decision boundary.
How It Works
Formula: margin = P(y₁|x) - P(y₂|x), where y₁ and y₂ are the most likely classes.
Selection: Select samples with smallest margins (transformed as 1 - margin for consistency with other strategies where higher = more informative).
Advantages:
Complexity: O(n × c) where n=pool size, c=number of classes.
Reference: Settles, B. (2012). “Active Learning.” Morgan & Claypool Publishers.
Constructors
| Constructor | Summary |
|---|---|
MarginSampling() |
Initializes a new instance of the MarginSampling class. |
Properties
| Property | Summary |
|---|---|
bool UseBatchDiversity { get; set; } |
|
string Name { get; } |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T> GetSelectionStatistics() |
|
Vector<T> ComputeInformativenessScores(IFullModel<T, Tensor<T>, Tensor<T>> model, Tensor<T> unlabeledPool) |
|
int[] SelectSamples(IFullModel<T, Tensor<T>, Tensor<T>> model, Tensor<T> unlabeledPool, int batchSize) |