forked from timole/experiment-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze-experiment.py
62 lines (44 loc) · 1.56 KB
/
analyze-experiment.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
#!/usr/bin/python
import sys, re
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
import data_helper
import analyze_login
import analyze_opportunities
import analyze_polling
import analyze_clicks
# for data preprocessing:
# cat event_dump2.txt | sed 's/[^ ]|/;/g' | sed 's/[ ]*|/|/g' | sed 's/|[ ]*/|/g' | sed 's/^ *//' | grep -v '^[-(]' | grep -v '^$' > event_dump2.csv
def main():
print "----------------------------------------------------"
print "Analyzing experiment data."
print
print "Usage: <inputfile>"
print "----------------------------------------------------"
print
inputFileName = sys.argv[1]
print "Import data from: " + inputFileName
df = data_helper.import_and_clean_data(inputFileName)
describe_data(df)
analyze_login.calculate_direct_and_report_logins(df)
ordata = analyze_opportunities.calculate_ratios(df)
plt.figure()
ordata['or'].plot(kind="hist")
plt.show()
print ''
polltimes = analyze_polling.calc_times(df)
analyze_polling.largescale_values(polltimes)
analyze_polling.show_histogram(polltimes)
analyze_clicks.click_percentages(df)
analyze_clicks.count_reportbased_clicks(df)
analyze_clicks.count_userbased_clicks(df)
def describe_data(df):
# Describe data set
print "Data set starts: {}".format(df['datetime'].min())
print "Data set ends: {}".format(df['datetime'].max())
print
if __name__ == "__main__":
main()