mlpack
Classes | Functions
perceptron_main.cpp File Reference
#include <mlpack/prereqs.hpp>
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/data/normalize_labels.hpp>
#include <mlpack/core/util/mlpack_main.hpp>
#include "perceptron.hpp"
Include dependency graph for perceptron_main.cpp:
This graph shows which files directly or indirectly include this file:

Classes

class  PerceptronModel
 

Functions

 BINDING_NAME ("Perceptron")
 
 BINDING_SHORT_DESC ("An implementation of a perceptron---a single level neural network--=for " "classification. Given labeled data, a perceptron can be trained and saved" " for future use; or, a pre-trained perceptron can be used for " "classification on new points.")
 
 BINDING_LONG_DESC ("This program implements a perceptron, which is a single level neural " "network. The perceptron makes its predictions based on a linear predictor " "function combining a set of weights with the feature vector. The " "perceptron learning rule is able to converge, given enough iterations " "(specified using the "+PRINT_PARAM_STRING("max_iterations")+" parameter), if the data supplied is linearly separable. The perceptron " "is parameterized by a matrix of weight vectors that denote the numerical " "weights of the neural network." "\" "This program allows loading a perceptron from a model (via the "+PRINT_PARAM_STRING("input_model")+" parameter) or training a perceptron " "given training data (via the "+PRINT_PARAM_STRING("training")+" parameter), or both those things at once. In addition, this program " "allows classification on a test dataset (via the "+PRINT_PARAM_STRING("test")+" parameter) and the classification results " "on the test set may be saved with the "+PRINT_PARAM_STRING("predictions")+" output parameter. The perceptron model may be saved with the "+PRINT_PARAM_STRING("output_model")+" output parameter." "\" "Note: the following parameter is deprecated and " "will be removed in mlpack 4.0.0: "+PRINT_PARAM_STRING("output")+"." "\ "Use "+PRINT_PARAM_STRING("predictions")+" instead of "+PRINT_PARAM_STRING("output")+'.')
 
 BINDING_EXAMPLE ("The training data given with the "+PRINT_PARAM_STRING("training")+" option may have class labels as its last dimension (so, if the training " "data is in CSV format, labels should be the last column). Alternately, " "the "+PRINT_PARAM_STRING("labels")+" parameter may be used to specify " "a separate matrix of labels." "\" "All these options make it easy to train a perceptron, and then re-use that" " perceptron for later classification. The invocation below trains a " "perceptron on "+PRINT_DATASET("training_data")+" with labels "+PRINT_DATASET("training_labels")+", and saves the model to "+PRINT_MODEL("perceptron_model")+"." "\"+PRINT_CALL("perceptron", "training", "training_data", "labels", "training_labels", "output_model", "perceptron_model")+"\" "Then, this model can be re-used for classification on the test data "+PRINT_DATASET("test_data")+". The example below does precisely that, " "saving the predicted classes to "+PRINT_DATASET("predictions")+"." "\"+PRINT_CALL("perceptron", "input_model", "perceptron_model", "test", "test_data", "predictions", "predictions")+"\" "Note that all of the options may be specified at once: predictions may be " "calculated right after training a model, and model training can occur even" " if an existing perceptron model is passed with the "+PRINT_PARAM_STRING("input_model")+" parameter. However, note that the " "number of classes and the dimensionality of all data must match. So you " "cannot pass a perceptron model trained on 2 classes and then re-train with" " a 4-class dataset. Similarly, attempting classification on a " "3-dimensional dataset with a perceptron that has been trained on 8 " "dimensions will cause an error.")
 
 BINDING_SEE_ALSO ("@adaboost", "#adaboost")
 
 BINDING_SEE_ALSO ("Perceptron on Wikipedia", "https://en.wikipedia.org/wiki/Perceptron")
 
 BINDING_SEE_ALSO ("mlpack::perceptron::Perceptron C++ class documentation", "@doxygen/classmlpack_1_1perceptron_1_1Perceptron.html")
 
 PARAM_MATRIX_IN ("training", "A matrix containing the training set.", "t")
 
 PARAM_UROW_IN ("labels", "A matrix containing labels for the training set.", "l")
 
 PARAM_INT_IN ("max_iterations", "The maximum number of iterations the " "perceptron is to be run", "n", 1000)
 
 PARAM_MODEL_IN (PerceptronModel, "input_model", "Input perceptron model.", "m")
 
 PARAM_MODEL_OUT (PerceptronModel, "output_model", "Output for trained perceptron" " model.", "M")
 
 PARAM_MATRIX_IN ("test", "A matrix containing the test set.", "T")
 
 PARAM_UROW_OUT ("output", "The matrix in which the predicted labels for the" " test set will be written.", "o")
 
 PARAM_UROW_OUT ("predictions", "The matrix in which the predicted labels for the" " test set will be written.", "P")
 

Detailed Description

Author
Udit Saxena

This program runs the Simple Perceptron Classifier.

Perceptrons are simple single-layer binary classifiers, which solve linearly separable problems with a linear decision boundary.

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.