Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions petab/v1/visualize/plot_residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,16 @@ def plot_goodness_of_fit(
ax.plot(x, x, linestyle="--", color="gray")
ax.plot(x, intercept + slope * x, "r", label="fitted line")

mse = np.mean(np.abs(residual_df["residual"]))
# assumes that residuals are normalized by default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't assume, pass normalize=True to calculate_residuals. And maybe move calculate_residuals and msnr computation closer together, so this becomes clearer.

msnr = np.mean(np.power(residual_df["residual"], 2))
ax.text(
0.1,
0.70,
f"$R^2$: {r_value**2:.2f}\n"
f"slope: {slope:.2f}\n"
f"intercept: {intercept:.2f}\n"
f"p-value: {p_value:.2e}\n"
f"mean squared error: {mse:.2e}\n",
f"mean of squared\nnormalized residuals: {msnr:.2e}\n",
transform=ax.transAxes,
)

Expand Down