.
This commit is contained in:
parent
5d1e5e75c2
commit
f261b06dff
2 changed files with 17 additions and 9 deletions
|
|
@ -101,14 +101,22 @@ class LinearRegression:
|
|||
def rmse(self, x: pd.DataFrame, y: pd.Series) -> float:
|
||||
'''
|
||||
Root Mean Squared Error
|
||||
Square root of MSE, in same units as the target variable
|
||||
More interpretable than MSE while still penalizing larger errors
|
||||
Lower values indicate better performance
|
||||
'''
|
||||
y_hat = self.predict(x)
|
||||
y_true = pd.Series(y).astype('float64')
|
||||
return (((y_true - y_hat) ** 2).mean()) ** 0.5
|
||||
|
||||
def regression_report(self, x: pd.DataFrame, y: pd.Series) -> dict:
|
||||
"""
|
||||
Comprehensive classification report
|
||||
"""
|
||||
return {
|
||||
'R^2': self.score(x, y),
|
||||
'MAE': self.mae(x, y),
|
||||
'MSE': self.mse(x, y),
|
||||
'RMSE': self.rmse(x, y)
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
df = pd.read_csv('parkinsons_updrs.data', dtype=str)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue