13#ifndef MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_FUNCTION_HPP
14#define MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_FUNCTION_HPP
35 const arma::Row<size_t>& labels,
36 const size_t numClasses,
37 const double lambda = 0.0001,
38 const bool fitIntercept =
false);
58 const size_t numClasses,
59 const bool fitIntercept =
false);
71 const size_t featureSize,
72 const size_t numClasses,
73 const bool fitIntercept =
false);
82 arma::sp_mat& groundTruth);
96 arma::mat& probabilities,
98 const size_t batchSize)
const;
109 double Evaluate(
const arma::mat& parameters)
const;
124 const size_t batchSize = 1)
const;
135 void Gradient(
const arma::mat& parameters, arma::mat& gradient)
const;
151 const size_t batchSize = 1)
const;
164 arma::sp_mat& gradient)
const;
175 return initialPoint.n_cols;
194 arma::sp_mat groundTruth;
196 arma::mat initialPoint;
void PartialGradient(const arma::mat ¶meters, size_t j, arma::sp_mat &gradient) const
Evaluates the gradient values of the objective function given the current set of parameters for a sin...
size_t NumClasses() const
Gets the number of classes.
double Evaluate(const arma::mat ¶meters, const size_t start, const size_t batchSize=1) const
Evaluate the objective function of the softmax regression model for a subset of the data points using...
size_t NumFunctions() const
Return the number of separable functions (the number of predictor points).
void Shuffle()
Shuffle the dataset.
bool FitIntercept() const
Gets the intercept flag.
size_t NumFeatures() const
Gets the features size of the training data.
double & Lambda()
Sets the regularization parameter.
static const arma::mat InitializeWeights(const size_t featureSize, const size_t numClasses, const bool fitIntercept=false)
Initialize Softmax Regression weights (trainable parameters) with the given parameters.
double Lambda() const
Gets the regularization parameter.
double Evaluate(const arma::mat ¶meters) const
Evaluates the objective function of the softmax regression model using the given parameters.
const arma::mat InitializeWeights()
Initializes the parameters of the model to suitable values.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
void GetProbabilitiesMatrix(const arma::mat ¶meters, arma::mat &probabilities, const size_t start, const size_t batchSize) const
Evaluate the probabilities matrix with the passed parameters.
void Gradient(const arma::mat ¶meters, arma::mat &gradient) const
Evaluates the gradient values of the objective function given the current set of parameters.
SoftmaxRegressionFunction(const arma::mat &data, const arma::Row< size_t > &labels, const size_t numClasses, const double lambda=0.0001, const bool fitIntercept=false)
Construct the Softmax Regression objective function with the given parameters.
static void InitializeWeights(arma::mat &weights, const size_t featureSize, const size_t numClasses, const bool fitIntercept=false)
Initialize Softmax Regression weights (trainable parameters) with the given parameters.
void Gradient(const arma::mat ¶meters, const size_t start, arma::mat &gradient, const size_t batchSize=1) const
Evaluate the gradient of the objective function given the current set of parameters,...
void GetGroundTruthMatrix(const arma::Row< size_t > &labels, arma::sp_mat &groundTruth)
Constructs the ground truth label matrix with the passed labels.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.