You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
first of all thank you for this wonderful framework. I have a problem regarding the return of the optimal individual, its evaluation in the variable res.F[0] turns out to be different from the evaluation done outside the genetic algorithm. I realized, by printing all the populations of the various generations, that the optimal value coincides with the best individual but the reference present a res.X[0] is not of that individual. How can I solve this?
Below I leave you the code to run the genetic algorithm (I used a custom variable)
if __name__ == '__main__':
print('\nRESEARCHED FOR ML\n')
print('Select the metric for the evaluation of the individual:\n1.Precision\n2.Recall\n3.Accuracy\n4.F-measure')
print('By default, the metric used is F-measure')
metric = int(input('Type your choice: '))
print('\n\n')
algorithm = GA(pop_size=problem.SIZE_POPULATION,
sampling=Initialization(),
selection=TournamentSelection(pressure=2, func_comp=binary_tournament),
crossover=TreeCrossover(2, 2),
mutation=TreeMutation(),
eliminate_duplicates=False)
res = minimize(ProblemDecisionTree(metric),
algorithm,
get_termination('n_gen', 5),
# get_termination("time", "00:05:00"),
seed=1,
verbose=False)
print('\n\nFINAL SOLUTION', res.X[0])
get_tree_representation(res.X[0])
print('\nEvaluation: ', res.F[0])
model = TreeModel(res.X[0])
model.predict()
print('\n\nAll metrics of the model.')
print(res.X[0])
print('Precision: ', model.get_precision())
print('Recall : ', model.get_recall())
print('Accuracy : ', model.get_accuracy())
print('F-measure: ', model.get_fmeasure())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
first of all thank you for this wonderful framework. I have a problem regarding the return of the optimal individual, its evaluation in the variable res.F[0] turns out to be different from the evaluation done outside the genetic algorithm. I realized, by printing all the populations of the various generations, that the optimal value coincides with the best individual but the reference present a res.X[0] is not of that individual. How can I solve this?
Below I leave you the code to run the genetic algorithm (I used a custom variable)
Beta Was this translation helpful? Give feedback.
All reactions