

def print_to_file(distances):
    with open('cos_distances.dat', 'w') as f:
        for (i, col) in enumerate(distances):
            f.write(('# distance for example %d to others\n' % (i + 1)))
            for item in col:
                f.write((str(item) + ' '))
            f.write('\n')

dataset/ETHPy150Open bt3gl/Advanced-Machine-Learning/k-NN/calculate_cosine_distance.py print_to_file/original