13 #ifndef MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_FUNCTION_HPP 14 #define MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_FUNCTION_HPP 19 namespace regression {
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;
122 double Evaluate(
const arma::mat& parameters,
124 const size_t batchSize = 1)
const;
135 void Gradient(
const arma::mat& parameters, arma::mat& gradient)
const;
148 void Gradient(
const arma::mat& parameters,
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;
double Lambda() const
Gets the regularization parameter.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Gradient(const arma::mat ¶meters, arma::mat &gradient) const
Evaluates the gradient values of the objective function given the current set of parameters.
double & Lambda()
Sets the regularization parameter.
void Shuffle()
Shuffle the dataset.
size_t NumClasses() const
Gets the number of classes.
size_t NumFeatures() const
Gets the features size of the training data.
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.
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.
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.
size_t NumFunctions() const
Return the number of separable functions (the number of predictor points).
void GetGroundTruthMatrix(const arma::Row< size_t > &labels, arma::sp_mat &groundTruth)
Constructs the ground truth label matrix with the passed labels.
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...
bool FitIntercept() const
Gets the intercept flag.
double Evaluate(const arma::mat ¶meters) const
Evaluates the objective function of the softmax regression model using the given parameters.