Skip to content

Commit

Permalink
Update R2 method in validation code (#1211)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Mar 19, 2024
1 parent 0a7d2de commit 8f78d5d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Tools/dea_tools/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import pandas as pd
from sklearn.metrics import mean_squared_error
from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score
from math import sqrt
from scipy import stats

Expand Down Expand Up @@ -72,7 +71,7 @@ def eval_metrics(x, y, round=3, all_regress=False):
"Correlation": xy_df.corr().iloc[0, 1],
"RMSE": sqrt(mean_squared_error(xy_df.x, xy_df.y)),
"MAE": mean_absolute_error(xy_df.x, xy_df.y),
"R-squared": r2_score(xy_df.x, xy_df.y),
"R-squared": lin_reg.rvalue**2,
"Bias": (xy_df.y - xy_df.x).mean(),
"Regression slope": lin_reg.slope,
}
Expand All @@ -88,4 +87,4 @@ def eval_metrics(x, y, round=3, all_regress=False):
)

# Return as
return pd.Series(stats_dict).round(round)
return pd.Series(stats_dict).round(round)

0 comments on commit 8f78d5d

Please sign in to comment.