1

I'm trying to adjust a random forest as a Hyperopt, but this error is occurring and I can't solve it

enter image description here

enter image description here

  • Please do not include code/errors as images. Somewhere you have a variable called hp that shadows the hp package in hyperopt – Dr. Snoopy Jun 19 '20 at 23:21

4 Answers4

1

Here, rstate parameter of fmin() function needs random number generator which can be provided by np.random.RandomState(seed). However, you have passed an integer value (i.e., rstate=42) and that is why it is showing

AttributeError: 'int' object has no attribute 'randint'

Therefore, simply replacing that value (i.e., 42) by np.random.RandomState(42) will resolve the problem.

Md. Sabbir Ahmed
  • 850
  • 8
  • 22
0

Not sure if you have resolved this yet but I think you can't set 'rstate' as an integer in this method, I had the same issue and it's resolve since I stopped setting 'rstate'

  • Welcome to SO! Please read the [tour](https://stackoverflow.com/tour), and [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) – Tomer Shetah Dec 16 '20 at 13:05
0

Try using rstate=np.random.default_rng(seed=42) instead.

George Shimanovsky
  • 1,668
  • 1
  • 17
  • 15
0

This was due to the method np.random.RandomState was deprecated. Hyperopt now uses np.random.Generator().

You can use the rstate=np.random.default_rng(42)

This can fix your issue

Ravi kumar
  • 170
  • 1
  • 2
  • 15