Skip to content

Commit

Permalink
Fix to get Test and Train Fitness for final solution of Mult-objectiv…
Browse files Browse the repository at this point in the history
…e Optimization. Fixes PonyGE#166
  • Loading branch information
zahidirfan committed Oct 2, 2024
1 parent f337171 commit 4e1b5da
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/stats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_moo_stats(individuals, end):
stdout.flush()

# Generate test fitness on regression problems
if hasattr(params['FITNESS_FUNCTION'], "training_test") and end:
if params["DATASET_TEST"] and end:

for ind in trackers.best_ever:
# Iterate over all individuals in the first front.
Expand All @@ -249,7 +249,10 @@ def get_moo_stats(individuals, end):
ind.training_fitness = copy(ind.fitness)

# Evaluate test fitness.
ind.test_fitness = params['FITNESS_FUNCTION'](ind, dist='test')
ind.test_fitness = [
func(ind, dist="test")
for func in params["FITNESS_FUNCTION"].fitness_functions
]

# Set main fitness as training fitness.
ind.fitness = ind.training_fitness
Expand Down

0 comments on commit 4e1b5da

Please sign in to comment.