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) 2013 Thoralf Klein 00008 * Written (W) 2012 Fernando José Iglesias García 00009 * Copyright (C) 2012 Fernando José Iglesias García 00010 */ 00011 00012 #ifndef _MULTICLASS_MODEL__H__ 00013 #define _MULTICLASS_MODEL__H__ 00014 00015 #include <shogun/structure/StructuredModel.h> 00016 00017 namespace shogun 00018 { 00019 00025 class CMulticlassModel : public CStructuredModel 00026 { 00027 00028 public: 00030 CMulticlassModel(); 00031 00037 CMulticlassModel(CFeatures* features, CStructuredLabels* labels); 00038 00040 virtual ~CMulticlassModel(); 00041 00043 virtual CStructuredLabels* structured_labels_factory(int32_t num_labels=0); 00044 00049 virtual int32_t get_dim() const; 00050 00063 virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y); 00064 00078 virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true); 00079 00087 virtual float64_t delta_loss(CStructuredData* y1, CStructuredData* y2); 00088 00101 virtual void init_primal_opt( 00102 float64_t regularization, 00103 SGMatrix< float64_t > & A, SGVector< float64_t > a, 00104 SGMatrix< float64_t > B, SGVector< float64_t > & b, 00105 SGVector< float64_t > lb, SGVector< float64_t > ub, 00106 SGMatrix < float64_t > & C); 00107 00109 virtual const char* get_name() const { return "MulticlassModel"; } 00110 00111 private: 00112 void init(); 00113 00115 float64_t delta_loss(float64_t y1, float64_t y2); 00116 float64_t delta_loss(int32_t y1_idx, float64_t y2); 00117 00118 private: 00120 int32_t m_num_classes; 00121 00122 }; /* MulticlassModel */ 00123 00124 } /* namespace shogun */ 00125 00126 #endif /* _MULTICLASS_MODEL__H__ */