From 1cd1f8c047bce4b8d7225ddf49e940ae79780555 Mon Sep 17 00:00:00 2001 From: "Bhanushri.chinta" <161404554+bhanushri12@users.noreply.github.com> Date: Thu, 30 May 2024 23:07:35 +0530 Subject: [PATCH 1/3] Add files via upload --- ML/Algorithms/Losses/root_mean_squared_error.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 ML/Algorithms/Losses/root_mean_squared_error.py diff --git a/ML/Algorithms/Losses/root_mean_squared_error.py b/ML/Algorithms/Losses/root_mean_squared_error.py new file mode 100644 index 0000000..db2e566 --- /dev/null +++ b/ML/Algorithms/Losses/root_mean_squared_error.py @@ -0,0 +1,16 @@ +import numpy as np +import math as mt + +def root_mean_squared_error(y_true,y_pred): + """ + Calculate the root mean squared error between true and predicted values. + + Parameters: + - y_true: True target values (numpy array). + - y_pred: Predicted values (numpy array). + + Returns: + - Root Mean squared error (float). + """ + return mt.sqrt(np.mean((y_true - y_pred) ** 2)) + From e070c6150ca50c6972ef67423179fb4ae90bc0c1 Mon Sep 17 00:00:00 2001 From: "Bhanushri.chinta" <161404554+bhanushri12@users.noreply.github.com> Date: Thu, 30 May 2024 23:07:57 +0530 Subject: [PATCH 2/3] Add files via upload --- ML/Algorithms/Losses/mean_absolute_error.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ML/Algorithms/Losses/mean_absolute_error.py diff --git a/ML/Algorithms/Losses/mean_absolute_error.py b/ML/Algorithms/Losses/mean_absolute_error.py new file mode 100644 index 0000000..30112db --- /dev/null +++ b/ML/Algorithms/Losses/mean_absolute_error.py @@ -0,0 +1,15 @@ +# Algorithms/Losses/mean_squared_error.py +import numpy as np + +def mean_absolute_error(y_true, y_pred): + """ + Calculate the mean absolute error between true and predicted values. + + Parameters: + - y_true: True target values (numpy array). + - y_pred: Predicted values (numpy array). + + Returns: + - Mean absolute error (float). + """ + return (np.absolute(y_true - y_pred)).mean() \ No newline at end of file From 48c082cab8b1f52d41ec51f99c025bc84f6be2d7 Mon Sep 17 00:00:00 2001 From: "Bhanushri.chinta" <161404554+bhanushri12@users.noreply.github.com> Date: Thu, 13 Jun 2024 06:27:58 +0530 Subject: [PATCH 3/3] losses --- .../MeanAbsoluteError.py} | 0 .../RootMeanSquaredError.py} | 0 ML/README.md | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename ML/Algorithms/Losses/{mean_absolute_error.py => MeanAbsoluteError/MeanAbsoluteError.py} (100%) rename ML/Algorithms/Losses/{root_mean_squared_error.py => RootMeanSquaredError/RootMeanSquaredError.py} (100%) diff --git a/ML/Algorithms/Losses/mean_absolute_error.py b/ML/Algorithms/Losses/MeanAbsoluteError/MeanAbsoluteError.py similarity index 100% rename from ML/Algorithms/Losses/mean_absolute_error.py rename to ML/Algorithms/Losses/MeanAbsoluteError/MeanAbsoluteError.py diff --git a/ML/Algorithms/Losses/root_mean_squared_error.py b/ML/Algorithms/Losses/RootMeanSquaredError/RootMeanSquaredError.py similarity index 100% rename from ML/Algorithms/Losses/root_mean_squared_error.py rename to ML/Algorithms/Losses/RootMeanSquaredError/RootMeanSquaredError.py diff --git a/ML/README.md b/ML/README.md index b4a43b9..41c79f2 100644 --- a/ML/README.md +++ b/ML/README.md @@ -19,8 +19,8 @@ | S.No | Algorithm | S.No. | Algorithm | S.No. | Algorithm | |-------|-----------|-------|-----------|-------|-----------| -| 1 | [Mean Squared Error](./Algorithms/Losses/MeanSquaredError) | 2 | [R2 Squared](./Algorithms/Losses/R2Squared) | 3 | | -| 4 | | 5 | | 6 | | +| 1 | [Mean Squared Error](./Algorithms/Losses/MeanSquaredError) | 2 | [R2 Squared](./Algorithms/Losses/R2Squared) | 3 |[Mean Absolute Error](./Algorithms/Losses/MeanAbsoluteError) | +| 4 | [Root Mean Squared Error](./Algorithms/Losses/RootMeanSquaredError) | 5 | | 6 | | ## Available Documentations