Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail experiment on large std #308

Merged
merged 1 commit into from
Apr 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions scripts/post_process_historical_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import csv
import json
import os
import sys
import numpy as np


Expand Down Expand Up @@ -79,20 +78,20 @@ def __init__(self,

def process(self, n_stats=5, n_std=3):
"""
Process the current and historical dropped statistics, exit 1 when a large deviation is detected.
Process the current and historical dropped statistics.
:param n_stats: The number of historical values to keep
:param n_std: The latest value must be within n_std standard deviations of the historical mean for this function
to exit successfully.
"""
# write the current data if we don't have old data
if not os.path.exists(self._dropped_stats_json):
print(self._dropped_stats_json + " does not exist, trying to create it")
print self._dropped_stats_json + " does not exist, trying to create it"
mkdir_for_file(self._dropped_stats_json)
with open(self._dropped_stats_json, 'w') as f:
json.dump([self._compute_stats()], f)
return
else:
print(self._dropped_stats_json + " exists, proceeding")
print self._dropped_stats_json + " exists, proceeding"

# we update the historical json with the latest statistics
combined = self._combine_stats(n_stats)
Expand All @@ -107,8 +106,8 @@ def process(self, n_stats=5, n_std=3):
combined_avg = [x['average'] for x in combined]
large_deviation, mean, std = has_large_deviation(combined_avg[0], combined_avg[1:], n_std)
if large_deviation:
sys.stderr.write("large deviation detected, mean: " + str(mean) + ", std: " + str(std))
exit(1)
print "large deviation detected, new_value: {}, mean: {}, n_std: {}, std: {}"\
.format(combined_avg[0], mean, n_std, std)

def _combine_stats(self, n):
stats = self._get_stats()
Expand Down