resurfemg.modelling.fit module

Copyright 2026 Netherlands eScience Center and University of Twente Licensed under the Apache License, version 2.0. See LICENSE for details.

This file contains functions for checking the fit of linear models.

check_model_fit(mdl, x_input, y_true, verbose=True, include_constant_term=False)

Check the fit of a linear model by calculating the coefficient of determination (R^2), mean absolute error (MAE), and residual standard error (RSE). :param mdl: The fitted linear model. :type mdl: ~statsmodels.regression.linear_model.RegressionResultsWrapper :param x_input: The input features for the model. :type x_input: ~numpy.ndarray :param y_true: The true output values. :type y_true: ~numpy.ndarray

explained_variance(y_true, y_pred)

Calculate the explained variance score :param y_true: The true output values. :type y_true: ~numpy.ndarray :param y_pred: The predicted output values. :type y_pred: ~numpy.ndarray

residual_standard_error(y_true, y_pred, p)

Calculate the residual standard error (RSE). :param y_true: The true output values. :type y_true: ~numpy.ndarray :param y_pred: The predicted output values. :type y_pred: ~numpy.ndarray :param p: The number of predictors in the model. :type p: int