-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__main__.py
50 lines (43 loc) · 1.37 KB
/
__main__.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
import datagen
import modelgen as mgen
import modelplot as mplt
import pandas
import numpy as np
def main():
nD = 3
xDataLowerLimit = 10
xDataUpperLimit = 15
mDataLowerLimit = 5
mDataUpperLimit = 8
epoch = 200
datagen.gen_data(nD, xDataLowerLimit, xDataUpperLimit,
mDataLowerLimit, mDataUpperLimit, epoch)
pr = pandas.read_csv("data.csv")
print("\nNumber of Data Points : ", epoch)
print("Training Set : ", epoch - 15)
print("Testing Set : ", 15)
print("\n")
mSet = mgen.traindata(
pr.values[:epoch - 15, 1:], pr.values[:epoch - 15, 0], 0.0001)
c = mSet[1]
epochs = mSet[2]
losses = mSet[3]
mSet = mSet[0]
nTrain = epoch - 15
xSetTest = pr.values[nTrain + 1:, 1:]
ySetTest = pr.values[nTrain + 1:, 0]
if xSetTest.shape[1] > 1:
xSetTest = mgen.normalize(xSetTest)
yPredTest = np.zeros((ySetTest.shape))
for i in range(len(xSetTest)):
yPredTest[i] = c
for j in range(xSetTest.shape[1]):
yPredTest[i] = yPredTest[i] + (xSetTest[i][j] * mSet[j])
# print(ySetTest[i], yPredTest[i])
header_data = {"Y (Actual)": ySetTest, "Y (Predicted)": yPredTest}
df = pandas.DataFrame(header_data)
print("\n")
print(df.to_string(index=False))
mplt.showPlot(epochs, losses, pr.values, mSet, c)
if __name__ == '__main__':
main()