forked from Akash-Tandale001/Power_Theft_Detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisualisation1d.py
74 lines (57 loc) · 2.59 KB
/
Visualisation1d.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
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
def visualisation1D():
rawData1 = pd.read_csv('./visualization.csv', nrows=3) #taking first 3 rows
cols = rawData1.columns
rawData2 = pd.read_csv('./visualization.csv', skiprows=187) #removing first 189 rows
rawData2.columns = cols
data = pd.concat([rawData1, rawData2], ignore_index=True) #ignore_index=True to make row index number
#plot 1D graph for consumer
fig, axs = plt.subplots(2, 1)
fig.suptitle('Consumers With Fraud', fontsize=18)
plt.subplots_adjust(hspace=0.8)
data.loc[0].plot(ax=axs[0], color='firebrick', grid=True)
axs[0].set_title('Consumer 0', fontsize=16)
axs[0].set_xlabel('Dates of Consumption')
axs[0].set_ylabel('Consumption')
data.loc[2].plot(ax=axs[1], color='firebrick', grid=True)
axs[1].set_title('Consumer 1', fontsize=16)
axs[1].set_xlabel('Dates of Consumption')
axs[1].set_ylabel('Consumption')
fig, axs = plt.subplots(2, 1)
fig.suptitle('Consumers Without Fraud', fontsize=18)
plt.subplots_adjust(hspace=0.8)
data.loc[3].plot(ax=axs[0], color='teal', grid=True)
axs[0].set_title('Consumer 40255', fontsize=16)
axs[0].set_xlabel('Dates of Consumption')
axs[0].set_ylabel('Consumption')
data.loc[4].plot(ax=axs[1], color='teal', grid=True)
axs[1].set_title('Consumer 40256', fontsize=16)
axs[1].set_xlabel('Dates of Consumption')
axs[1].set_ylabel('Consumption')
#statistics for consumer
#with fraud
fig2, axs2 = plt.subplots(2, 1)
fig2.suptitle('Statistics for Consumers with Fraud', fontsize=18)
plt.subplots_adjust(hspace=0.8)
data.loc[0].plot(ax=axs2[0], color='firebrick', grid=True)
axs2[0].set_title('Consumption of Consumer 0', fontsize=16)
axs2[0].set_xlabel('Dates of Consumption')
axs2[0].set_ylabel('Consumption')
data.loc[0].plot.kde(color='firebrick', ax=axs2[1], grid=True)
axs2[1].set_title('Density Estimation', fontsize=16)
axs2[1].set_xlabel('Values')
axs2[1].set_ylabel('Density')
#without fraud
fig3, axs3 = plt.subplots(2,1)
fig3.suptitle('Statistics for Consumers without Fraud', fontsize=18)
plt.subplots_adjust(hspace=0.8)
data.loc[4].plot(ax=axs3[0], color='teal', grid=True)
axs3[0].set_title('Consumption of Consumer 40256', fontsize=16)
axs3[0].set_xlabel('Dates of Consumption')
axs3[0].set_ylabel('Consumption')
data.loc[4].plot.kde(color='teal', ax=axs3[1], grid=True)
axs3[1].set_title('Density Estimation', fontsize=16)
axs3[1].set_xlabel('Values')
axs3[1].set_ylabel('Density')