forked from timole/experiment-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze-experiment.py
50 lines (35 loc) · 1.22 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
#!/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
# 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()
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()