r79149 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79148‎ | r79149 | r79150 >
Date:01:42, 29 December 2010
Author:rfaulk
Status:deferred
Tags:
Comment:
Adding functionality for plot generation of custom campaigns.
Modified paths:
  • /trunk/fundraiser-statistics/bash/plot_build_latest.sh (added) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/mine_impression_request.py (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/run_confidence_plot.py (modified) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/run_plots_campaign.py (added) (history)
  • /trunk/fundraiser-statistics/fundraiser-scripts/squid_miner_script.py (modified) (history)
  • /trunk/fundraiser-statistics/reporting/banner_test_banners.sql (modified) (history)
  • /trunk/fundraiser-statistics/reporting/compare_test.php (modified) (history)
  • /trunk/fundraiser-statistics/reporting/custom_campaign_plot.php (added) (history)
  • /trunk/fundraiser-statistics/reporting/landing_page_test.sql (modified) (history)
  • /trunk/fundraiser-statistics/reporting/reporting_latest.html (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/fundraiser_reporting.py
@@ -48,8 +48,8 @@
4949 def init_db(self):
5050 """ Establish connection """
5151 #db = MySQLdb.connect(host='db10.pmtpa.wmnet', user='rfaulk', db='faulkner')
52 - #self.db = MySQLdb.connect(host='127.0.0.1', user='rfaulk', db='faulkner', port=3307)
53 - self.db = MySQLdb.connect(host='storage3.pmtpa.wmnet', user='rfaulk', db='faulkner')
 52+ self.db = MySQLdb.connect(host='127.0.0.1', user='rfaulk', db='faulkner', port=3307)
 53+ #self.db = MySQLdb.connect(host='storage3.pmtpa.wmnet', user='rfaulk', db='faulkner')
5454
5555 """ Create cursor """
5656 self.cur = self.db.cursor()
@@ -431,6 +431,16 @@
432432
433433 class BannerLPReporting(FundraiserReporting):
434434
 435+
 436+ def __init__(self, *args):
 437+
 438+ if len(args) == 2:
 439+ self.campaign = campaign
 440+ self.start_time = start_time
 441+ else:
 442+ self.campaign = None
 443+ self.start_time = None
 444+
435445 def run_query(self,start_time, end_time, campaign, query_name, metric_name):
436446
437447 self.init_db()
@@ -447,7 +457,7 @@
448458
449459 query_name = 'report_bannerLP_metrics' # rename query to work with query store
450460 sql_stmnt = query_obj.format_query(query_name, sql_stmnt, [start_time, end_time, campaign])
451 - #print sql_stmnt
 461+ # print sql_stmnt
452462 key_index = query_obj.get_banner_index(query_name)
453463 time_index = query_obj.get_time_index(query_name)
454464 metric_index = query_obj.get_metric_index(query_name, metric_name)
@@ -553,9 +563,9 @@
554564
555565 # Current date & time
556566 now = datetime.datetime.now()
557 - #UTC = 8
558 - #delta = datetime.timedelta(hours=UTC)
559 - #now = now + delta
 567+ UTC = 8
 568+ delta = datetime.timedelta(hours=UTC)
 569+ now = now + delta
560570
561571 # ESTABLISH THE START TIME TO PULL ANALYTICS
562572 hours_back = 24
@@ -568,32 +578,57 @@
569579
570580 if type == 'LP':
571581 query_name = 'report_LP_metrics'
572 - campaign = '[0-9](JA|SA|EA)[0-9]'
 582+
 583+ # Set the campaign type - either a regular expression corresponding to a particular campaign or specific campaign
 584+ if self.campaign == None:
 585+ campaign = '[0-9](JA|SA|EA)[0-9]'
 586+ else:
 587+ campaign = self.campaign
 588+
573589 title = metric_name + ': ' + start_time + ' -- ' + end_time
574590 fname = query_name + '_' + metric_name + '.png'
575591 elif type == 'BAN':
576592 query_name = 'report_banner_metrics'
577 - campaign = '[0-9](JA|SA|EA)[0-9]'
 593+
 594+ # Set the campaign type - either a regular expression corresponding to a particular campaign or specific campaign
 595+ if self.campaign == None:
 596+ campaign = '[0-9](JA|SA|EA)[0-9]'
 597+ else:
 598+ campaign = self.campaign
 599+
578600 title = metric_name + ': ' + start_time + ' -- ' + end_time
579601 fname = query_name + '_' + metric_name + '.png'
580602 elif type == 'BAN-TEST':
581603 r = self.get_latest_campaign()
582604 query_name = 'report_banner_metrics'
583 - campaign = r[0]
584 - start_time = r[1]
 605+
 606+ # Set the campaign type - either a regular expression corresponding to a particular campaign or specific campaign
 607+ if self.campaign == None:
 608+ campaign = r[0]
 609+ start_time = r[1]
 610+ else:
 611+ campaign = self.campaign
 612+ start_time = self.start_time
 613+
585614 title = metric_name + ': ' + start_time + ' -- ' + end_time + ', CAMPAIGN =' + campaign
586615 fname = query_name + '_' + metric_name + '_latest' + '.png'
587616 elif type == 'LP-TEST':
588617 r = self.get_latest_campaign()
589618 query_name = 'report_LP_metrics'
590 - campaign = r[0]
591 - start_time = r[1]
 619+
 620+ # Set the campaign type - either a regular expression corresponding to a particular campaign or specific campaign
 621+ if self.campaign == None:
 622+ campaign = r[0]
 623+ start_time = r[1]
 624+ else:
 625+ campaign = self.campaign
 626+ start_time = self.start_time
 627+
592628 title = metric_name + ': ' + start_time + ' -- ' + end_time + ', CAMPAIGN =' + campaign
593629 fname = query_name + '_' + metric_name + '_latest' + '.png'
594630 else:
595631 sys.exit("Invalid type name - must be 'LP' or 'BAN'.")
596632
597 -
598633 return_val = self.run_query(start_time, end_time, campaign, query_name, metric_name)
599634 metrics = return_val[0]
600635 times = return_val[1]
@@ -629,7 +664,7 @@
630665 query_obj = qs.query_store()
631666 sql_stmnt = mh.read_sql('./sql/report_latest_campaign.sql')
632667 sql_stmnt = query_obj.format_query(query_name, sql_stmnt, [times[0]])
633 - print sql_stmnt
 668+
634669 campaign_index = query_obj.get_campaign_index(query_name)
635670 time_index = query_obj.get_time_index(query_name)
636671
@@ -648,7 +683,8 @@
649684 self.close_db()
650685
651686 return [campaign, timestamp]
652 -
 687+
 688+
653689 """
654690
655691 CLASS :: ^ConfidenceReporting^
@@ -659,12 +695,12 @@
660696
661697 class ConfidenceReporting(FundraiserReporting):
662698
663 - def __init__(self, query_name, cmpgn1, cmpgn2, item_1, item_2, start_time , end_time, metric):
 699+ def __init__(self, query_name, cmpgn_1, cmpgn_2, item_1, item_2, start_time , end_time, metric):
664700 self.query_name = query_name
665 - self.cmpgn1 = cmpgn1
666 - self.cmpgn2 = cmpgn2
667 - self.item1 = item1
668 - self.item2 = item2
 701+ self.cmpgn_1 = cmpgn_1
 702+ self.cmpgn_2 = cmpgn_2
 703+ self.item_1 = item_1
 704+ self.item_2 = item_2
669705 self.start_time = start_time
670706 self.end_time = end_time
671707 self.metric = metric
@@ -683,8 +719,7 @@
684720 filename = './sql/' + self.query_name + '.sql'
685721 sql_stmnt = mh.read_sql(filename)
686722
687 - query_name = 'report_bannerLP_metrics' # rename query to work with query store
688 - sql_stmnt = query_obj.format_query(self.query_name, sql_stmnt, [self.start_time, self.end_time, self.cmpgn1, self.item1])
 723+ sql_stmnt = query_obj.format_query(self.query_name, sql_stmnt, [self.start_time, self.end_time, self.cmpgn_1, self.item_1])
689724
690725 time_index = query_obj.get_time_index(query_name)
691726 metric_index = query_obj.get_metric_index(query_name, metric_name)
Index: trunk/fundraiser-statistics/fundraiser-scripts/squid_miner_script.py
@@ -56,9 +56,9 @@
5757 """
5858
5959 """ Establish connection """
60 -#db = MySQLdb.connect(host='localhost', user='root', passwd='baggin5', db='faulkner')
 60+db = MySQLdb.connect(host='localhost', user='root', passwd='baggin5', db='faulkner')
6161 # db = MySQLdb.connect(host='db10.pmtpa.wmnet', user='rfaulk', db='faulkner')
62 -db = MySQLdb.connect(host='storage3.pmtpa.wmnet', user='rfaulk', db='faulkner')
 62+#db = MySQLdb.connect(host='storage3.pmtpa.wmnet', user='rfaulk', db='faulkner')
6363
6464 """ Create cursor """
6565 cur = db.cursor()
Index: trunk/fundraiser-statistics/fundraiser-scripts/mine_impression_request.py
@@ -58,7 +58,7 @@
5959
6060 try:
6161 # cur.execute(deleteStmnt)
62 - print >> sys.stdout, "Executed delete from landing page: " + deleteStmnt
 62+ print >> sys.stdout, "Executed delete from impression: " + deleteStmnt
6363 except:
6464 print >> sys.stderr, "Could not execute delete:\n" + deleteStmnt + "\nResuming insert ..."
6565 pass
Index: trunk/fundraiser-statistics/fundraiser-scripts/run_confidence_plot.py
@@ -13,6 +13,7 @@
1414
1515 """
1616
 17+import sys
1718 import fundraiser_reporting as fr
1819
1920
@@ -30,7 +31,6 @@
3132 except IndexError:
3233 sys.exit('Invalid command args.\n')
3334
34 -query = sql_filename.split('.')[0]
35 -r = fr.ConfidenceReporting(query, cmpgn1, cmpgn2, item_1, item_2, start_time , end_time, metric)
 35+r = fr.ConfidenceReporting(type, cmpgn1, cmpgn2, item_1, item_2, start_time , end_time, metric)
3636
3737 r.run()
\ No newline at end of file
Index: trunk/fundraiser-statistics/fundraiser-scripts/run_plots_campaign.py
@@ -0,0 +1,35 @@
 2+
 3+"""
 4+
 5+run_plots_campaign.py
 6+
 7+wikimediafoundation.org
 8+Ryan Faulkner
 9+December 28th, 2010
 10+
 11+
 12+Pulls data from storage3.faulkner and generates plots for campaigns.
 13+
 14+
 15+"""
 16+
 17+import sys
 18+import fundraiser_reporting as fa
 19+
 20+
 21+# cmd args -- Get the utm_campaign
 22+
 23+
 24+try:
 25+ campaign = sys.argv[1]
 26+ start_time = sys.argv[2]
 27+except IndexError:
 28+ sys.exit('Invalid command args.\n')
 29+
 30+blpr = fa.BannerLPReporting(campaign, start_time)
 31+
 32+# Run the banner/lp plots
 33+blpr.run('LP-TEST', 'don_per_view')
 34+blpr.run('BAN-TEST', 'don_per_imp')
 35+blpr.run('BAN-TEST', 'click_rate')
 36+
Index: trunk/fundraiser-statistics/reporting/reporting_latest.html
@@ -32,27 +32,53 @@
3333
3434
3535 <p>
36 -This page will be used for graphical reporting of fundraiserrelated data for the latest tests.
 36+This page will be used for graphical reporting of fundraiser related data for the latest tests.
3737 </p>
3838 <br>
3939
 40+<p>
 41+Is the campaign data missing? Enter a campaign manually.
 42+</p>
 43+<form action="custom_campaign_plot.php" method="post">
 44+<label for="utm_campaign">
 45+<pre>UTM CAMPAIGN: </pre>
 46+</label>
 47+<input type="text" name="utm_campaign" />
 48+<br/>
 49+<br/>
 50+<label for="start_time">
 51+<pre>START TIMESTAMP: </pre>
 52+</label>
 53+ <input type="text" name="start_time" />
 54+<br/>
 55+<br/>
 56+<label for="pwd">
 57+<pre>Key: </pre>
 58+</label>
 59+<input type="password" name="pwd" size="20">
 60+<br/>
 61+<input type="submit" value="Generate Plots">
 62+</form>
 63+
 64+<br>
 65+
4066 <h3><u>Banners Donations Per Impression</u></h3>
4167 <OBJECT WIDTH="1600" HEIGHT="800" data="report_banner_metrics_don_per_imp_latest.png" type="image/png">
42 -<p>Total donation amounts over a given period.</p>
 68+<!-- <p>Total donation amounts over a given period.</p> -->
4369 </OBJECT>
4470
4571 <br>
4672
4773 <h3><u>Landing Pages Donations Per View</u></h3>
4874 <OBJECT WIDTH="1600" HEIGHT="800" data="report_LP_metrics_don_per_view_latest.png" type="image/png">
49 -<p>Total donation amounts over a given period.</p>
 75+<!-- <p>Total donation amounts over a given period.</p> -->
5076 </OBJECT>
5177
5278 <br>
5379
54 -<h3><u>Landing Pages Donations Per View</u></h3>
 80+<h3><u>Banner Click Rate</u></h3>
5581 <OBJECT WIDTH="1600" HEIGHT="800" data="report_banner_metrics_click_rate_latest.png" type="image/png">
56 -<p>Total donation amounts over a given period.</p>
 82+<!-- <p>Click rate of the latest test.</p> -->
5783 </OBJECT>
5884
5985 <br>
Index: trunk/fundraiser-statistics/reporting/custom_campaign_plot.php
@@ -0,0 +1,67 @@
 2+<?
 3+
 4+/*
 5+ Ryan Faulkner
 6+ Wikimedia Foundation
 7+ 2010
 8+*/
 9+
 10+
 11+// Authenticate form
 12+$pwd_key=$_POST["pwd"];
 13+
 14+if ($pwd_key != "angelface") {
 15+ $message = "Invalid Key.\n";
 16+ die($message);
 17+}
 18+
 19+// CONNECT TO FAULKNER STORAGE3
 20+$link = mysql_connect('storage3.pmtpa.wmnet', 'rfaulk');
 21+
 22+if (!$link) {
 23+ die('Could not connect: ' . mysql_error());
 24+}
 25+
 26+$db_selected = mysql_select_db('faulkner', $link);
 27+if (!$db_selected) {
 28+ die ('Can\'t use faulkner : ' . mysql_error());
 29+}
 30+
 31+$query = file_get_contents ($sql_file);
 32+
 33+// get the campaign and the start time
 34+$start=$_POST["start_time"];
 35+$cmpgn=$_POST["utm_campaign"];
 36+
 37+// generate plots
 38+$home_path = './plot_build_latest.sh';
 39+$cmd_arr = array();
 40+$args = ' ' . $cmpgn . ' ' . $start;
 41+$cmd = 'sh plot_build_latest.sh' . $args;
 42+
 43+
 44+chdir('/home/rfaulk/fundraiser-statistics/bash/');
 45+// $output= shell_exec($cmd);
 46+
 47+// Execute the shell command
 48+$output = shell_exec($cmd);
 49+
 50+echo '<html>';
 51+echo '<head>';
 52+echo '<title>Wikimedia Fundraiser Reporting</title>';
 53+echo '</head>';
 54+echo '<body>';
 55+
 56+echo $cmd . '<br>';
 57+echo $output . '<br>';
 58+echo 'Plots are generating, results will be up momentarily.<br>';
 59+echo '<a href="http://fundraising.wikimedia.org/stats/reporting_latest.html">Back to latest Reports</a><br>';
 60+
 61+echo '</body>';
 62+echo '</html>';
 63+
 64+?>
 65+
 66+
 67+
 68+
Index: trunk/fundraiser-statistics/reporting/landing_page_test.sql
@@ -8,9 +8,11 @@
99 total_clicks as clicks,
1010 donations as donations,
1111 amount as amount,
 12+amount50 as amount50,
1213 donations / total_clicks as completion_rate,
1314 donations / views as don_per_view,
1415 amount / views as amt_per_view,
 16+amount50 / views as amt50_per_view,
1517 modified_amount / views as amt_per_view_reduced,
1618 max_amt,
1719 pp_don,
@@ -40,6 +42,7 @@
4143 count(*) as total_clicks,
4244 sum(not isnull(contribution_tracking.contribution_id)) as donations,
4345 sum(converted_amount) AS amount,
 46+sum(if(converted_amount > 50, 50, converted_amount)) as amount50,
4447 sum(if(converted_amount > 100, 100, converted_amount)) AS modified_amount, -- truncates donations over 100
4548 max(converted_amount) AS max_amt,
4649 sum(if(right(utm_source,2)='cc',1,0)) as cc_clicks,
Index: trunk/fundraiser-statistics/reporting/banner_test_banners.sql
@@ -8,14 +8,16 @@
99 total_clicks as clicks,
1010 donations as donations,
1111 amount as amount,
 12+amount50 as amount50,
1213 views / impressions as click_rate,
1314 donations / total_clicks as conversion_rate,
1415 round(donations / impressions,6) as don_per_imp,
1516 amount / impressions as amt_per_imp,
 17+amount50 / impressions as amt50_per_imp,
1618 donations / views as don_per_view,
17 -amount / views as amt_per_view
 19+amount / views as amt_per_view,
 20+amount50 / views as amt50_per_view
1821
19 -
2022 from
2123
2224 (select
@@ -50,7 +52,8 @@
5153 utm_campaign,
5254 count(*) as total_clicks,
5355 sum(not isnull(contribution_tracking.contribution_id)) as donations,
54 -sum(converted_amount) AS amount
 56+sum(converted_amount) AS amount,
 57+sum(if(converted_amount > 50, 50, converted_amount)) as amount50
5558 from
5659 drupal.contribution_tracking LEFT JOIN civicrm.public_reporting
5760 ON (contribution_tracking.contribution_id = civicrm.public_reporting.contribution_id)
Index: trunk/fundraiser-statistics/reporting/compare_test.php
@@ -18,14 +18,14 @@
1919 $link = mysql_connect('storage3.pmtpa.wmnet', 'rfaulk');
2020
2121 if (!$link) {
22 - die('Could not connect: ' . mysql_error());
 22+ die('Could not connect: ' . mysql_error());
2323 }
2424
2525 // echo 'Connected successfully<br>';
2626
2727 $db_selected = mysql_select_db('faulkner', $link);
2828 if (!$db_selected) {
29 - die ('Can\'t use faulkner : ' . mysql_error());
 29+ die ('Can\'t use faulkner : ' . mysql_error());
3030 }
3131
3232 $sql_file=$_POST["sqlFile"];
@@ -44,7 +44,7 @@
4545 $query='';
4646 for ( $counter = 0; $counter < count($query_parts); $counter += 1)
4747 {
48 - $query=$query.$query_parts[$counter];
 48+ $query=$query.$query_parts[$counter];
4949 }
5050
5151 // Format the query based on the type
@@ -69,101 +69,166 @@
7070 }
7171
7272
73 -// Compute the mean and standard deviation of the results
74 -$m1= 0;
75 -$m2= 0;
 73+/* Compute the mean and standard deviation of the results */
7674 $n1 = 0;
7775 $n2 = 0;
 76+$m1= array();
 77+$m2= array();
 78+$interval = 6;
7879
7980 // These will store the table values
8081 $time = array();
8182 $metric1 = array();
8283 $metric2 = array();
8384
84 -// Means
 85+// Compute the means of the first item
 86+$counter = 0;
 87+$index = 0;
8588 while ($row = mysql_fetch_assoc($result1)) {
8689
87 - $time[$n1] = $row["day_hr"];
88 - $metric1[$n1] = $row[$metric];
89 -
90 - $x1 = $row[$metric];
91 - $group1[$n] = $x1;
92 - $m1 = $x1 + $m1;
93 - $n1=$n1+1;
 90+ $time[$n1] = $row["day_hr"];
 91+ $metric1[$n1] = $row[$metric];
 92+
 93+ $x1 = $row[$metric];
 94+ $group1[$n] = $x1;
 95+ $m1[$index] = $x1 + $m1[$index];
 96+ $n1=$n1+1;
 97+
 98+ if ($counter < $interval) {
 99+ $counter = $counter + 1;
 100+ } else {
 101+ $index = $index + 1;
 102+ $counter = 0;
 103+ }
94104 }
95105
 106+// Compute the means of the second item
 107+$counter = 0;
 108+$index = 0;
96109 while ($row = mysql_fetch_assoc($result2)) {
97 - $metric2[$n2] = $row[$metric];
98 -
99 - $x2 = $row[$metric];
100 - $group2[$n] = $x2;
101 - $m2 = $x2 + $m2;
102 - $n2=$n2+1;
 110+ $metric2[$n2] = $row[$metric];
 111+
 112+ $x2 = $row[$metric];
 113+ $group2[$n] = $x2;
 114+ $m2[$index] = $x2 + $m2[$index];
 115+ $n2=$n2+1;
 116+
 117+ if ($counter < $interval) {
 118+ $counter += 1;
 119+ } else {
 120+ $index = $index + 1;
 121+ $counter = 0;
 122+ }
103123 }
104124
105125 $n = $n1;
106 -$m1= $m1/$n;
107 -$m2= $m2/$n;
108 -$v1 = 0;
109 -$v2 = 0;
110126
111 -// Variance
 127+// Normalize means
 128+for ( $i = 0; $i < count($m1); $i += 1) {
 129+ $m1[$i] = $m1[$i] / $interval;
 130+ $m2[$i] = $m2[$i] / $interval;
 131+}
 132+
 133+$v1 = array();
 134+$v2 = array();
 135+
 136+// Compute variance for both groups
112137 for ( $counter = 0; $counter < $n; $counter += 1)
 138+{
 139+ $index = floor($counter / $interval);
 140+
 141+ $diff1 = $group1[$counter] - $m1[$index];
 142+ $diff2 = $group2[$counter] - $m2[$index];
 143+ $v1[$index] = $v1[$index] + pow($diff1,2);
 144+ $v2[$index] = $v2[$index] + pow($diff2,2);
 145+
 146+}
 147+
 148+// Normalize variances
 149+for ( $i = 0; $i < count($v1); $i += 1) {
 150+ $v1[$i] = $v1[$i] / $interval;
 151+ $v2[$i] = $v2[$i] / $interval;
 152+}
 153+
 154+
 155+// Compute W values for each test hour
 156+$W = array();
 157+for ( $i = 0; $i < count($v1); $i += 1)
113158 {
114 - $diff1 = $group1[$counter] - $m1;
115 - $diff2 = $group2[$counter] - $m2;
116 - $v1 = $v1 + pow($diff1,2);
117 - $v2 = $v2 + pow($diff2,2);
 159+ $W[$i] = abs($m1[$i] - $m2[$i]) / pow(($v1[$i] + $v2[$i]) ,0.5);
118160 }
119161
120 -$v1=$v1/$n;
121 -$v2=$v2/$n;
122162
123163 // Student's t test
124 -$t = ($m1 - $m2) / pow(($v1 + $v2) / $n, 0.5);
125 -$df = pow(($v1+$v2)/$n,2) / ((pow($v1/$n,2)/($n-1)) + (pow($v2/$n,2)/($n-1)));
 164+// $t = ($m1 - $m2) / pow(($v1 + $v2) / $n, 0.5);
 165+// $df = pow(($v1+$v2)/$n,2) / ((pow($v1/$n,2)/($n-1)) + (pow($v2/$n,2)/($n-1)));
126166
127167 // Wald test test
128 -$W = abs($m1 - $m2) / pow(($v1 + $v2) ,0.5);
 168+// $W = abs($m1 - $m2) / pow(($v1 + $v2) ,0.5);
129169
130170 echo '<h2> Test Analysis: </h2></br>';
131171
132 -echo 'Average ' . $metric . ' for ' . $item1 .' = '.$m1.'<br>';
133 -echo 'Average ' . $metric . ' for ' . $item2 .' = '.$m2.'<br><br>';
134 -echo 'The Wald test value is: ' . $W . '<br>';
 172+// echo 'Average ' . $metric . ' for ' . $item1 .' = '.$m1.'<br>';
 173+// echo 'Average ' . $metric . ' for ' . $item2 .' = '.$m2.'<br><br>';
 174+// echo 'The Wald test value is: ' . $W . '<br>';
135175 // echo 'sample variance of group 1 '.$v1.'<br>';
136176 // echo 'sample variance of group 2 '.$v2.'<br>';
137177
138 -if ($W >= 0.1) {
139 -echo '<br>8% confident about the winner.<br>';
140 -} elseif ($W >= 0.2) {
141 -echo '<br>16% confident about the winner.<br>';
142 -} elseif ($W >= 0.3) {
143 -echo '<br>24% confident about the winner.<br>';
144 -} elseif ($W >= 0.4) {
145 -echo '<br>31% confident about the winner.<br>';
146 -} elseif ($W >= 0.5) {
147 -echo '<br>38% confident about the winner.<br>';
148 -} elseif ($W >= 0.6) {
149 -echo '<br>45% confident about the winner.<br>';
150 -} elseif ($W >= 0.7) {
151 -echo '<br>52% confident about the winner.<br>';
152 -} elseif ($W >= 0.8) {
153 -echo '<br>63% confident about the winner.<br>';
154 -} elseif ($W >= 0.9) {
155 -echo '<br>68% confident about the winner.<br>';
156 -} elseif ($W >= 1.0) {
157 -echo '<br>73% confident about the winner.<br>';
158 -} elseif ($W >= 1.3) {
159 -echo '<br>81% confident about the winner.<br>';
160 -} elseif ($W >= 1.6) {
161 -echo '<br>89% confident about the winner.<br>';
162 -} elseif ($W >= 1.9) {
163 -echo '<br>95% confident about the winner.<br>';
164 -} else {
165 -echo '<br>There is no clear winner.<br>';
 178+$P = 1;
 179+for ( $i = 0; $i < count($m1); $i += 1) {
 180+
 181+ echo 'The average of Group 1 for hour ' . ($i + 1). ': ' . $m1[$i] . '<br>';
 182+ echo 'The average of Group 2 for hour ' . ($i + 1). ': ' . $m2[$i] . '<br>';
 183+
 184+ if ($W[$i] >= 0.1) {
 185+ echo '<br>8% confident about the winner.<br>';
 186+ $P *= 0.08;
 187+ } elseif ($W[$i] >= 0.2) {
 188+ echo '<br>16% confident about the winner.<br>';
 189+ $P *= 0.16;
 190+ } elseif ($W[$i] >= 0.3) {
 191+ echo '<br>24% confident about the winner.<br>';
 192+ $P *= 0.24;
 193+ } elseif ($W[$i] >= 0.4) {
 194+ echo '<br>31% confident about the winner.<br>';
 195+ $P *= 0.31;
 196+ } elseif ($W[$i] >= 0.5) {
 197+ echo '<br>38% confident about the winner.<br>';
 198+ $P *= 0.38;
 199+ } elseif ($W[$i] >= 0.6) {
 200+ echo '<br>45% confident about the winner.<br>';
 201+ $P *= 0.45;
 202+ } elseif ($W[$i] >= 0.7) {
 203+ echo '<br>52% confident about the winner.<br>';
 204+ $P *= 0.52;
 205+ } elseif ($W[$i] >= 0.8) {
 206+ echo '<br>63% confident about the winner.<br>';
 207+ $P *= 0.63;
 208+ } elseif ($W[$i] >= 0.9) {
 209+ echo '<br>68% confident about the winner.<br>';
 210+ $P *= 0.68;
 211+ } elseif ($W[$i] >= 1.0) {
 212+ echo '<br>73% confident about the winner.<br>';
 213+ $P *= 0.73;
 214+ } elseif ($W[$i] >= 1.3) {
 215+ echo '<br>81% confident about the winner.<br>';
 216+ $P *= 0.81;
 217+ } elseif ($W[$i] >= 1.6) {
 218+ echo '<br>89% confident about the winner.<br>';
 219+ $P *= 0.89;
 220+ } elseif ($W[$i] >= 1.9) {
 221+ echo '<br>95% confident about the winner.<br>';
 222+ $P *= 0.95;
 223+ } else {
 224+ echo '<br>There is no clear winner.<br>';
 225+ $P *= 0.08;
 226+ }
 227+
 228+ echo '<br>';
166229 }
167230
 231+echo '<br>Overall there is ' . ($P * 100) . '% confidence on the winner.<br>';
 232+
168233 // Build Table of data
169234
170235 echo "</br></br><table width='50%'><tr>";
@@ -203,6 +268,11 @@
204269
205270
206271 $script_args = $type . ' ' . $cmpgn1 . ' ' . $cmpgn2 . ' ' . $item1 . ' ' . $item2 . ' ' . $start . ' ' . $end . ' ' . $metric_index;
207 -$retval = system($home_path . 'python run_confidfence_plots.py '. $script_args , $retval);
 272+$cmd_output = ' 1>./plotrun_out.txt';
 273+echo 'python ' . $home_path . 'run_confidence_plot.py '. $script_args . $cmd_output;
 274+$retval1 = system('python ' . $home_path . 'run_confidence_plot.py '. $script_args . $cmd_output, $retval2);
208275
 276+echo '<br>' .$retval1. '<br>';
 277+echo $retval2;
 278+
209279 ?>
\ No newline at end of file
Index: trunk/fundraiser-statistics/bash/plot_build_latest.sh
@@ -0,0 +1,13 @@
 2+#!/bin/bash
 3+
 4+cd /home/rfaulk/fundraiser-statistics/fundraiser-scripts
 5+
 6+# get date from command line args
 7+campaign=$1
 8+start_time=$2
 9+
 10+python run_plots_campaign.py $campaign $start_time
 11+
 12+cp /home/rfaulk/fundraiser-statistics/fundraiser-scripts/report_LP_metrics_don_per_view_latest.png /srv/org.wikimedia.fundraising/stats/
 13+cp /home/rfaulk/fundraiser-statistics/fundraiser-scripts/report_banner_metrics_don_per_imp_latest.png /srv/org.wikimedia.fundraising/stats/
 14+cp /home/rfaulk/fundraiser-statistics/fundraiser-scripts/report_banner_metrics_click_rate_latest.png /srv/org.wikimedia.fundraising/stats/
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r79279Merging from r79149 through r79270 of headawjrichards17:54, 30 December 2010

Status & tagging log