Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: scripts/slave/recipe_modules/auto_bisect/resources/significantly_different.py

Issue 1610203003: Iteratively increase sample size for good/bad classification. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Making initial regression check have a timeout. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 """Launches an anaconda environment to run some scipy hypothesis tests."""
2
3 import json
4 import os
5 import subprocess
6 import sys
7
8 CONDA_SCRIPT = """
dtu 2016/02/05 00:18:02 Why not put it in its own Python file?
9 import json
10 import sys
11
12 from scipy import stats
13
14 _, list_a, list_b = sys.argv
15 list_a = json.loads(list_a)
16 list_b = json.loads(list_b)
17
18 shapiro_p_value = stats.shapiro(list_a)[1], stats.shapiro(list_b)[1]
19 mann_whitney_p_value = stats.mannwhitneyu(list_a, list_b).pvalue
20 anderson_p_value = stats.anderson_ksamp([list_a, list_b]).significance_level
21 welch_p_value = stats.ttest_ind(list_a, list_b, equal_var=False)[1]
22
23 results = {
24 'first_sample': list_a,
25 'second_sample': list_b,
26 'shapiro_p_value': shapiro_p_value,
27 'mann_p_value': mann_whitney_p_value,
28 'anderson_p_value': mann_whitney_p_value,
29 'welch_p_value': welch_p_value,
30 }
31
32 print json.dumps(results)
33 sys.exit(0)
34 """
35
36 def main(argv, anaconda_path=None):
37 if not anaconda_path:
38 if os.name == 'nt':
39 anaconda_path = r'c:\conda-py-scientific\bin\python'
40 else:
41 anaconda_path = '/opt/conda-py-scientific/bin/python'
42
43 _, list_a, list_b, significance = argv
44
45 p = subprocess.Popen([anaconda_path, '-', list_a, list_b],
46 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
47 output, _ = p.communicate(input=CONDA_SCRIPT)
48 results = json.loads(output.decode())
49 if (results['shapiro_p_value'][0] < significance and
dtu 2016/02/05 00:18:02 It's strange to mix logic between here and the Ana
50 results['shapiro_p_value'][1] < significance):
51 results['normal-y'] = True
52 else:
53 results['normal-y'] = False
54 results['significantly_different'] = bool(
55 float(results['mann_p_value']) < float(significance))
56
57 return results
58
59 if __name__ == '__main__':
60 result = main(sys.argv)
61 if result:
62 print json.dumps(result, indent=4)
63 sys.exit(0)
64 sys.exit(1)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698