SHOGUN  3.2.1
 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  * Modifications (W) 2013 Thoralf Klein
10  * Copyright (c) 2007-2009 The LIBLINEAR Project.
11  * Copyright (C) 2007-2010 Fraunhofer Institute FIRST and Max-Planck-Society
12  */
13 
14 #ifndef _ONLINELIBLINEAR_H__
15 #define _ONLINELIBLINEAR_H__
16 
17 #include <shogun/lib/config.h>
18 
19 #include <shogun/lib/SGVector.h>
20 #include <shogun/lib/common.h>
21 #include <shogun/base/Parameter.h>
23 
24 namespace shogun
25 {
29 {
30 public:
31 
34 
37 
44 
52 
58 
60  virtual ~COnlineLibLinear();
61 
68  virtual void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
69 
75  virtual float64_t get_C1() { return C1; }
76 
82  float64_t get_C2() { return C2; }
83 
89  virtual void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
90 
96  virtual bool get_bias_enabled() { return use_bias; }
97 
99  virtual const char* get_name() const { return "OnlineLibLinear"; }
100 
102  virtual void start_train();
103 
105  virtual void stop_train();
106 
116  virtual void train_example(CStreamingDotFeatures *feature, float64_t label);
117 
122  virtual void train_one(SGVector<float32_t> ex, float64_t label);
123 
128  virtual void train_one(SGSparseVector<float32_t> ex, float64_t label);
129 
130 private:
132  void init();
133 
134 private:
136  bool use_bias;
138  float64_t C1;
140  float64_t C2;
141 
142 private:
143  //========================================
144  // "local" variables used during training
145 
146  float64_t C, d, G;
147  float64_t QD;
148 
149  // alpha for example being processed
150  float64_t alpha_current;
151 
152  // Cost constants
153  float64_t Cp;
154  float64_t Cn;
155 
156  // PG: projected gradient, for shrinking and stopping
157  float64_t PG;
158  float64_t PGmax_old;
159  float64_t PGmin_old;
160  float64_t PGmax_new;
161  float64_t PGmin_new;
162 
163  // Diag is probably unnecessary
164  float64_t diag[3];
165  float64_t upper_bound[3];
166 
167  // Objective value = v/2
168  float64_t v;
169  // Number of support vectors
170  int32_t nSV;
171 };
172 }
173 #endif // _ONLINELIBLINEAR_H__

SHOGUN Machine Learning Toolbox - Documentation