ECOCPAK v0.9
|
00001 // Copyright (C) 2011 the authors listed below 00002 // http://ecocpak.sourceforge.net 00003 // 00004 // Authors: 00005 // - Dimitrios Bouzas (bouzas at ieee dot org) 00006 // - Nikolaos Arvanitopoulos (niarvani at ieee dot org) 00007 // - Anastasios Tefas (tefas at aiia dot csd dot auth dot gr) 00008 // 00009 // This file is part of the ECOC PAK C++ library. It is 00010 // provided without any warranty of fitness for any purpose. 00011 // 00012 // You can redistribute this file and/or modify it under 00013 // the terms of the GNU Lesser General Public License (LGPL) 00014 // as published by the Free Software Foundation, either 00015 // version 3 of the License or (at your option) any later 00016 // version. 00017 // (see http://www.opensource.org/licenses for more info) 00018 00019 00022 00023 00024 00040 template<typename T1> 00041 inline 00042 void 00043 kmeans 00044 ( 00045 Col<u32>& indices_out, 00046 Col<u32>& ranks_out, 00047 Mat<typename T1::elem_type>& centroids_out, 00048 const Base<typename T1::elem_type,T1>& X, 00049 const u32 k, 00050 const typename T1::pod_type lr = 0.01 00051 ) 00052 { 00053 arma_extra_debug_sigprint(); 00054 00055 arma_check(k == 0, "kmeans(): Number of clusters can't be 0"); 00056 00057 typedef typename T1::elem_type eT; 00058 00059 const unwrap<T1> tmp(X.get_ref()); 00060 const Mat<eT>& A = tmp.M; 00061 00062 op_kmeans::direct_kmeans(indices_out, ranks_out, centroids_out, A, k, lr); 00063 } 00064 00065 00066 00081 mat 00082 subClasses 00083 ( 00084 ucolvec& inds, 00085 ucolvec& ranks, 00086 const mat& samples 00087 ) 00088 { 00089 mat centroids; 00090 ranks = zeros<ucolvec>(2); 00091 kmeans(inds, ranks, centroids, samples, 2); 00092 00093 return centroids; 00094 } 00095 00096 00097