Skip to content

[Code scan] Constant stacking-fault predictions can produce invalid derivative metrics #437

Description

@njzjz

This issue was found by a Codex global repository scan of tracked non-test files at commit 8c93925cb10b401b2b83c738bd9263fd74474468.

Relevant code

_, y_smooth_pred = fit_pchip(
res, x_col="Displacement", y_col="Energy", num_points=NUM_POINTS
)
derivative_label = (
(y_smooth_label[1:] - y_smooth_label[:-1])
* (NUM_POINTS - 1)
/ max(y_smooth_label)
)
derivative_pred = (
(y_smooth_pred[1:] - y_smooth_pred[:-1]) * (NUM_POINTS - 1) / max(y_smooth_pred)
)
return np.round(mean_absolute_error(y_smooth_label, y_smooth_pred), 4), np.round(
mean_absolute_error(derivative_label, derivative_pred), 4
)

Impact

The derivative metric normalizes by max(y_smooth_pred). A calculator that predicts a flat energy curve produces y_smooth_pred == 0 after subtracting the minimum, so the denominator is zero. The resulting NaN values can make the derivative MAE invalid or fail the task instead of assigning a defined penalty for a bad trajectory.

Suggested fix

Guard zero or near-zero denominators and assign a defined derivative penalty, or mark that trajectory as failed while allowing the rest of the task to complete. Add a regression test with constant predicted energies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions