Professional Documents
Culture Documents
AI Lab10
AI Lab10
AI Lab10
Solve the multi variable linear regression problem for the ‘’Marks’’ dataset, use mean
normalization to scale the features. Analyze your model using different learning rates, also provide
a solution in limited number of iterations by observing the cost function.
Solution:
Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import numpy.linalg as LA
from sklearn import metrics
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score
Output:
Figure 1
Figure 2
Discussion:
From above figure1 accuracy for different learning rates is as follow:
There is no such major effect on accuracy by changing the learning rate in this case. Values of theta
are also shown in figure1.
For learning rate = 0.01 relation between cost and iterations is shown is figure2. From the figure we
can analyze that cost function will decrease with each iteration but after 400 iterations it becomes
constant, and there is no such significant decrease in cost function, therefore we don’t need to
perform further iterations and we can terminate our program here.