Machine Learning with Measurement Data · Learning Materials
English translation
Topics covered
Create alarms from temperature measurement records and compare prediction errors of a sensor calibration equation.
Overall workflow
Measurements and units → Rules and calibration equations → Compare predictions with reference values → Check input quality
Reading samples, inputs, and reference values
A measurement at one time is one sample. The temperature read by the sensor is the input, and the temperature from a reliable reference sensor is the reference value for comparison with the calibrated result. Using the input unchanged also provides a baseline method for comparison.
| Sensor input [°C] | Reference temperature [°C] |
|---|---|
| 20 | 22.5 |
| 22 | 24.7 |
Rules and prediction models
In the rule that triggers an alarm when temperature > 28°C, a person sets the threshold. The calibration equation y_hat=1.1x+0.5 predicts the reference temperature from input x.
The coefficients are provided here; Experiment 3 covers finding such coefficients from data.
Taking the mean of the absolute differences between predictions and reference values lets you compare error magnitudes. If the error is small, also check new measurements to see whether the equation fits only the original data.
Working in a notebook
Code cells run inputs, calculations, and plots; text cells describe the sensor, units, decision criteria, and observed differences. What matters is whether someone else can readily understand the conditions and results, rather than the number of headings or equations.
Run the cells in order, starting with the input cell. When you change a condition, rerun the relevant results; finally, check that a fresh session gives the same results.
Creating alarms from measurement records
Mark the times when temperatures measured every 5 minutes exceed 28°C. Check that the numerical output and plot show the same conditions.
import numpy as np
import matplotlib.pyplot as plt
minutes=np.array([0,5,10,15,20,25])
temperature=np.array([24.,25.,29.,23.,30.,26.])
threshold=28.
alarm=temperature>threshold
print('alarm times [min]:',minutes[alarm])
print('alarm count:',alarm.sum())
plt.plot(minutes,temperature,'o-',label='measurement')
plt.axhline(threshold,color='gray',linestyle='--',label='threshold')
plt.scatter(minutes[alarm],temperature[alarm],color='red',label='alarm')
plt.xlabel('Time [min]');plt.ylabel('Temperature [deg C]');plt.legend();plt.grid()
alarm times [min]: [10 20] alarm count: 2
Reference example
View more examples