Class LinearClassifierOptions<T>
Configuration options for linear classifiers.
public class LinearClassifierOptions<T> : ClassifierOptions<T>
Type Parameters
TThe data type used for calculations.
- Inheritance
-
LinearClassifierOptions<T>
- Derived
- Inherited Members
Remarks
Linear classifiers learn a linear decision boundary to separate classes. They are simple, interpretable, and often very effective.
For Beginners: Linear classifiers draw a straight line (or hyperplane in higher dimensions) to separate different classes of data.
Key concepts:
- They learn weights for each feature
- Prediction is: sign(weight * features + bias)
- Training adjusts weights to minimize errors
Linear classifiers are great when:
- You have many features (high-dimensional data)
- Data is approximately linearly separable
- You need fast training and prediction
- You want interpretable models (feature importance = weight magnitude)
Properties
Alpha
Gets or sets the regularization strength (alpha).
public double Alpha { get; set; }
Property Value
- double
A positive regularization parameter. Default is 0.0001.
Remarks
Higher values mean stronger regularization, which prevents overfitting but may increase bias. Set to 0 for no regularization.
FitIntercept
Gets or sets whether to fit an intercept term (bias).
public bool FitIntercept { get; set; }
Property Value
- bool
True (default) to include an intercept; false to pass through origin.
Remarks
For Beginners: The intercept (also called bias) allows the decision boundary to not pass through the origin.
Almost always set to true unless you specifically know your data should be classified through the origin.
LearningRate
Gets or sets the learning rate for gradient-based optimization.
public double LearningRate { get; set; }
Property Value
- double
A positive learning rate. Default is 0.01.
Remarks
Controls how much to adjust weights on each update. - Too high: Training may oscillate or diverge - Too low: Training will be slow to converge
Loss
Gets or sets the loss function type.
public LinearLoss Loss { get; set; }
Property Value
- LinearLoss
The loss function. Default is Hinge (for SVM-style classifier).
MaxIterations
Gets or sets the maximum number of training iterations.
public int MaxIterations { get; set; }
Property Value
- int
The maximum iterations. Default is 1000.
Penalty
Gets or sets the penalty type for regularization.
public LinearPenalty Penalty { get; set; }
Property Value
- LinearPenalty
The penalty type. Default is L2.
RandomState
Gets or sets the random state for reproducibility.
public int? RandomState { get; set; }
Property Value
- int?
The random seed, or null for non-deterministic. Default is null.
Shuffle
Gets or sets whether to shuffle training data at each epoch.
public bool Shuffle { get; set; }
Property Value
- bool
True (default) to shuffle; false to use data in original order.
Tolerance
Gets or sets the convergence tolerance.
public double Tolerance { get; set; }
Property Value
- double
The tolerance for convergence check. Default is 1e-4.
Remarks
Training stops early if the loss improvement is below this threshold.