Module Expr Str Import alias Import alias identifier Import alias ImportFrom alias Assign NameStore Str FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str Return TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListLoad For NameStore Call NameLoad Call NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore ListLoad For NameStore Call NameLoad Call NameLoad NameLoad body If CompareNotEq NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return SubscriptLoad Call NameLoad NameLoad Slice BinOpAdd NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListLoad While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr For TupleStore NameStore NameStore Call NameLoad NameLoad body If BoolOpAnd Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Num keyword Num keyword NameLoad CompareNotIn NameLoad Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Break Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad NameLoad Return Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore NameLoad Assign TupleStore NameStore NameStore TupleLoad Num Num For NameStore SubscriptLoad NameLoad Slice Num body If CompareEq SubscriptLoad NameLoad Index NameLoad NameLoad body AugAssignAdd NameStore Num orelse AugAssignAdd NameStore Num Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareGtE NameLoad NameLoad body Return NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Num Assign NameStore Call NameLoad NameLoad For NameStore Call NameLoad Call NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad If CompareEq SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index Num body AugAssignAdd NameStore Num Return BinOpDiv NameLoad NameLoad decorator_list If CompareEq NameLoad Str body Import alias Assign NameStore IfExp CompareEq Call NameLoad AttributeLoad NameLoad attr Num SubscriptLoad AttributeLoad NameLoad attr Index Num Num Assign NameStore IfExp CompareEq Call NameLoad AttributeLoad NameLoad attr Num SubscriptLoad AttributeLoad NameLoad attr Index Num Str Assign TupleStore NameStore NameStore NameStore NameStore NameStore Call NameLoad NameLoad Print Call NameLoad NameLoad NameLoad NameLoad
N/A N/A 
Calculates the k-nearest neighbor (kNN) algorithm

 N/A math N/A numpy np N/A scipy.io calculate_cosine_distance cosineDistance N/A __author__ Mari Wahl loading_data N/A N/A filename N/A N/A N/A  
       This function load a MATLAB file and get the dict variables 
     N/A f N/A N/A N/A scipy io loadmat filename N/A traindata N/A f N/A traindata N/A trainlabels N/A f N/A trainlabels N/A testdata N/A f N/A testdata N/A evaldata N/A f N/A evaldata N/A testlabels N/A f N/A testlabels N/A N/A traindata trainlabels testdata evaldata testlabels N/A calculate_distances N/A N/A trainlabels traindata N/A N/A N/A 
       This function calculate the distances for all the input examples
     N/A distances N/A N/A i N/A range N/A len trainlabels N/A N/A first_train_example_class1 N/A traindata N/A i N/A aux N/A N/A j N/A range N/A len trainlabels N/A N/A N/A i j N/A N/A first_train_example_class2 N/A traindata N/A j N/A d N/A cosineDistance first_train_example_class1 first_train_example_class2 N/A N/A N/A aux append d N/A N/A N/A distances append aux N/A distances N/A get_closest_k_points N/A N/A D k N/A N/A N/A 
       Get the k closest points
     N/A N/A N/A sorted D N/A N/A k 1 N/A get_index_vec N/A N/A points_list D N/A N/A N/A 
       Return the index of the k closest points
     N/A index_vec N/A N/A points_list N/A N/A point N/A N/A points_list pop N/A N/A j point_D N/A enumerate D N/A N/A N/A N/A N/A np isclose point_D point rtol 1e-08 atol 1e-08 equal_nan False N/A j N/A set index_vec N/A N/A N/A N/A index_vec append j N/A N/A index_vec N/A knn_search N/A N/A x D k N/A N/A N/A  
       Find the K nearest neighbours of data among distance D 
     N/A points_list N/A get_closest_k_points D k N/A N/A get_index_vec points_list D N/A knn_classify N/A N/A index_vec trainlabels N/A N/A N/A 
       Return the classification of the indices
     N/A label1 N/A trainlabels N/A 0 N/A label2 None N/A N/A neg pos N/A 0 0 N/A i N/A index_vec N/A 1 N/A N/A N/A N/A trainlabels N/A i label1 N/A N/A pos 1 N/A N/A neg 1 N/A label2 N/A trainlabels N/A i N/A N/A pos neg N/A N/A label1 N/A N/A label2 N/A calculate_knn N/A N/A traindata trainlabels k N/A N/A N/A 
       Return knn classification
     N/A distances N/A calculate_distances trainlabels traindata N/A correct 0.0 N/A total N/A len traindata N/A x N/A range N/A len traindata N/A N/A index_vec N/A knn_search x N/A distances N/A x k N/A classification N/A knn_classify index_vec trainlabels N/A N/A N/A trainlabels N/A x N/A classification N/A 0 N/A N/A correct 1 N/A N/A correct total N/A N/A N/A __name__ __main__ N/A N/A sys N/A k N/A N/A N/A len N/A sys argv 2 N/A N/A sys argv N/A 1 5 N/A datafile N/A N/A N/A len N/A sys argv 3 N/A N/A sys argv N/A 2 cvdataset.mat N/A N/A traindata trainlabels testdata evaldata testlabels N/A loading_data datafile N/A N/A calculate_knn traindata trainlabels k