Skip to content

Commit

Permalink
More detailed comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jmafoster1 committed Jan 6, 2025
1 parent 9bb78f1 commit f22af96
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,15 @@ def fitness(self, expression: gp.PrimitiveTree) -> float:
if isinstance(expression, str):
expression = creator.Individual(gp.PrimitiveTree.from_string(expression, self.pset))

# Create model, fit (run) it, give estimates from it]
# Create model, fit (run) it, give estimates from it
func = gp.compile(expression, self.pset)
y_estimates = pd.Series(
[func(**x) for _, x in self.df[self.features].iterrows()],
index=self.df.index,
)

# Calculate errors using root mean square error
# Calculate errors using the normalised root mean square error (nrmse),
# which is normalised with respect to the range
sqerrors = (self.df[self.outcome] - y_estimates) ** 2
nrmse = np.sqrt(sqerrors.sum() / len(self.df)) / (self.df[self.outcome].max() - self.df[self.outcome].min())

Expand Down

0 comments on commit f22af96

Please sign in to comment.