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) 2012 Chiyuan Zhang 00008 * Written (W) 2013 Shell Hu and Heiko Strathmann 00009 * Copyright (C) 2012 Chiyuan Zhang 00010 */ 00011 00012 #include <shogun/multiclass/MulticlassStrategy.h> 00013 #include <shogun/mathematics/Math.h> 00014 00015 using namespace shogun; 00016 00017 00018 CMulticlassStrategy::CMulticlassStrategy() 00019 : CSGObject() 00020 { 00021 init(); 00022 } 00023 00024 CMulticlassStrategy::CMulticlassStrategy(EProbHeuristicType prob_heuris) 00025 : CSGObject() 00026 { 00027 init(); 00028 00029 m_prob_heuris=prob_heuris; 00030 } 00031 00032 void CMulticlassStrategy::init() 00033 { 00034 m_rejection_strategy=NULL; 00035 m_train_labels=NULL; 00036 m_orig_labels=NULL; 00037 m_train_iter=0; 00038 m_prob_heuris=PROB_HEURIS_NONE; 00039 m_num_classes=0; 00040 00041 SG_ADD((CSGObject**)&m_rejection_strategy, "rejection_strategy", "Strategy of rejection", MS_NOT_AVAILABLE); 00042 SG_ADD(&m_num_classes, "num_classes", "Number of classes", MS_NOT_AVAILABLE); 00043 SG_ADD((machine_int_t*)&m_prob_heuris, "prob_heuris", "Probability estimation heuristics", MS_NOT_AVAILABLE); 00044 } 00045 00046 void CMulticlassStrategy::train_start(CMulticlassLabels *orig_labels, CBinaryLabels *train_labels) 00047 { 00048 if (m_train_labels != NULL) 00049 SG_ERROR("Stop the previous training task before starting a new one!") 00050 SG_REF(train_labels); 00051 m_train_labels=train_labels; 00052 SG_REF(orig_labels); 00053 m_orig_labels=orig_labels; 00054 m_train_iter=0; 00055 } 00056 00057 SGVector<int32_t> CMulticlassStrategy::train_prepare_next() 00058 { 00059 m_train_iter++; 00060 return SGVector<int32_t>(); 00061 } 00062 00063 void CMulticlassStrategy::train_stop() 00064 { 00065 SG_UNREF(m_train_labels); 00066 SG_UNREF(m_orig_labels); 00067 m_train_labels = NULL; 00068 m_orig_labels = NULL; 00069 }