ShareBoost.h

Go to the documentation of this file.
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) 2012 Chiyuan Zhang
00008  * Copyright (C) 2012 Chiyuan Zhang
00009  */
00010 
00011 #ifndef SHAREBOOST_H__
00012 #define SHAREBOOST_H__
00013 
00014 #include <shogun/machine/LinearMulticlassMachine.h>
00015 #include <shogun/multiclass/MulticlassOneVsRestStrategy.h>
00016 #include <shogun/features/DenseFeatures.h>
00017 #include <shogun/labels/MulticlassLabels.h>
00018 
00019 namespace shogun
00020 {
00021 
00030 class CShareBoost: public CLinearMulticlassMachine
00031 {
00032 public:
00034     CShareBoost();
00035 
00037     CShareBoost(CDenseFeatures<float64_t> *features, CMulticlassLabels *labs, int32_t num_nonzero_feas);
00038 
00040     virtual ~CShareBoost() {}
00041 
00043     virtual const char* get_name() const { return "ShareBoost"; }
00044 
00046     void set_num_nonzero_feas(int32_t n) { m_nonzero_feas = n; }
00047 
00049     int32_t get_num_nonzero_feas() const { return m_nonzero_feas; }
00050 
00052     void set_features(CFeatures *f);
00053 
00055     SGVector<int32_t> get_activeset();
00056 
00057     friend class ShareBoostOptimizer;
00058 protected:
00059 
00061     virtual bool train_machine(CFeatures* data = NULL);
00062 
00063 private:
00064     void init_sb_params(); 
00065 
00066     void compute_rho(); 
00067     int32_t choose_feature(); 
00068     void optimize_coefficients(); 
00069     void compute_pred(); 
00070     void compute_pred(const float64_t *W); 
00071 
00072     int32_t m_nonzero_feas; 
00073     SGVector<int32_t> m_activeset; 
00074 
00075     SGMatrix<float64_t> m_fea; 
00076     SGMatrix<float64_t> m_rho; 
00077     SGVector<float64_t> m_rho_norm; 
00078     SGMatrix<float64_t> m_pred; 
00079 };
00080 
00081 } /* shogun */ 
00082 
00083 #endif /* end of include guard: SHAREBOOST_H__ */
00084 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation