12 #ifndef MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_HPP 13 #define MLPACK_METHODS_SOFTMAX_REGRESSION_SOFTMAX_REGRESSION_HPP 21 namespace regression {
75 const size_t numClasses = 0,
76 const bool fitIntercept =
false);
93 template<
typename OptimizerType = mlpack::optimization::L_BFGS>
95 const arma::Row<size_t>& labels,
96 const size_t numClasses,
97 const double lambda = 0.0001,
98 const bool fitIntercept =
false,
99 OptimizerType optimizer = OptimizerType());
110 void Classify(
const arma::mat& dataset, arma::Row<size_t>& labels)
const;
120 template<
typename VecType>
121 size_t Classify(
const VecType& point)
const;
134 void Classify(
const arma::mat& dataset,
135 arma::Row<size_t>& labels,
136 arma::mat& probabilites)
const;
144 void Classify(
const arma::mat& dataset,
145 arma::mat& probabilities)
const;
156 const arma::Row<size_t>& labels)
const;
168 template<
typename OptimizerType = mlpack::optimization::L_BFGS>
169 double Train(
const arma::mat& data,
170 const arma::Row<size_t>& labels,
171 const size_t numClasses,
172 OptimizerType optimizer = OptimizerType());
194 {
return fitIntercept ? parameters.n_cols - 1 :
200 template<
typename Archive>
203 ar & BOOST_SERIALIZATION_NVP(parameters);
204 ar & BOOST_SERIALIZATION_NVP(numClasses);
205 ar & BOOST_SERIALIZATION_NVP(lambda);
206 ar & BOOST_SERIALIZATION_NVP(fitIntercept);
211 arma::mat parameters;
224 #include "softmax_regression_impl.hpp" SoftmaxRegression(const size_t inputSize=0, const size_t numClasses=0, const bool fitIntercept=false)
Initialize the SoftmaxRegression without performing training.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Lambda() const
Gets the regularization parameter.
bool FitIntercept() const
Gets the intercept term flag. We can't change this after training.
size_t NumClasses() const
Gets the number of classes.
double Train(const arma::mat &data, const arma::Row< size_t > &labels, const size_t numClasses, OptimizerType optimizer=OptimizerType())
Train the softmax regression with the given training data.
Softmax Regression is a classifier which can be used for classification when the data available can t...
arma::mat & Parameters()
Get the model parameters.
void serialize(Archive &ar, const unsigned int)
Serialize the SoftmaxRegression model.
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...
double & Lambda()
Sets the regularization parameter.
size_t FeatureSize() const
Gets the features size of the training data.
size_t & NumClasses()
Sets the number of classes.
void Classify(const arma::mat &dataset, arma::Row< size_t > &labels) const
Classify the given points, returning the predicted labels for each point.
const arma::mat & Parameters() const
Get the model parameters.