Root Mean Square Error in Machine Learning|MSE vs RMSE

In this ML Algorithms course tutorial, we are going to learn “Root Mean Square Error in detail. we covered it by practically and theoretical intuition.

  1. What is an error?
  2. What is mean square error (MSE)?
  3. What is Root Mean Square Error (RMSE)?
  4. What is the cost function?
  5. Why need to use it?
  6. How to implement RMSE in python?
root mean square error in machine learning-
# Business Problem - Predict the Price of Bangalore House
#Using Linear Regression - Supervised Machine Learning Algorithm

### Load Libraries
import pandas as pd

"""### Load Data"""

path = r"" 
df = pd.read_csv(path)


"""### Split Data"""

X = df.drop('price', axis=1)
y = df['price']

print('Shape of X = ', X.shape)
print('Shape of y = ', y.shape)

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=51)

print('Shape of X_train = ', X_train.shape)
print('Shape of y_train = ', y_train.shape)
print('Shape of X_test = ', X_test.shape)
print('Shape of y_test = ', y_test.shape)

"""### Feature Scaling"""

from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.transform(X_train)
X_test = sc.transform(X_test)

"""## Linear Regression - ML Model Training"""

from sklearn.linear_model import LinearRegression
lr = LinearRegression(), y_train)



"""## Predict the value of Home and Test"""

X_test[0, :]

lr.predict([X_test[0, :]])



lr.score(X_test, y_test)

"""## Model Evaluation

### Root Mean Squre Error

y_pred = lr.predict(X_test)


from sklearn.metrics import mean_squared_error
import numpy as np

mse = mean_squared_error(y_test, y_pred)
rmse = np.sqrt(mse)

print('MSE = ', mse)
print('RMSE = ', rmse)

One Reply to “Root Mean Square Error in Machine Learning|MSE vs RMSE”

Leave a Reply