-
Notifications
You must be signed in to change notification settings - Fork 418
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
TypeError: unhashable type #40
Comments
Please post a full traceback, so that I can locate the error.
…On Apr 16, 2017 11:47 PM, "visayang2005" ***@***.***> wrote:
when i commit the code below:
clustermodel=kprototypes.KPrototypes(n_clusters=6, init='Cao', verbose=2)
clustermodel.fit(sd1,categorical=[0,1])
it can't run with the " TypeError: unhashable type", but kmode is ok.
could you pls tell me how can solve this problem? Thank very much!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#40>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADi0g_l8lQRXo4nKs2vGJOYZM6txNvJaks5rwwrugaJpZM4M-67U>
.
|
ok, my full code like this, from kmodes import kmodes the first two varibles of dataframe sd1 is categorical, other varibles is continussd1=sd[['state','newmode_id','at_price_scaled','day_diff_scaled', 'time_avg_rate_scaled', 'total_dealnum_scaled', 'total_dealprice_scaled', 'total_dealnum_fws_scaled']] clustermodel=kprototypes.KPrototypes(n_clusters=6, init='Cao', verbose=2) |
Can you post the full error too, please?
…On Apr 16, 2017 11:57 PM, "visayang2005" ***@***.***> wrote:
ok, my full code like this,
from kmodes import kmodes
from kmodes import kprototypes
import pandas as pd
from sklearn import cluster
the first two varibles of dataframe sd1 is categorical, other varibles is
continus
sd1=sd[['state','newmode_id','at_price_scaled','day_diff_scaled',
'time_avg_rate_scaled', 'total_dealnum_scaled', 'total_dealprice_scaled',
'total_dealnum_fws_scaled']]
clustermodel=kprototypes.KPrototypes(n_clusters=6, init='Cao', verbose=2)
cluser=clustermodel.fit_predict(sd1,categorical=[0,1])
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADi0gzKfclSR07U3GRBHwuArpjW7hneAks5rww1GgaJpZM4M-67U>
.
|
sorry, pls ignore before, use this: cluser=clustermodel.fit_predict(sd1,categorical=[0,1]) File "", line 1, in File "build\bdist.win-amd64\egg\kmodes\kmodes.py", line 374, in fit_predict File "build\bdist.win-amd64\egg\kmodes\kprototypes.py", line 415, in fit File "build\bdist.win-amd64\egg\kmodes\kprototypes.py", line 154, in k_prototypes File "build\bdist.win-amd64\egg\kmodes\kprototypes.py", line 47, in _split_num_cat File "D:\Anaconda2\lib\site-packages\pandas\core\frame.py", line 2059, in getitem File "D:\Anaconda2\lib\site-packages\pandas\core\frame.py", line 2066, in _getitem_column File "D:\Anaconda2\lib\site-packages\pandas\core\generic.py", line 1384, in _get_item_cache TypeError: unhashable type |
Hi Nico, The full error like this, can you help me to solve it, I really appreciate your help. cluser=clustermodel.fit_predict(sd1,categorical=[0,1]) File "", line 1, in File "build\bdist.win-amd64\egg\kmodes\kmodes.py", line 374, in fit_predict File "build\bdist.win-amd64\egg\kmodes\kprototypes.py", line 415, in fit File "build\bdist.win-amd64\egg\kmodes\kprototypes.py", line 154, in k_prototypes File "build\bdist.win-amd64\egg\kmodes\kprototypes.py", line 47, in _split_num_cat File "D:\Anaconda2\lib\site-packages\pandas\core\frame.py", line 2059, in getitem File "D:\Anaconda2\lib\site-packages\pandas\core\frame.py", line 2066, in _getitem_column File "D:\Anaconda2\lib\site-packages\pandas\core\generic.py", line 1384, in _get_item_cache TypeError: unhashable type |
Try presenting a numpy array to the algorithm, instead of a pandas DataFrame:
|
Since it seems reasonable to have users present pandas DataFrames as inputs to the algorithm, it's probably a good idea to include a check (e.g., Alternatively, make sure all operations (such as the one that caused this bug) support DataFrames, but that's hard to implement and check consistently. |
Thanks, Nico. My problem is solved by using a numpy array to the algorithm. |
This should no longer occur: a30da80 |
This is not fixed in the latest version. Added the .values to the dataframe and worked like a charm. Snippet from kprototypes:
|
Fixed for real by: #67 |
when i commit the code below:
clustermodel=kprototypes.KPrototypes(n_clusters=6, init='Cao', verbose=2)
clustermodel.fit(sd1,categorical=[0,1])
it can't run with the " TypeError: unhashable type", but kmode is ok. could you pls tell me how can solve this problem? Thank very much!
The text was updated successfully, but these errors were encountered: