tracek / Ornithokrites

Automatic identification of kiwi calls from audio recordings
GNU General Public License v3.0
51 stars 15 forks source link

Cannot load scaler pickle file #12

Closed neilramsay closed 10 years ago

neilramsay commented 10 years ago

Hi there,

I am having some trouble loading the scaler.pkl pickle file. I can unpickle model.pkl with no problems at all.

Unpickling scaler.pkl returns the error "ImportError: No module named data".

Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> scaler = open('scaler.pkl', 'rb')
>>> model = open('model.pkl', 'rb')
>>> pickle.load(model)
SVC(C=300, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.1,
  kernel='rbf', max_iter=-1, probability=False, shrinking=True, tol=0.001,
  verbose=False)
>>> pickle.load(scaler)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/pickle.py", line 1378, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1090, in load_global
    klass = self.find_class(module, name)
  File "/usr/lib/python2.7/pickle.py", line 1124, in find_class
    __import__(module)
ImportError: No module named data

Have you come across this error before?

Cheers, Neil Ramsay


branch: master current HEAD: 97517b9454a897879365249cd14cf9a73770ae14

tracek commented 10 years ago

Hi Neil,

Thanks for the report! I cannot reproduce the problem on my end. Can you share what operating system are you using and Python version? It would be also helpful if you could send me your scaler.pkl to my e-mail address.

Just to be sure: you cloned the repository and did not try to copy the scaler.pkl content by hand? That sort of errors often occur when format is changed from binary to text. Besides, there is at least one known to me bug in Python pickle module that can cause unpickling errors - but let's first eliminate the more likely causes.

neilramsay commented 10 years ago

Hi Lukasz,

I am doing an initial testing with MintLinux 16 in a 64bit VM. It has the Ubuntu python package version 2.7.5-5ubuntu1

I fetched the project via a git clone https://github.com/tracek/Ornithokrites.git

I will send you my copy of scaler.pkl to you via email. It has a SHA1 hash of

38b339296412b3539fbf41c0ad17baef2eb39737  scaler.pkl

Cheers, Neil

neilramsay commented 10 years ago

Hi Lucas,

Thank you for your help :-)

The pickle error was due to a version problem in the scikit-learn package.

I had a system package installed, which was version 0.13, but version 0.14 is required. This is because between version 0.13 and 0.14 preprocessing.py was split into a module, which has a data.py file.

Cheers, Neil

tracek commented 10 years ago

My thanks for explanation! To avoid such problems in future I made importing sklearn modules explicit and stated in Readme what versions of libraries are needed. Issue closed.

Cheers, Lucas