Z-score
Remember, from Chapter 1, Introduction to Data Analysis, that we can also calculate Z-scores and flag IP addresses a given number of standard deviations from the mean. The pct_change_threshold() function we wrote earlier won't help us as is, since we aren't just comparing to the baseline; instead, we need to subtract the baseline for the mean from all the values and divide by the baseline for the standard deviation, so we must rework our approach.
Let's write a new function, z_score_test(), to perform our Z-score tests using any number of standard deviations above the mean as a cutoff. First, we will use the get_baselines() function to calculate the baseline standard deviations by hour with the trimmed data. Then, we join the standard ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access