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()
Sets the regularization parameter.
Definition: softmax_regression_function.hpp:183
double Evaluate(const arma::mat ¶meters) const
Evaluates the objective function of the softmax regression model using the given parameters.
Definition: softmax_regression_function.cpp:184
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
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...
Definition: softmax_regression_function.cpp:304
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t NumFeatures() const
Gets the features size of the training data.
Definition: softmax_regression_function.hpp:173
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.
Definition: softmax_regression_function.cpp:18
void GetGroundTruthMatrix(const arma::Row< size_t > &labels, arma::sp_mat &groundTruth)
Constructs the ground truth label matrix with the passed labels.
Definition: softmax_regression_function.cpp:114
size_t NumFunctions() const
Return the number of separable functions (the number of predictor points).
Definition: softmax_regression_function.hpp:180
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.
Definition: softmax_regression_function.cpp:150
void Gradient(const arma::mat ¶meters, arma::mat &gradient) const
Evaluates the gradient values of the objective function given the current set of parameters.
Definition: softmax_regression_function.cpp:242
double Lambda() const
Gets the regularization parameter.
Definition: softmax_regression_function.hpp:185
void Shuffle()
Shuffle the dataset.
Definition: softmax_regression_function.cpp:39
const arma::mat InitializeWeights()
Initializes the parameters of the model to suitable values.
Definition: softmax_regression_function.cpp:78
Definition: softmax_regression_function.hpp:21
bool FitIntercept() const
Gets the intercept flag.
Definition: softmax_regression_function.hpp:188
size_t NumClasses() const
Gets the number of classes.
Definition: softmax_regression_function.hpp:170
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
Definition: softmax_regression_function.hpp:167