Fixed the different evaluation metrics.

This commit is contained in:
Batuhan Berk Başoğlu 2025-09-29 22:32:43 -04:00
parent 4ed70f6bd4
commit be12360f9a
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
4 changed files with 126 additions and 20 deletions

View file

@ -95,7 +95,10 @@ class LinearRegression:
if self.verbose and epoch % 100 == 0:
y_full_pred = x.dot(w_np)
mse = ((y_np - y_full_pred) ** 2).mean()
print(f"Iter {epoch:5d} | MSE: {mse:.6f}")
mae = float(np.mean(np.abs(y_np - y_full_pred)))
rmse = (((y_np - y_full_pred) ** 2).mean()) ** 0.5
print(f"Iter {epoch:5d} | MSE: {mse:.6f} | MAE: {mae:.6f} | RMSE: {rmse:.6f}")
self.w = pd.Series(w_np, index=x.columns) # store weights back as a pandas series
return self
@ -206,7 +209,7 @@ if __name__ == "__main__":
df = df[(df['Jitter(%)'] >= 0) & (df['Jitter(%)'] <= 10)]
df = df[(df['Shimmer(dB)'] >= 0) & (df['Shimmer(dB)'] <= 10)]
print(f"Rows after sanity checks: {len(df)}")
print(f"Rows after sanity checks: {len(df)}\n")
# check if there are still null values
assert df.isna().sum().sum() == 0, "There are still some null values."