Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runing problrm #6

Open
kelly110 opened this issue Feb 27, 2019 · 3 comments
Open

runing problrm #6

kelly110 opened this issue Feb 27, 2019 · 3 comments

Comments

@kelly110
Copy link

hi,thanks for your sharing.but when I run the code,I have a problem that need your help.
if val < shortest:

TypeError: '<' not supported between instances of 'float' and 'tuple'

@knowledgecomputer2018
Copy link

hi
#python3
1-shortest is number change :
shortest=0.0
2- and in python3 change itervalues to items :
for count,points in new_means.items():
3-change xrange to range in python3

god willing

@mcpcpc
Copy link

mcpcpc commented Jan 13, 2021

hi
#python3
1-shortest is number change :
shortest=0.0
2- and in python3 change itervalues to items :
for count,points in new_means.items():
3-change xrange to range in python3

god willing

Tried this and ran the commented example:

 points = [
     [1, 2],
     [2, 1],
     [3, 1],
     [5, 4],
     [5, 5],
     [6, 5],
     [10, 8],
     [7, 9],
     [11, 5],
     [14, 9],
     [14, 14],
     ]
 print(k_means(points, 3))

Alas, assignments returns [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]. ='(

@ZiHAO-LI-cmd
Copy link

ZiHAO-LI-cmd commented Jun 20, 2022

shortest should be float('inf') and assignments returns [(0, [1, 2]), (0, [2, 1]), (0, [3, 1]), (0, [5, 4]), (0, [5, 5]), (0, [6, 5]), (1, [10, 8]), (1, [7, 9]), (1, [11, 5]), (2, [14, 9]), (2, [14, 14])]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants