How do I prepare this text file for nearest neighbor algorithm?
Question: I want to prepare the text file so I can use k-NN clusstering in python 2.7. I
have no idea how to approach this. Can anybody help?

The dataset is here: <http://textuploader.com/ayhqc>

Columns are separated by commas and rows are separated by newlines. Each
column describes one individual patient. The attributes are in rows in the
following order: plasma_glucose, bp, test_result, skin_thickness,
num_pregnancies, insulin, bmi, pedigree, age.


Answer: You need to transpose the data first (below) and then you can use an out of
the box algo.

    
    
    import numpy as np
    f1=open(,'r')
    data=np.zeros(100,6) #rows and cols
    j=0
    for line in f1:
      row=line.split(',')
      for i in range(len(row)):
        x=row[i]
        if x=='positive': x=1
        elif x=='negative': x=-1
        else: x=float(x)
        data[i,j]=x
      j+=1
    

