//#include "stdafx.h" #include #include #include #include #include #include #include #include #include "./../CSVparser/CSVparser.h" #include "KNN.h" using namespace std; ifstream fin; ofstream fout; string Trim(string& str) { str.erase(0,str.find_first_not_of(" \t\r\n")); str.erase(str.find_last_not_of(" \t\r\n") + 1); return str; } KNN::KNN(int magic_x, int magic_y, int magic_z) { int k = 10; this->k = k; csv::Parser file = csv::Parser("d:/magic_map/trainning_data_magic.csv"); std::cout << file[0][0] << std::endl; // display : 1997 std::cout << file[0] << std::endl; // display : 1997 | Ford | E350 cout<::const_iterator map_it = map_label_freq.begin(); tLabel label; int max_freq = 0; //find the most frequent label while( map_it != map_label_freq.end() ) { if( map_it->second > max_freq ) { max_freq = map_it->second; label = map_it->first; } map_it++; } cout<<"The test data belongs to the x:"<>k; KNN knn(k); knn.get_all_distance(); knn.get_max_freq_label(); system("pause"); return 0; } #endif