Professional Documents
Culture Documents
Practical 4
Practical 4
In [7]: #Training
#Getting random values of T1 and T0
rng = np.random.default_rng()
T0 = rng.random()
T1 = rng.random()
In [13]: L = list([])
L.append(Cost_Func)
In [16]: I = np.arange(1,200001)
fig = plt.figure()
fig.set_figheight(8)
fig.set_figwidth(15)
print(plt.xlabel("No.of Iterations"))
print(plt.ylabel("Cost Function"))
print(plt.plot(I, L, 'green', label = 'Given Data-Points'))
print(plt.title("Cost function vs No of Iterations graph"))
print(plt.legend())
TESTING OF MODEL
VALIDATION
Out[17]: array([[-13.59177115],
[ -5.80517009],
[ -6.86950355],
[ -6.81836563],
[ -3.11325366],
[ -5.25082583],
[ 1.23593351],
[ -5.13852289],
[ -2.16244381],
[ -1.0400533 ],
[ 0.28498892],
[ -2.16757206],
[ 0.40910151],
[ -0.56106269],
[ 2.7398552 ],
[ -0.35980004],
[ -1.00859194],
[ 2.30330679],
[ 0.71883761],
[ -0.27529433],
[ 0.95321662],
[ -1.35064909],
[ -0.98156123],
[ -0.93685396],
[ 0.28565731],
[ -3.75777306],
[ -1.71244875],
[ 2.57272828],
[ -2.49999883],
[ -1.48964711],
[ 4.22586393],
[ -1.44070004],
[ -4.49564993],
[ 1.89764518],
[ -0.10660024],
[ 1.55175136],
[ 2.18604392],
[ 0.02335394],
[ 1.68082596],
[ -1.21510401],
[ 2.62841178],
[ 0.98420217],
[ 5.10469175],
[ 1.16962726],
[ -0.74376877],
[ 4.09355893],
[ -2.33906761],
[ 1.79834095],
[ 2.47651704],
[ 2.32324472],
[ -1.09220067],
[ 1.23037536],
[ 1.23486822],
[ 0.73302174],
[ 2.83511361],
[ 5.70977235],
[ 1.71487635],
[ -1.14932414],
[ 3.74782908],
[ 2.46237827],
[ 1.97878161],
localhost:8890/notebooks/CAL201/SUPERVISED LEARNING/LINEAR REGRESSION WITH ONE VARIABLE.ipynb# 11/15
11/2/23, 11:31 PM LINEAR REGRESSION WITH ONE VARIABLE - Jupyter Notebook
[ 3.66390626],
[ 3.6571238 ],
[ 2.14597604],
[ 1.84245769],
[ 0.39969222],
[ 0.78918422],
[ 1.00814497],
[ 2.27492062],
[ -0.49333604]])
VALIDATION GRAPH
TESTING
In [19]: #Testing
h_Test = (T1 * x_Test) + T0
loss_Test = h_Test - y_Test
loss_Test