ECOCOVOEncoder.cpp

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 #include <shogun/multiclass/ecoc/ECOCOVOEncoder.h>
00012 
00013 using namespace shogun;
00014 
00015 SGMatrix<int32_t> CECOCOVOEncoder::create_codebook(int32_t num_classes)
00016 {
00017     SGMatrix<int32_t> code_book(num_classes*(num_classes-1)/2, num_classes, true);
00018     code_book.zero();
00019     int32_t k=0;
00020     for (int32_t i=0; i < num_classes; ++i)
00021     {
00022         for (int32_t j=i+1; j < num_classes; ++j)
00023         {
00024             code_book(k, i) = 1;
00025             code_book(k, j) = -1;
00026             k++;
00027         }
00028     }
00029 
00030     return code_book;
00031 }
00032 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation