Perceptron
An implementation of a perceptron -a single level neural network- for classification.
Available Predicates
initModelNoTrain/3
Initilizes the perceptron model and its weight matrix but doesn't train it.
%% part of the predicate definition
initModelNoTrain(+integer, +integer, +integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
numClasses | +integer | 0 | |
dimensionality | +integer | Number of classes in the data. | 0 |
maxIterations | +integer | The maximum number of iterations the perceptron is to be run. | 1000 |
initModelWithTrain/7
Initilizes the perceptron model and its weight matrix and trains it with the given data.
%% part of the predicate definition
initModelWithTrain( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer, +integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | A matrix containing the training set. | - |
labels | +vector | A vector containing labels for the training set. | - |
numClasses | +integer | Number of classes in the data. | 0 |
maxIterations | +integer | The maximum number of iterations the perceptron is to be run. | 1000 |
biases/2
Get the biases.
%% part of the predicate definition
biases(-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
biases | -vector | Get the biases. | - |
classify/5
After training, use the weights matrix to classify test, and put the predicted classes in predictedLabels.
%% part of the predicate definition
classify( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
test | +matrix | - | |
predicLabels | -vector | The predicted labels for the test data. | - |
train/8
Train the perceptron on the given data for up to the maximum number of iterations. This training does not reset the model weights, so you can call train/8 on multiple datasets sequentially.
%% part of the predicate definition
train( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
+pointer(float_array), +integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | A matrix containing the training set. | - |
labels | +vector | A vector containing labels for the training set. | - |
numClasses | +integer | Number of classes in the data. | 0 |
instanceWeights | +vector | Cost matrix. Stores the cost of mispredicting instances. This is useful for boosting. | - |
weights/3
Get the weight matrix.
%% part of the predicate definition
weights(-pointer(float_array), -integer, -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
weights | -matrix | Get the weight matrix. | - |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation
- adaboost
- Perceptron on Wikipedia