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

Text classification - error when fitting HyperoptEstimator #71

Closed
rdoume opened this issue Mar 23, 2017 · 2 comments
Closed

Text classification - error when fitting HyperoptEstimator #71

rdoume opened this issue Mar 23, 2017 · 2 comments

Comments

@rdoume
Copy link

rdoume commented Mar 23, 2017

Hi there,

I am encountering an issue regarding the text classifier example explained at http://hyperopt.github.io/hyperopt-sklearn/.

I'm litteraly copy-pasting the example, but an error rises when I execute the fit command.

estim.fit( X_train, y_train )

Traceback (most recent call last):
  File "<ipython-input-12-8ecb54c50078>", line 1, in <module>
    estim.fit( X_train, y_train )

  File "/home/robin/Documents/Python/hyperopt-sklearn/hpsklearn/estimator.py", line 708, in fit
    fit_iter.send(increment)
  File "/home/robin/Documents/Python/hyperopt-sklearn/hpsklearn/estimator.py", line 619, in fit_iter
    return_argmin=False, # -- in case no success so far
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/fmin.py", line 307, in fmin
    return_argmin=return_argmin,
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/base.py", line 635, in fmin
    return_argmin=return_argmin)
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/fmin.py", line 320, in fmin
    rval.exhaust()
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/fmin.py", line 199, in exhaust
    self.run(self.max_evals - n_done, block_until_done=self.async)
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/fmin.py", line 173, in run
    self.serial_evaluate()
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/fmin.py", line 92, in serial_evaluate
    result = self.domain.evaluate(spec, ctrl)
  File "/home/robin/anaconda3/lib/python3.5/site-packages/hyperopt/base.py", line 840, in evaluate
    rval = self.fn(pyll_rval)
  File "/home/robin/Documents/Python/hyperopt-sklearn/hpsklearn/estimator.py", line 582, in fn_with_timeout
    raise fn_rval[1]

ValueError: zero-dimensional arrays cannot be concatenated 

I have checked that my numpy version is 1.11.0 ( I saw that this could be an issue).

Do you have an idea of what's going on? Maybe Python 3.5 ?
Thank you,

@bjkomer
Copy link
Member

bjkomer commented Mar 23, 2017

It looks like this bug was introduced during refactoring when a bunch of new features were added. The problem stems from np.concatenate() being used on a sparse array. I'll look into it more and see if I can get a fix.

In the meantime, one option would be to use a version of the code before the bug was introduced. This is the last commit where things are working. You can check this point out and use it with this command:
git checkout 3393a2236ee1a1ef46a5e474f85532357597aed3

IDex added a commit to IDex/hyperopt-sklearn that referenced this issue Mar 1, 2018
As mentioned in hyperopt#71 feeding sparse arrays to .fit caused
```
ValueError: zero-dimensional arrays cannot be concatenated
```
to be raised. This fixes the issue.
IDex added a commit to IDex/hyperopt-sklearn that referenced this issue Mar 1, 2018
As mentioned in hyperopt#71 feeding sparse arrays to .fit caused
```
ValueError: zero-dimensional arrays cannot be concatenated
```
to be raised. This fixes the issue.
@bjkomer
Copy link
Member

bjkomer commented Sep 21, 2018

fixed in #107

@bjkomer bjkomer closed this as completed Sep 21, 2018
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