Table of Contents

Class PerceptronClassifier<T>

Namespace
AiDotNet.Classification.Linear
Assembly
AiDotNet.dll

Classic Perceptron classifier - the original neural network building block.

public class PerceptronClassifier<T> : LinearClassifierBase<T>, IProbabilisticClassifier<T>, IClassifier<T>, IFullModel<T, Matrix<T>, Vector<T>>, IModel<Matrix<T>, Vector<T>, ModelMetadata<T>>, IModelSerializer, ICheckpointableModel, IParameterizable<T, Matrix<T>, Vector<T>>, IFeatureAware, IFeatureImportance<T>, ICloneable<IFullModel<T, Matrix<T>, Vector<T>>>, IGradientComputable<T, Matrix<T>, Vector<T>>, IJitCompilable<T>

Type Parameters

T

The numeric data type used for calculations (e.g., float, double).

Inheritance
PerceptronClassifier<T>
Implements
IFullModel<T, Matrix<T>, Vector<T>>
IModel<Matrix<T>, Vector<T>, ModelMetadata<T>>
IParameterizable<T, Matrix<T>, Vector<T>>
ICloneable<IFullModel<T, Matrix<T>, Vector<T>>>
IGradientComputable<T, Matrix<T>, Vector<T>>
Inherited Members
Extension Methods

Remarks

The Perceptron is a linear classifier that updates weights only on mistakes. It's historically significant as the foundation of neural networks.

For Beginners: The Perceptron is the simplest possible neural network:

How it works:

  1. Start with zero weights
  2. For each training sample:
    • If correct: do nothing
    • If wrong: adjust weights in the direction of the correct class
  3. Repeat until no mistakes (or max iterations)

Properties:

  • Only works for linearly separable data
  • Guaranteed to converge if data IS linearly separable
  • Never converges if data is NOT linearly separable
  • No notion of margin (unlike SVM)

Historical note: The Perceptron was invented in 1958 by Frank Rosenblatt and was one of the first machine learning algorithms ever created!

Constructors

PerceptronClassifier(LinearClassifierOptions<T>?, IRegularization<T, Matrix<T>, Vector<T>>?)

Initializes a new instance of the PerceptronClassifier class.

public PerceptronClassifier(LinearClassifierOptions<T>? options = null, IRegularization<T, Matrix<T>, Vector<T>>? regularization = null)

Parameters

options LinearClassifierOptions<T>

Configuration options for the classifier.

regularization IRegularization<T, Matrix<T>, Vector<T>>

Optional regularization strategy.

Methods

Clone()

Creates a clone of the classifier model.

public override IFullModel<T, Matrix<T>, Vector<T>> Clone()

Returns

IFullModel<T, Matrix<T>, Vector<T>>

A new instance of the model with the same parameters and options.

CreateNewInstance()

Creates a new instance of the same type as this classifier.

protected override IFullModel<T, Matrix<T>, Vector<T>> CreateNewInstance()

Returns

IFullModel<T, Matrix<T>, Vector<T>>

A new instance of the same classifier type.

GetModelType()

Returns the model type identifier for this classifier.

protected override ModelType GetModelType()

Returns

ModelType

Train(Matrix<T>, Vector<T>)

Trains the Perceptron classifier on the provided data.

public override void Train(Matrix<T> x, Vector<T> y)

Parameters

x Matrix<T>
y Vector<T>