SHOGUN  6.1.3
OnlineLinearMachine.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) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _ONLINELINEARCLASSIFIER_H__
12 #define _ONLINELINEARCLASSIFIER_H__
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
18 #include <shogun/machine/Machine.h>
19 
20 
21 namespace shogun
22 {
23 class CBinaryLabels;
24 class CFeatures;
25 class CRegressionLabels;
26 
54 {
55  public:
58  virtual ~COnlineLinearMachine();
59 
66  virtual void get_w(float64_t*& dst_w, int32_t& dst_dims)
67  {
68  ASSERT(m_w.vector && m_w.vlen > 0)
69  dst_w=SG_MALLOC(float64_t, m_w.vlen);
70  for (int32_t i=0; i<m_w.vlen; i++)
71  dst_w[i]=m_w[i];
72  dst_dims=m_w.vlen;
73  }
74 
79  virtual SGVector<float32_t> get_w() const
80  {
81  return m_w;
82  }
83 
89  virtual void set_w(const SGVector<float32_t> w)
90  {
91  m_w = w;
92  }
93 
100  virtual void set_w(float64_t* src_w, int32_t src_w_dim)
101  {
102  m_w = SGVector<float32_t>(src_w_dim);
103  for (int32_t i=0; i<src_w_dim; i++)
104  m_w[i] = src_w[i];
105  }
106 
111  virtual void set_bias(float32_t b)
112  {
113  bias=b;
114  }
115 
120  virtual float32_t get_bias()
121  {
122  return bias;
123  }
124 
130  {
131  SG_REF(feat);
133  features=feat;
134  }
135 
142  virtual CRegressionLabels* apply_regression(CFeatures* data=NULL);
143 
150  virtual CBinaryLabels* apply_binary(CFeatures* data=NULL);
151 
153  virtual float64_t apply_one(int32_t vec_idx)
154  {
156  return CMath::INFTY;
157  }
158 
167  virtual float32_t apply_one(float32_t* vec, int32_t len);
168 
175 
181 
187  virtual const char* get_name() const { return "OnlineLinearMachine"; }
188 
192  virtual void start_train() { }
193 
197  virtual void stop_train() { }
198 
209 
210  protected:
219  virtual bool train_machine(CFeatures* data=NULL);
220 
227 
229  virtual bool train_require_labels() const { return false; }
230 
231  protected:
238 };
239 }
240 #endif
virtual CRegressionLabels * apply_regression(CFeatures *data=NULL)
Class OnlineLinearMachine is a generic interface for linear machines like classifiers which work thro...
Real Labels are real-valued labels.
static const float64_t INFTY
infinity
Definition: Math.h:1868
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:138
virtual void set_w(float64_t *src_w, int32_t src_w_dim)
#define SG_REF(x)
Definition: SGObject.h:52
A generic learning machine interface.
Definition: Machine.h:151
virtual void set_features(CStreamingDotFeatures *feat)
#define ASSERT(x)
Definition: SGIO.h:176
virtual bool train_machine(CFeatures *data=NULL)
virtual float32_t apply_to_current_example()
double float64_t
Definition: common.h:60
virtual float64_t apply_one(int32_t vec_idx)
get output for example "vec_idx"
virtual void set_w(const SGVector< float32_t > w)
Streaming features that support dot products among other operations.
float float32_t
Definition: common.h:59
#define SG_UNREF(x)
Definition: SGObject.h:53
virtual CStreamingDotFeatures * get_features()
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual void get_w(float64_t *&dst_w, int32_t &dst_dims)
CStreamingDotFeatures * features
The class Features is the base class of all feature objects.
Definition: Features.h:69
virtual const char * get_name() const
Binary Labels for binary classification.
Definition: BinaryLabels.h:37
virtual CBinaryLabels * apply_binary(CFeatures *data=NULL)
virtual bool train_require_labels() const
virtual SGVector< float32_t > get_w() const
virtual void train_example(CStreamingDotFeatures *feature, float64_t label)
SGVector< float64_t > apply_get_outputs(CFeatures *data)
virtual void set_bias(float32_t b)
index_t vlen
Definition: SGVector.h:571

SHOGUN Machine Learning Toolbox - Documentation