-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodelplot.py
54 lines (50 loc) · 1.77 KB
/
modelplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def showPlot(epochs, losses, dataSet, mSet, c):
n = mSet.size + 1
if n == 2:
plt.figure("Multivariate Plot", figsize=(12, 6))
plt.subplot(1, 2, 1)
plt.title("Epochs VS Losses")
plt.plot(epochs, losses)
plt.xlabel('Epochs')
plt.ylabel('Losses')
plt.subplot(1, 2, 2)
plt.title("Linear Regression Plot")
plt.scatter(dataSet[:, 1], dataSet[:, 0])
yPred = np.zeros((dataSet[:, 0].shape))
xGiven = dataSet[:, 1]
for i in range(0, xGiven.size):
yPred[i] = c
yPred[i] = yPred[i] + (xGiven[i] * mSet[0])
plt.plot(dataSet[:, 1], yPred, c="r")
plt.xlabel('X')
plt.ylabel('Y')
elif n == 3:
fig = plt.figure("Multivariate Plot", figsize=(12, 6))
plt.subplot(1, 2, 1)
plt.title("Epochs VS Losses")
plt.plot(epochs, losses)
plt.xlabel('Epochs')
plt.ylabel('Losses')
ax = fig.add_subplot(1, 2, 2, projection='3d')
plt.title("Linear Regression Plot")
data = pd.read_csv("data.csv")
data = data.values
ax.scatter(data[:, 1], data[:, 2],
data[:, 0], c="blue")
yPred = np.zeros((data[:, 0].shape[0]))
xGiven = dataSet[:, 1:]
for i in range(0, yPred.size):
yPred[i] = c
for j in range(0, xGiven.shape[1]):
yPred[i] = yPred[i] + (xGiven[i][j] * mSet[j])
ax.plot3D(data[:, 1], data[:, 2], yPred, c="green")
elif n > 3:
plt.figure("Multivariate Plot", figsize=(6, 6))
plt.title("Epochs VS Losses")
plt.plot(epochs, losses)
plt.xlabel('Epochs')
plt.ylabel('Losses')
plt.show()