13 #ifndef MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_FUNCTION_HPP
14 #define MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_FUNCTION_HPP
19 namespace regression {
36 const arma::Row<size_t>& labels,
37 const size_t numClasses,
38 const double lambda = 0.0001,
39 const bool fitIntercept =
false);
54 const size_t numClasses,
55 const bool fitIntercept =
false);
67 const size_t featureSize,
68 const size_t numClasses,
69 const bool fitIntercept =
false);
78 arma::sp_mat& groundTruth);
90 arma::mat& probabilities)
const;
101 double Evaluate(
const arma::mat& parameters)
const;
112 void Gradient(
const arma::mat& parameters, arma::mat& gradient)
const;
123 return fitIntercept ? initialPoint.n_cols - 1 :
137 const arma::mat& data;
139 arma::sp_mat groundTruth;
141 arma::mat initialPoint;
void Gradient(const arma::mat ¶meters, arma::mat &gradient) const
Evaluates the gradient values of the objective function given the current set of parameters.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t FeatureSize() const
Gets the features size of the training data.
double & Lambda()
Sets the regularization parameter.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
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.
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.
void GetProbabilitiesMatrix(const arma::mat ¶meters, arma::mat &probabilities) const
Evaluate the probabilities matrix with the passed parameters.
double Lambda() const
Gets the regularization parameter.
void GetGroundTruthMatrix(const arma::Row< size_t > &labels, arma::sp_mat &groundTruth)
Constructs the ground truth label matrix with the passed labels.
size_t NumClasses() const
Gets the number of classes.
bool FitIntercept() const
Gets the intercept flag.