Menu
CoddyTech

Recap: Sensor Glitches

Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 28 of 64.

challenge icon

Challenge

Medium

Remember the box plot's lonely dots? A museum's storage room sensor logs the humidity every 15 minutes into readings, and now and then it glitches.

  1. Print how many readings each rule flags: outside the IQR fences, and z-score beyond 3 either side.
  2. Cap the readings at the IQR fences, then print the mean before and after, rounded to 2 decimals.
  3. Draw box plots side by side, titled Before (the readings) and After (capped), both with the y label Humidity (%).

For another day's log, the program prints:

IQR glitches: 3
Z-score glitches: 2
Mean before: 51.69
Mean after: 51.89

and draws this figure (Coddy then describes yours):

Two box plots side by side. Before: a squashed box near 52 percent with outlier dots at 0, 31.5 and 99.9. After, the capped readings: a full box from about 50.7 to 53.2 with whiskers from about 47 to 57 and no dots

Try it yourself

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

log = pd.read_csv("humidity.csv")
readings = log["humidity"]

# Write your code below

All lessons in Statistics for ML

Practice on your own: Online Python compiler