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

kMeans.py does not work in python3 #9

Open
vitoyan opened this issue Dec 11, 2017 · 1 comment
Open

kMeans.py does not work in python3 #9

vitoyan opened this issue Dec 11, 2017 · 1 comment

Comments

@vitoyan
Copy link

vitoyan commented Dec 11, 2017

in kMeans.py in CH10. it does not work in python3.

    def randCent(dataSet, k):
        n = shape(dataSet)[1]
        centroids = mat(zeros((k, n)))
        for j in range(n):
            minJ = min(dataSet[:,j])
            rangeJ = float(max(dataSet[:,j]) - minJ)

i got a error

rangeJ = float(max(dataSet[:,j]) - minJ)
TypeError: unsupported operand type(s) for -: 'map' and 'map'
@shenyyi
Copy link
Contributor

shenyyi commented Dec 20, 2017

CH10 is not working with python3 yet, but to quick fix this, you can change this line in loadDataset()

from:
fltLine = map(float,curLine) #map all elements to float()
to:
fltLine = list(map(float,curLine)) #map all elements to float()

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

2 participants