-
Notifications
You must be signed in to change notification settings - Fork 417
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
Converting categorical variables to int / float? #1
Comments
Actually that error is from k-modes.cluster instead of k-prototypes.cluster |
Yes, that seems to be a limitation. Let me see what I can do. Was planning a significant rewrite anyway. For now, you could use sklearn's LabelEncoder to convert to integers: http://scikit-learn.org/dev/modules/generated/sklearn.preprocessing.LabelEncoder.html |
I will try that! Thanks for your quick response! |
Thanks for the motivation fo rewriting the package. :) Try again, using strings directly should now work. |
Thanks! Glad that you wrote this package! |
Merge pull request #1 from nicodv/master
Hi, I am trying to apply your k-prototypes algorithm on my dataset. I have a list of categorical and numerical attributes. Following the soybean examples, i got the following error:
Traceback (most recent call last):
File "", line 2, in
kmodes_huang.cluster(cas_orc_join_nonus_cat, init_method='Huang')
File "/Users/212448740/Desktop/python_ml/kmodes.py", line 75, in cluster
self._perform_clustering(x, _args, verbose=0, *_kwargs)
File "/Users/212448740/Desktop/python_ml/kmodes.py", line 108, in _perform_clustering
self.init_centroids(x)
File "/Users/212448740/Desktop/python_ml/kmodes.py", line 190, in init_centroids
self.centroids[ik, iattr] = random.choice(choices)
ValueError: could not convert string to float
Is that mean i have to convert all the categorical attributes into 0, 1, 2, etc for the function to works?
Sherry
The text was updated successfully, but these errors were encountered: