-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
48 lines (32 loc) · 1.46 KB
/
plot.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
'''
Created on Jan 7, 2014
@author: xorduna
'''
import matplotlib.pyplot as plt
from datetime import datetime
from swissknife import MixSwissKnife
where_clause = 'properties["partner"]=="Satel Spain" or properties["partner"]=="Pointverde" or properties["partner"]=="UPCnet" or properties["partner"]=="PGIGrup" or properties["partner"]=="Optima Group"'
msk = MixSwissKnife(api_key = '3b0436edbe3fdb3eda75083e5d66301c', api_secret = '7dc6dcd26210e8dce661e4db3ec8c741', period_threshold = 2, period = 'day')
features = ['consumption', 'cost', 'dashboard', 'mvp', 'evolution', 'bydevice', 'reports', 'alerts', 'query', 'billing', 'export excel', 'reactive', 'passive']
start = datetime(2014, 1, 1)
end = datetime(2015, 4, 1)
while end > start:
print 'working on ', start, '->', end
if start.month == 12:
next_month = datetime(start.year+1, 1, 1)
else:
next_month = datetime(start.year, start.month+1, 1)
for feature in features:
msk.track_users_feature(feature, start.strftime("%Y-%m-%d"), next_month.strftime("%Y-%m-%d"))
print 'there are ', msk.num_users(), 'qualified users'
plt.xlabel("users")
plt.ylabel("frequency")
#plt.axis([0.0, 100, 0, 100])
for feature in features:
usage, frequency = msk.analyze_feature(feature)
print feature, '--> u:', usage, 'f:', frequency
plt.plot(usage, frequency, 'o')
plt.text(usage + 1, frequency - 0.5, feature)
plt.savefig('sak-'+start.strftime("%Y-%m")+'.png')
plt.clf()
start = next_month