SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OnlineLibLinear.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2007-2010 Soeren Sonnenburg
8  * Written (W) 2011 Shashwat Lal Das
9  * Copyright (c) 2007-2009 The LIBLINEAR Project.
10  * Copyright (C) 2007-2010 Fraunhofer Institute FIRST and Max-Planck-Society
11  */
12 
13 #ifndef _ONLINELIBLINEAR_H__
14 #define _ONLINELIBLINEAR_H__
15 
16 #include <shogun/lib/config.h>
17 
18 #include <shogun/lib/SGVector.h>
19 #include <shogun/lib/common.h>
20 #include <shogun/base/Parameter.h>
22 
23 namespace shogun
24 {
28 {
29 public:
30 
33 
36 
43 
51 
57 
59  virtual ~COnlineLibLinear();
60 
67  virtual void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
68 
74  virtual float64_t get_C1() { return C1; }
75 
81  float64_t get_C2() { return C2; }
82 
88  virtual void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
89 
95  virtual bool get_bias_enabled() { return use_bias; }
96 
98  inline virtual const char* get_name() const { return "OnlineLibLinear"; }
99 
101  virtual void start_train();
102 
104  virtual void stop_train();
105 
115  virtual void train_example(CStreamingDotFeatures *feature, float64_t label);
116 
121  virtual void train_one(SGVector<float32_t> ex, float64_t label);
122 
123 private:
125  void init();
126 
127 private:
129  bool use_bias;
131  float64_t C1;
133  float64_t C2;
134 
135 private:
136  //========================================
137  // "local" variables used during training
138 
139  float64_t C, d, G;
140  float64_t QD;
141 
142  // y and alpha for example being processed
143  int32_t y_current;
144  float64_t alpha_current;
145 
146  // Cost constants
147  float64_t Cp;
148  float64_t Cn;
149 
150  // PG: projected gradient, for shrinking and stopping
151  float64_t PG;
152  float64_t PGmax_old;
153  float64_t PGmin_old;
154  float64_t PGmax_new;
155  float64_t PGmin_new;
156 
157  // Diag is probably unnecessary
158  float64_t diag[3];
159  float64_t upper_bound[3];
160 
161  // Objective value = v/2
162  float64_t v;
163  // Number of support vectors
164  int32_t nSV;
165 };
166 }
167 #endif // _ONLINELIBLINEAR_H__

SHOGUN Machine Learning Toolbox - Documentation