12 #ifndef MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_HPP 13 #define MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_HPP 21 namespace regression {
95 const arma::Row<size_t>& labels,
97 const double lambda = 0.0001,
119 void Predict(
const arma::mat& testData, arma::Row<size_t>& predictions)
const;
130 const arma::Row<size_t>& labels)
const;
140 double Train(OptimizerType<SoftmaxRegressionFunction>& optimizer);
149 double Train(
const arma::mat &data,
const arma::Row<size_t>& labels,
150 const size_t numClasses);
178 template<
typename Archive>
184 ar &
CreateNVP(numClasses,
"numClasses");
204 #include "softmax_regression_impl.hpp" double & Lambda()
Sets the regularization parameter.
SoftmaxRegression(const size_t inputSize=0, const size_t numClasses=0, const bool fitIntercept=false)
Initialize the SoftmaxRegression without performing training.
Linear algebra utility functions, generally performed on matrices or vectors.
arma::mat & Parameters()
Get the model parameters.
The core includes that mlpack expects; standard C++ includes and Armadillo.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename std::enable_if_t< HasSerialize< T >::value > *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
size_t numClasses
Number of classes.
const arma::mat & Parameters() const
Get the model parameters.
double Train(OptimizerType< SoftmaxRegressionFunction > &optimizer)
Train the softmax regression model with the given optimizer.
Softmax Regression is a classifier which can be used for classification when the data available can t...
size_t & NumClasses()
Sets the number of classes.
bool fitIntercept
Intercept term flag.
size_t NumClasses() const
Gets the number of classes.
double Lambda() const
Gets the regularization parameter.
bool FitIntercept() const
Gets the intercept term flag. We can't change this after training.
void Serialize(Archive &ar, const unsigned int)
Serialize the SoftmaxRegression model.
double lambda
L2-regularization constant.
size_t FeatureSize() const
Gets the features size of the training data.
void Predict(const arma::mat &testData, arma::Row< size_t > &predictions) const
Predict the class labels for the provided feature points.
arma::mat parameters
Parameters after optimization.
The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function...
double ComputeAccuracy(const arma::mat &testData, const arma::Row< size_t > &labels) const
Computes accuracy of the learned model given the feature data and the labels associated with each dat...