-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgraphGenerator.py
80 lines (59 loc) · 1.84 KB
/
graphGenerator.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from pandas import read_csv
from pandas import datetime
import enum
from matplotlib import pyplot
import os
class TrainignTimeType(enum.IntEnum):
ONE_WEEK = 7
ONE_MONTH = 30
'''
PUT HERE THE CONFIGURATION VALUES
'''
trainSize = TrainignTimeType.ONE_WEEK
originFileName = "ukdale_def1.csv"
seriesName = "Datalogger_PC"
algorithm = "Arima"
#Parser for the read_csv
def parser(x):
return datetime.strptime(x, '%y-%m-%d %H:%M:%S')
#Defining the path
finalPath = "results/" + algorithm + "/" + originFileName.split(".")[0] + "/" + seriesName + "/"
predictionPath = finalPath + str(int(trainSize)) + "days_predictions.csv"
testPath = finalPath + str(int(trainSize)) + "days_test.csv"
trainPath = finalPath + str(int(trainSize)) + "days_train.csv"
print("Reconstructing graph for home: \"" + originFileName + "\"")
print("Appliance: \""+seriesName+"\"\n")
pred = None
test = None
train = None
#Loading the series
if os.path.exists(predictionPath):
pred = read_csv(str(predictionPath),header=0,index_col=0)
print("Prediction file found!")
else:
print("Prediction file not found!")
if os.path.exists(testPath):
test = read_csv(str(testPath),header=0,index_col=0)
print("Test file found!")
else:
print("Test file not found!")
if os.path.exists(trainPath):
train = read_csv(str(trainPath),header=0,index_col=0)
print("Train file found!")
else:
print("Train file not found!")
#Showing the graph with matplotlib
print("\nShowing the graph...\n")
pyplot.figure(figsize=(12,5), dpi=100)
#if train is not None:
# pyplot.plot(train, color='blue')
if test is not None:
pyplot.plot(test[:60], color='orange')
if pred is not None:
pyplot.plot(pred[:60], color='red')
day = trainSize / 1440
pyplot.title(seriesName + " " + str(int(trainSize)) + " days trained")
pyplot.xticks(rotation=90)
#ax = pyplot.gca()
#ax.axes.xaxis.set_visible(False)
pyplot.show()