Skip to content

Residual

add_residuals_col(df, residual_name='residual', true_column='y', pred_column='y_hat')

Add a residuals column to the DataFrame.

PARAMETER DESCRIPTION
df

The input DataFrame.

TYPE: DataFrame

residual_name

The name for the new residuals column.

TYPE: str DEFAULT: 'residual'

true_column

The name of the column with true values.

TYPE: str DEFAULT: 'y'

pred_column

The name of the column with predicted values.

TYPE: str DEFAULT: 'y_hat'

RETURNS DESCRIPTION
DataFrame

The DataFrame with the added residuals column.

calculate_residual_bounds(rss, n_rows)

Calculate upper and lower residual bounds.

PARAMETER DESCRIPTION
rss

The residual sum of squares.

TYPE: float

n_rows

The number of rows in the DataFrame.

TYPE: int

RETURNS DESCRIPTION
tuple[float, float]

A tuple containing the lower and upper residual bounds.

get_residual_bounds(df, residual_column='residual')

Calculate residual bounds for the DataFrame.

PARAMETER DESCRIPTION
df

The input DataFrame.

TYPE: DataFrame

residual_column

The name of the residuals column.

TYPE: str DEFAULT: 'residual'

RETURNS DESCRIPTION
tuple[float, float]

A tuple containing the lower and upper residual bounds.

get_residual_sum_square(df, residual_column='residual')

Calculate the residual sum of squares.

PARAMETER DESCRIPTION
df

The input DataFrame.

TYPE: DataFrame

residual_column

The name of the residuals column.

TYPE: str DEFAULT: 'residual'

RETURNS DESCRIPTION
float

The residual sum of squares.