Open SiqiKe opened 1 month ago
Hi, @SiqiKe:
You can access the fitting history by setting save_history=True
in the minimize
function. This flag would save every generation in the fitting progress. And then you can extract what you need for a statistical analyzation.
Here is the example:
problem = get_problem("zdt1")
algorithm = NSGA2(pop_size=100)
res = minimize(problem,
algorithm,
('n_gen', 200),
seed=42,
save_history=True, # setting save_history=True
verbose=False)
his = res.history # a list contains this status of every generation
first_gen_pop = his[0].pop # the first generation's whole population
first_gen_opt = his[0].opt # pareto front in first generation
first_gen_pop.get('X') # the solutions
first_gen_pop.get('F') # the objective spaces values
first_gen_opt.get('X')
first_gen_opt.get('F')
plot = Scatter()
plot.add(first_gen_pop.get('F'), facecolor="blue", edgecolor="blue")
plot.add(first_gen_opt.get('F'), facecolor="red", edgecolor="red")
plot.show()
As for your self-defined statistics, you can define your own functions and run the function after fitting for all generations!
Hi,
I have a question regarding the ability to check some self-defined statistics between generations during the optimization run. Specifically, I would like to know if there is a way to compute and track custom statistics as the generations evolve.
Is there a built-in feature that allows me to calculate and compare some statistics between generations?
If not, could you suggest how I might modify the source code to enable this functionality?
Any guidance or example implementations would be greatly appreciated!
Thank you for your help!