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/ECOCSimpleDecoder.h> 00012 00013 using namespace shogun; 00014 00015 int32_t CECOCSimpleDecoder::decide_label(const SGVector<float64_t> outputs, const SGMatrix<int32_t> codebook) 00016 { 00017 SGVector<float64_t> query=outputs; 00018 00019 if (binary_decoding()) 00020 query = binarize(outputs); 00021 00022 SGVector<float64_t> distances(codebook.num_cols); 00023 for (int32_t i=0; i < distances.vlen; ++i) 00024 distances[i] = compute_distance(query, codebook.get_column_vector(i)); 00025 00026 int32_t result = SGVector<float64_t>::arg_min(distances.vector, 1, distances.vlen); 00027 return result; 00028 }