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 Fernando José Iglesias García 00008 * Copyright (C) 2012 Fernando José Iglesias García 00009 */ 00010 00011 #include <shogun/structure/MulticlassSOLabels.h> 00012 00013 using namespace shogun; 00014 00015 CMulticlassSOLabels::CMulticlassSOLabels() 00016 : CStructuredLabels() 00017 { 00018 init(); 00019 } 00020 00021 CMulticlassSOLabels::CMulticlassSOLabels(SGVector< float64_t > const src) 00022 : CStructuredLabels(src.vlen) 00023 { 00024 init(); 00025 00026 m_num_classes = SGVector< float64_t >::max(src.vector, src.vlen) + 1; 00027 for ( int32_t i = 0 ; i < src.vlen ; ++i ) 00028 { 00029 if ( src[i] < 0 || src[i] >= m_num_classes ) 00030 SG_ERROR("Found label out of {0, 1, 2, ..., num_classes-1}"); 00031 else 00032 add_label( new CRealNumber(src[i]) ); 00033 } 00034 00035 //TODO check that every class has at least one example 00036 } 00037 00038 CMulticlassSOLabels::~CMulticlassSOLabels() 00039 { 00040 } 00041 00042 void CMulticlassSOLabels::init() 00043 { 00044 SG_ADD(&m_num_classes, "m_num_classes", "The number of classes", 00045 MS_NOT_AVAILABLE); 00046 00047 m_num_classes = 0; 00048 }