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

Side by Side Diff: scripts/slave/recipe_modules/auto_bisect/resources/significantly_different_inner.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: Rebasing 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 """This file is meant to be run in an environment where scipy is available."""
2 import json
3 import logging
4 import sys
5
6 try:
7 from scipy import stats
8 except ImportError:
9 def main():
10 # scipy required, see module docstring.
11 logging.warning(sys.modules[__name__].__doc__)
12 return 1
13 else:
14
15 def main():
16 if len(sys.argv) < 4:
17 return 1
18 _, list_a, list_b, significance = sys.argv[:4]
19 list_a = json.loads(list_a)
20 list_b = json.loads(list_b)
21 significance = float(significance)
22
23 shapiro_p_value = stats.shapiro(list_a)[1], stats.shapiro(list_b)[1]
24 mann_whitney_p_value = stats.mannwhitneyu(list_a, list_b).pvalue
25 anderson_p_value = stats.anderson_ksamp([list_a, list_b]).significance_level
26 welch_p_value = stats.ttest_ind(list_a, list_b, equal_var=False)[1]
27
28 results = {
29 'first_sample': list_a,
30 'second_sample': list_b,
31 'shapiro_p_value': shapiro_p_value,
32 'mann_p_value': mann_whitney_p_value,
33 'anderson_p_value': anderson_p_value,
34 'welch_p_value': welch_p_value,
35 }
36
37 if (results['shapiro_p_value'][0] < significance and
38 results['shapiro_p_value'][1] < significance):
39 results['normal-y'] = True
40 else:
41 results['normal-y'] = False
42 results['significantly_different'] = bool(
43 float(results['mann_p_value']) < float(significance))
44
45 print json.dumps(results)
46 return 0
47
48 if __name__ == '__main__':
49 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698