SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2009 Soeren Sonnenburg 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _LINEARCLASSIFIER_H__ 00012 #define _LINEARCLASSIFIER_H__ 00013 00014 #include <shogun/lib/common.h> 00015 #include <shogun/labels/Labels.h> 00016 #include <shogun/features/DotFeatures.h> 00017 #include <shogun/machine/Machine.h> 00018 00019 #include <stdio.h> 00020 00021 namespace shogun 00022 { 00023 class CDotFeatures; 00024 class CMachine; 00025 class CLabels; 00026 00061 class CLinearMachine : public CMachine 00062 { 00063 public: 00065 CLinearMachine(); 00066 00068 virtual ~CLinearMachine(); 00069 00071 CLinearMachine(CLinearMachine* machine); 00072 00077 virtual SGVector<float64_t> get_w() const; 00078 00083 virtual void set_w(const SGVector<float64_t> src_w); 00084 00089 virtual void set_bias(float64_t b); 00090 00095 virtual float64_t get_bias(); 00096 00101 virtual void set_features(CDotFeatures* feat); 00102 00109 virtual CBinaryLabels* apply_binary(CFeatures* data=NULL); 00110 00117 virtual CRegressionLabels* apply_regression(CFeatures* data=NULL); 00118 00120 virtual float64_t apply_one(int32_t vec_idx); 00121 00126 virtual CDotFeatures* get_features(); 00127 00133 virtual const char* get_name() const { return "LinearMachine"; } 00134 00135 protected: 00136 00142 virtual SGVector<float64_t> apply_get_outputs(CFeatures* data); 00143 00148 virtual void store_model_features(); 00149 00150 private: 00151 00152 void init(); 00153 00154 protected: 00156 SGVector<float64_t> w; 00158 float64_t bias; 00160 CDotFeatures* features; 00161 }; 00162 } 00163 #endif