def METHOD_NAME(group, rtype, indices, df, weight_flag, covariance, fit_sam):
    this_true, this_pred = df['truths'][indices], df['preds'][indices]
    A_matrix_columns = [num for num in df.columns if isinstance(num, (int))]
    A = df[A_matrix_columns].to_numpy()
    this_a = df.iloc[:, 0:A.shape[1]].loc[indices].to_numpy()
    if weight_flag == 'Weighted':
        w = df['weights'].array[indices]
        this_true, this_pred = w * this_true, w * this_pred
        nconfig = np.count_nonzero(w)
    else:
        nconfig = len(this_pred)
    res = this_true - this_pred
    mae = np.sum(np.abs(res) / nconfig)
    ssr = np.square(res).sum()
    mse = ssr / nconfig
    rmse = np.sqrt(mse)
    rsq = 1 - ssr / np.sum(np.square(this_true - (this_true / nconfig).sum()))
    error_record = {
        "Group": group,
        "Weighting": weight_flag,
        "Subsystem": rtype,
        "ncount": nconfig,
        "mae": mae,
        "rmse": rmse,
        "rsq": rsq,
        "residual": res
    }