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

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: Fixing multiple problems Created 4 years, 11 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 = """
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)
qyearsley 2016/01/26 19:26:00 Why is it necessary to do this through anaconda? O
RobertoCN 2016/02/01 17:29:51 Added the explanation to the docstring of bisector
47 output, _ = p.communicate(input=CONDA_SCRIPT)
48 results = json.loads(output.decode())
49 if (results['shapiro_p_value'][0] < significance and
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 print json.dumps(results, indent=4)
58
59 if __name__ == '__main__':
60 sys.exit(main(sys.argv))
61
62
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698