Closed fakhrulfa closed 4 years ago
Hi @fakhrulfa,
which version of NiaPy are you using? If not already, please install the latest release candidate version pip install NiaPy==2.0.0rc10
.
If you are still facing some issues with the latest RC version installed, please let us know.
Thanks, its work!
but, when i tried to run this code. i got an output like this :
(None, None)
(None, None)
(None, None)
(None, None)
(None, None)
How to add the random number(import random) to the code, wheres the parameter that can contain the random number ?
Could you provide us with a code example, which you are trying to run?
Heres the code, same as code that i used before.
import random
from NiaPy.algorithms.basic import FlowerPollinationAlgorithm
from NiaPy.task import StoppingTask
from NiaPy.benchmarks import Sphere
#we will run Flower Pollination Algorithm for 5 independent runs
for i in range(5):
task = StoppingTask(D=10, nFES=10000, benchmark=Sphere())
algo = FlowerPollinationAlgorithm(NP=20, p=0.5)
best = algo.run(task=algo)
print(best)
You have a problem in line best = algo.run(task=algo)
, where it should be best = algo.run(task=task)
, like in the example https://github.com/NiaOrg/NiaPy/blob/master/examples/run_fpa.py .
ow, okay, thanks. its works!
But, how can i find the best solution in case when i try to find best value for parameter in sklearn method. In this case, i try to find best value of C and Epsilon, in parameter of SVM in Sklearn.
Heres the code:
regressor = SVR(kernel='linear', C=value, gamma=0.1, epsilon=value)
regressor.fit(X_train, y_train)
Hope u can help, thanks again!
No problem. Regarding the parameter optimization of SVM, in general, you should implement your custom benchmark class which would map and evaluate the solution obtained from the optimization algorithm. For more information, you can check out the following blog post, where NiaPy is utilized for finding the most suitable parameters for KNN. Please, be aware that in the mentioned blog post the NiaPy version 1 is used, which is not compatible with version 2 (which you are using), so you can not copy-paste the code from the blog post to your project, but the general idea is the same.
Okay, i will try to follow the idea of the code on your blog. Thanks!
Hi,
I tried your example of Flower Pollination Algorithm code, but i got an error like this :
Here's the code :
Hope you can help, thanks!