Dec-25-2018, 04:16 PM
Hi everyone, I need to find the distance between the two rows of the matrix in two different .CSV file. Following is the part of the code:
this is the TRaceback error I am getting:
Data from "Data.csv" file :
Euclidean Distance between two matrix :
[[11.224972160321824, 3.3166247903554, 2.449489742783178], [9.1104335791443, 1.7320508075688772, 1.4142135623730951], [8.774964387392123, 4.123105625617661, 3.4641016151377544]]
The Standard Deviation of the elements in the column number passed as a parameter : 1.4142135623730951
Average of a matrix : 3.0
['5', '3', '2', '8', '5', '10', '8', '1', '2']
Traceback (most recent call last):
File "C:/Users/Python/python-assignment-new.py", line 86, in <module>
main()
File "C:/Users/Python/python-assignment-new.py", line 83, in main
get_k_nearest_labels('Data.csv','Learning_Data.csv','Learning_Data_Labels.csv',1))
File "C:/Users/Python/python-assignment-new.py", line 50, in get_k_nearest_labels
for item in len(fopen):
TypeError: 'int' object is not iterable
>>>
Appreciate any help please???
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
for item in len (fopen): print (item) print ( 'Distance between two matrix :\n' , get_distance(file_open[ 0 ], item)) newfile = load_from_csv(new_matrix) print ( 'TEST' ,newfile[ 0 ]) for data in len (newfile): print (data) print ( 'Distance between two matrix :\n' , get_distance(file_open[ 0 ], data)) def main(): print ( 'Data from "Data.csv" file :' , load_from_csv( 'Data.csv' )) print ( 'Euclidean Distance between two matrix :\n' , get_distance( [[ 2 , 3 , 5 ],[ 12 , 3 , 5 ],[ 2 , 3 , 6 ]], [[ 1 , 2 , 3 ],[ 3 , 4 , 6 ],[ 4 , 5 , 8 ]])) print ( 'The Standard Deviation of the elements in the column number passed as a parameter :' , get_standard_deviation([[ 2 , 5 , 8 ],[ 4 , 8 , 2 ]], 1 )) print ( 'Average of a matrix :' , ave([ 2 , 3 , 4 ])) #print('standardised matrix is :', get_standardised_matrix([[2,5,8],[4,8,2]])) print ( 'Nearest labels between data.csv and learning_data' , get_k_nearest_labels( 'Data.csv' , 'Learning_Data.csv' , 'Learning_Data_Labels.csv' , 1 )) main() |
Data from "Data.csv" file :
Euclidean Distance between two matrix :
[[11.224972160321824, 3.3166247903554, 2.449489742783178], [9.1104335791443, 1.7320508075688772, 1.4142135623730951], [8.774964387392123, 4.123105625617661, 3.4641016151377544]]
The Standard Deviation of the elements in the column number passed as a parameter : 1.4142135623730951
Average of a matrix : 3.0
['5', '3', '2', '8', '5', '10', '8', '1', '2']
Traceback (most recent call last):
File "C:/Users/Python/python-assignment-new.py", line 86, in <module>
main()
File "C:/Users/Python/python-assignment-new.py", line 83, in main
get_k_nearest_labels('Data.csv','Learning_Data.csv','Learning_Data_Labels.csv',1))
File "C:/Users/Python/python-assignment-new.py", line 50, in get_k_nearest_labels
for item in len(fopen):
TypeError: 'int' object is not iterable
>>>
Appreciate any help please???