gkhayes / mlrose

Python package for implementing a number of Machine Learning, Randomized Optimization and SEarch algorithms.
https://mlrose.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
235 stars 243 forks source link

RHC using wrong get_fitness? #27

Closed nibelungvalesti closed 5 years ago

nibelungvalesti commented 5 years ago

I think the fitness_curve.append in line 210 of algorithms.py is using the incorrect get_fitness (it's using get_pop_fitness)? When running an RHC, I get a blank array back for the fitness curve.

daivinhtran commented 5 years ago

I have the same problem. I think random_climb, random_hill_climb, and simulated_annealing should use get_fitness instead. genetic_alg and mimic still uses get_pop_fitness as implemented.

get_fitness returns the fitness value of the current state. get_pop_fitness returns the fitness values of the states of the current population. "Population" is only relevant in mimic and genetic_alg, I believe.

I'll make a quick fix to see how that goes.

nibelungvalesti commented 5 years ago

random_climb? or hill_climb? I think hill_climb should have implemented it correctly from what I see? And yeah, SA should be updated with the same fix. Oh and I also made a pull request so you can check it with that fork. I verified that it works...so far!

daivinhtran commented 5 years ago

Yeah, you're right. hill_climb had it correct already.

daivinhtran commented 5 years ago

Ahh I also made the same PR. 😄 I'll close mine.

gkhayes commented 5 years ago

I have just merged @nibelungvalesti 's pull request that fixes this issue, so am closing this. Thanks to @nibelungvalesti and @daivinhtran for pointing it out. Regards, Genevieve.