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

unhashable type: 'numpy.ndarray' #76

Closed
fusaroli opened this issue Jan 26, 2016 · 2 comments
Closed

unhashable type: 'numpy.ndarray' #76

fusaroli opened this issue Jan 26, 2016 · 2 comments
Labels

Comments

@fusaroli
Copy link

I am trying out basic tpot functionalities in a toy dataset (latest version, latest commit: f114a0d), and I keep getting:
"unhashable type: 'numpy.ndarray'" for the score function.

My code: https://www.dropbox.com/s/qjor6ewmcngr2xp/TpotCode.txt?dl=0&preview=TpotCode.txt
The data: https://www.dropbox.com/s/5jq1s2z4e4fm6or/Trial.txt?dl=0&preview=Trial.txt

@rhiever
Copy link
Contributor

rhiever commented Jan 26, 2016

I believe the issue was a data shape issue. The predictors should be an array of arrays, whereas the outcomes should be an array of numbers.

I corrected the code below and it seems to work fine.

## Now TPOT
import pandas as pd
from numpy import array
from tpot import TPOT  
from sklearn.cross_validation import train_test_split  

# Import data
Data = pd.DataFrame.from_csv("Trial.txt",sep='\t',index_col=0)
Data=Data.ix[:,0:40]
Data=Data.dropna()
Data = Data.reset_index()

# I changed the two lines below this comment
Outcome=Data["Population"].values
Predictors=Data.ix[:,4:13].values

# Make sure to specify test_size also
X_train, X_test, y_train, y_test = train_test_split(Predictors, Outcome,  
                                                    train_size=0.75,
                                                    test_size=0.25)

tpot = TPOT(generations=5)  
tpot.fit(X_train, y_train)  
tpot.score(X_train, y_train, X_test, y_test)

@fusaroli
Copy link
Author

oh, silly me. Thanks!

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

No branches or pull requests

2 participants