UFJF - Machine Learning Toolkit  0.51.8
DualRegressor.hpp
1 //
2 // Created by mateus558 on 06/03/2020.
3 //
4 
5 #pragma once
6 
7 #include "Regressor.hpp"
8 
9 namespace mltk{
10  namespace regressor {
11  template < typename T >
12  class DualRegressor: public Regressor < T > {
13  // Attributes
14  protected :
16  std::vector<double> alpha;
18  Kernel<T> *kernel = nullptr;
19  public:
20 
21  double evaluate(const Point< T > &p, bool raw_value=false) override {
22  double func = 0.0;
23  size_t i, dim = this->solution.w.size();
24 
25  if(p.x.size() != dim){
26  std::cerr << "The point must have the same dimension of the feature set!" << std::endl;
27  return 0;
28  }
29 
30  for(func = this->solution.bias, i = 0; i < dim; i++){
31  func += this->solution.w[i] * p[i];
32  }
33 
34  return func;
35  }
36 
37  /*********************************************
38  * Getters *
39  *********************************************/
40 
41  std::string getFormulationString() override { return "Dual"; }
42 
43  /*********************************************
44  * Setters *
45  *********************************************/
46 
47  };
48  }
49 }
std::size_t size() const
Returns the dimension of the point.
Definition: Point.hpp:133
double bias
Bias of the solution.
Definition: Solution.hpp:23
mltk::Point< double > w
Weights vector.
Definition: Solution.hpp:17
Definition: DualRegressor.hpp:12
std::vector< double > alpha
Alphas vector.
Definition: DualRegressor.hpp:16
std::string getFormulationString() override
getFormulationString Returns a string that represents the formulation of the learner (Primal or Dual)...
Definition: DualRegressor.hpp:41
Kernel< T > * kernel
Object for kernel computations.
Definition: DualRegressor.hpp:18
double evaluate(const Point< T > &p, bool raw_value=false) override
Returns the class of a feature point based on the trained Learner.
Definition: DualRegressor.hpp:21
Definition: regressor/Regressor.hpp:16
Solution solution
Regressor solution.
Definition: regressor/Regressor.hpp:19
UFJF-MLTK main namespace for core functionalities.
Definition: classifier/Classifier.hpp:11