Perceptron is a simple classification algorithm.
Attention: Available only with Activate commercial edition.
Syntax
parameters = perceptronfit(X,y)
parameters = perceptronfit(X,y,options)
Inputs
- X
- Training data.
- Type: double
- Dimension: vector | matrix
- y
- Target values.
- Type: double
- Dimension: vector | matrix
- options
- Type: struct
-
- penalty
- The penalty (regularization term) to be used. By default, it's not assigned. Allowed values are 'l2', 'l1', or 'elasticnet'.
- Type: char
- Dimension: string
- alpha
- Constant that multiplies the regularization term if regularization is used.
- Type: logical
- Dimension: Boolean
- max_iter
- Maximum number of passes over the training data (default: 1000).
- Type: integer
- Dimension: scalar
- tol
- Tolerance for stopping criteria. The iterations will stop when loss > previous_loss - tol (default: 1e-3).
- Type: double
- Dimension: scalar
- shuffle
- Whether or not the training data should be shuffled after each iteration over data. Default: true
- Type: Boolean
- Dimension: logical
- eta0
- Constant by which the updates are multiplied (default: 1).
- Type: double
- Dimension: scalar
- random_state
- The seed of pseudo random number generator to use when shuffling the data.
- Type: integer
- Dimension: scalar
- early_stopping
- Whether to use early stopping to terminate training when validation score is not improving (default: false). If set to true, it will automatically set aside a fraction of training data for validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs (iteration over all data).
- Type: Boolean
- Dimension: logical
- validation_fraction
- The proportion of training data to set aside as validation set for early stopping. It must be between 0 and 1. This value is considered only when early_stopping is set to true.
- Type: double
- Dimension: scalar
- n_iter_no_change
- Number of iterations with no improvement to wait before early stopping (default: 5).
- Type: integer
- Dimension: scalar
Outputs
- parameters
- Contains all the values passed to perceptronfit method as options. Additionally it has below key-value pairs.
- Type: struct
-
- scorer
- Function handle pointing to 'accuracy' function.
- Type: function handle
- intercept
- Intercept (bias) added to the decision function.
- Type: double
- Dimension: scalar
- coef
- Coefficient of the features in the decision function.
- Type: double
- Dimension: vector | matrix
- n_samples
- Number of rows in the training data.
- Type: integer
- Dimension: scalar
- n_features
- Number of columns in the training data.
- Type: integer
- Dimension: scalar
Example
Usage of perceptronfit
data = dlmread('banknote_authentication.txt', ',');
X = data(:, 1:2);
y = data(:, end);
parameters = perceptronfit(X, y);
> parameters
parameters = struct [
alpha: 0.0001
coef: [Matrix] 1 x 2
-12.75121 -6.88289
early_stopping: 0
eta0: 1
intercept: 4
max_iter: 1000
n_features: 2
n_iter_no_change: 5
n_samples: 1372
shuffle: 1
tol: 0.001
validation_fraction: 0.1
]
Comments
Output 'parameters' should be passed as input to perceptronpredict function.