-
Notifications
You must be signed in to change notification settings - Fork 270
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
AttributeError: 'numpy.random.mtrand.RandomState' object has no attribute 'integers' #179
Comments
@john-zeng112 I am seeing the same issue on 1.19.5 and 1.0.1. My stack trace is as follows:
I had a look through the hyperopt search code. The SparkTrials behaves differently than the normal base.Trials object. The SparkTrials object is expecting an instance of numpy.random.default_rng(SEED)). We can see an example of this in hyperopt/mix.py on line 28 - 34. I adjusted my code and saw success with:
I guess we can either mark this as solved or ask @jaberg if the difference between the interfaces of the Trials objects was intentional. I would argue that the same type of seed should be used for ALL classes of Trials. If there is a technical limitation then I'd suggest documenting SparkTrials as the black sheep and providing an example. |
Seeing the same issue with hpsklearn=0.1.0, numpy=1.21.4, hyperopt=0.2.7, Python 3.9.6. I'm running something very simple, straight from the main readme: from hpsklearn import HyperoptEstimator, svc
estim = HyperoptEstimator(classifier=svc('mySVC'))
estim.fit(X_train, Y_train) Stack trace: AttributeError Traceback (most recent call last)
1 from hpsklearn import HyperoptEstimator, svc
2 estim = HyperoptEstimator(classifier=svc('mySVC'))
----> 3 estim.fit(X_train, Y_train)
~/.venv/lib/python3.9/site-packages/hpsklearn/estimator.py in fit(self, X, y, EX_list, valid_size, n_folds, cv_shuffle, warm_start, random_state, weights)
744 increment = min(self.fit_increment,
745 adjusted_max_evals - len(self.trials.trials))
--> 746 fit_iter.send(increment)
747 if filename is not None:
748 with open(filename, 'wb') as dump_file:
~/.venv/lib/python3.9/site-packages/hpsklearn/estimator.py in fit_iter(self, X, y, EX_list, valid_size, n_folds, cv_shuffle, warm_start, random_state, weights, increment)
646 # latest hyperopt.fmin() on master does not match PyPI
647 if 'rstate' in inspect.getargspec(hyperopt.fmin).args:
--> 648 hyperopt.fmin(fn_with_timeout,
649 space=self.space,
650 algo=self.algo,
~/.venv/lib/python3.9/site-packages/hyperopt/fmin.py in fmin(fn, space, algo, max_evals, timeout, loss_threshold, trials, rstate, allow_trials_fmin, pass_expr_memo_ctrl, catch_eval_exceptions, verbose, return_argmin, points_to_evaluate, max_queue_len, show_progressbar, early_stop_fn, trials_save_file)
538
539 if allow_trials_fmin and hasattr(trials, "fmin"):
--> 540 return trials.fmin(
541 fn,
542 space,
~/.venv/lib/python3.9/site-packages/hyperopt/base.py in fmin(self, fn, space, algo, max_evals, timeout, loss_threshold, max_queue_len, rstate, verbose, pass_expr_memo_ctrl, catch_eval_exceptions, return_argmin, show_progressbar, early_stop_fn, trials_save_file)
669 from .fmin import fmin
670
--> 671 return fmin(
672 fn,
673 space,
~/.venv/lib/python3.9/site-packages/hyperopt/fmin.py in fmin(fn, space, algo, max_evals, timeout, loss_threshold, trials, rstate, allow_trials_fmin, pass_expr_memo_ctrl, catch_eval_exceptions, verbose, return_argmin, points_to_evaluate, max_queue_len, show_progressbar, early_stop_fn, trials_save_file)
584
585 # next line is where the fmin is actually executed
--> 586 rval.exhaust()
587
588 if return_argmin:
~/.venv/lib/python3.9/site-packages/hyperopt/fmin.py in exhaust(self)
362 def exhaust(self):
363 n_done = len(self.trials)
--> 364 self.run(self.max_evals - n_done, block_until_done=self.asynchronous)
365 self.trials.refresh()
366 return self
~/.venv/lib/python3.9/site-packages/hyperopt/fmin.py in run(self, N, block_until_done)
277 # processes orchestration
278 new_trials = algo(
--> 279 new_ids, self.domain, trials, self.rstate.integers(2 ** 31 - 1)
280 )
281 assert len(new_ids) >= len(new_trials)
AttributeError: 'numpy.random.mtrand.RandomState' object has no attribute 'integers' Having install requirements would make debugging this a lot easier (#180) |
For me this issue was solved by changing hyperopt to version 0.2.5 My (linux) setup: For me it worked in both ways of installing: with |
when I |
Facing same issue for hyperopt (0.2.7) |
The problem still exists |
This is an issue with hyperopt. Not hyperopt-sklearn. Downgrading to hyperopt v0.2.5 solves it for most. |
This didn't work with sparse data, instead of: Now I have: This error is mentioned in #105 as completed, but I'm with this same error on hyperopt 0.2.5 |
I encountered a AttributeError: 'numpy.random.mtrand.RandomState' object has no attribute 'integers' at the hyperopt/fmin.py in run(self, N, block_until_done). My numpy and sklearn version are 1.19.2 and 1.0.1, respectively.
The text was updated successfully, but these errors were encountered: