mlpack  3.0.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sparse_svm_function.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_SPARSE_SVM_SPARSE_SVM_FUNCTION_HPP
14 #define MLPACK_METHODS_SPARSE_SVM_SPARSE_SVM_FUNCTION_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
19 {
20  public:
23 
25  SparseSVMFunction(const arma::sp_mat& dataset, const arma::vec& labels);
26 
30  void Shuffle();
31 
41  double Evaluate(const arma::mat& parameters,
42  const size_t startId,
43  const size_t batchSize = 1);
44 
53  template <typename GradType>
54  void Gradient(const arma::mat& parameters, size_t id, GradType& gradient);
55 
57  const arma::mat& InitialPoint() const { return initialPoint; }
59  arma::mat& InitialPoint() { return initialPoint; }
60 
62  const arma::sp_mat& Dataset() const { return dataset; }
64  arma::sp_mat& Dataset() { return dataset; }
65 
67  const arma::vec& Labels() const { return labels; }
69  arma::vec& Labels() { return labels; }
70 
72  size_t NumFunctions();
73 
74  private:
76  arma::mat initialPoint;
77 
79  arma::sp_mat dataset;
80 
82  arma::vec labels;
83 };
84 
85 // Include implementation
86 #include "sparse_svm_function_impl.hpp"
87 
88 #endif // MLPACK_METHODS_SPARSE_SVM_SPARSE_SVM_FUNCTION_HPP
void Shuffle()
Shuffle the dataset.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const arma::sp_mat & Dataset() const
Get the dataset.
arma::vec & Labels()
Modify the labels.
double Evaluate(const arma::mat &parameters, const size_t startId, const size_t batchSize=1)
Evaluate the hinge loss function on the specified datapoints.
size_t NumFunctions()
Return the number of functions.
void Gradient(const arma::mat &parameters, size_t id, GradType &gradient)
Evaluate the gradient the gradient of the hinge loss function, following the SparseFunctionType requi...
arma::mat & InitialPoint()
Modify the initial point for the optimization.
arma::sp_mat & Dataset()
Modify the dataset.
const arma::vec & Labels() const
Get the labels.
const arma::mat & InitialPoint() const
Return the initial point for the optimization.
SparseSVMFunction()
Nothing to do for the default constructor.