SHOGUN
v1.1.0
|
00001 /* 00002 * Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights 00003 * embodied in the content of this file are licensed under the BSD 00004 * (revised) open source license. 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * Written (W) 2011 Shashwat Lal Das 00012 * Adaptation of Vowpal Wabbit v5.1. 00013 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society. 00014 */ 00015 00016 #ifndef _VW_LEARNER_H__ 00017 #define _VW_LEARNER_H__ 00018 00019 #include <shogun/base/SGObject.h> 00020 #include <shogun/base/Parameter.h> 00021 #include <shogun/classifier/vw/vw_common.h> 00022 #include <shogun/classifier/vw/VwRegressor.h> 00023 00024 namespace shogun 00025 { 00033 class CVwLearner: public CSGObject 00034 { 00035 public: 00039 CVwLearner() 00040 : CSGObject(), reg(NULL), env(NULL) 00041 { 00042 register_learner_params(); 00043 } 00044 00051 CVwLearner(CVwRegressor* regressor, CVwEnvironment* vw_env) 00052 : CSGObject(), reg(regressor), env(vw_env) 00053 { 00054 SG_REF(reg); 00055 SG_REF(env); 00056 register_learner_params(); 00057 } 00058 00062 virtual ~CVwLearner() 00063 { 00064 if (reg) 00065 SG_UNREF(reg); 00066 if (env) 00067 SG_UNREF(env); 00068 } 00069 00073 void register_learner_params() 00074 { 00075 SG_ADD((CSGObject**) ®, "vw_regressor", "Regressor object", 00076 MS_NOT_AVAILABLE); 00077 SG_ADD((CSGObject**) &env, "vw_env", "Environment", 00078 MS_NOT_AVAILABLE); 00079 } 00080 00087 virtual void train(VwExample* &ex, float32_t update) = 0; 00088 00094 virtual const char* get_name() const { return "VwLearner"; } 00095 00096 protected: 00098 CVwRegressor *reg; 00100 CVwEnvironment *env; 00101 }; 00102 } 00103 #endif // _VW_LEARNER_H__