28 #ifndef __INCLUDE_MIST_KNN__
29 #define __INCLUDE_MIST_KNN__
31 #ifndef __INCLUDE_MIST_H__
35 #ifndef __INCLUDE_MIST_MATRIX_H__
36 #include "../matrix.h"
55 bool operator<(
const distance_pair &a )
const
57 return distance < a.distance;
86 std::map< int, bool > rmap;
88 for(
size_t i = 0 ; i < response.
size() ; ++i )
90 if( rmap.find( response( i ) ) == rmap.end() )
92 rmap[ response( i ) ] =
true;
111 for(
size_t i = 0 ; i < in_.cols() ; ++i )
114 for(
size_t j = 0 ; j < in_.rows() ; ++j )
116 dist += pow( in_( j, i ) - in( j, 0 ), 2.0 );
119 mes( i ).distance = dist;
123 std::sort( mes.begin(), mes.end() );
125 for(
int i = 0 ; i < k ; ++i )
127 ++vote( response_( mes( i ).index ) );
133 for(
int i = 0 ; i < category_count_ ; ++i )
135 if( vote( i ) > max_count )
137 max_count = vote( i );