Samuel Baguley

Re-learning machine learning: environmental data

03 July 2026

Recently I have been brushing up on my machine learning knowledge – plenty has changed since I learned the basics of neural networks during my PhD. I’ve been doing this in python, via sklearn and PyTorch, which both have satisfyingly good documentation.

I reached a point where I wanted to work with a real dataset and see where my weaknesses lie. For that I chose a dataset called Environmental Sensor Telemetry Data hosted on Kaggle. The data is drawn from three sensors in different locations, which recorded features like humidity, smoke, temperature, carbon monoxide, etc.

Problem 1: Sensor classifier

First, I wrote a neural net classifier to predict which of the three sensors any single data point came from. The first and third sensors were apparently in stable environmental conditions, while the environment of the second was more variable. We might expect to be able to classify the stable sensors more accurately than the variable sensor.

Around half of the data comes from the third sensor, and my classifier was initially predicting that sensor 100% of the time. Not at all what I was hoping for! The solution was to exclude the timestamp feature from the training data; I guessed this wouldn’t be a useful feature for learning, but I hadn’t realised how actively harmful it would be. Here is the classifier’s performance, averaged over 100 random runs.

PredSensor1 PredSensor2 PredSensor3
TrueSensor1 99.92% 0.03% 0.05%
TrueSensor2 8.14% 22.81% 69.05%
TrueSensor3 0% 4.81% 95.19%

It does a decent job on the two stable sensors. As expected, it finds the second (variable) sensor the hardest to classify. Nice!

Problem 2: Predicting temperature

Next, I wrote a to predictor for temperature via linear regression on each sensor independently (ignoring the motion feature).

linear regression

Not horrible, but obviously incomplete, because it totally misses the lower temperatures. Let’s plot temperature against some other features for sensor 1:

features vs temperature

Not remotely linear. No wonder the model had problems! I won’t spend more time on this because I want to find some more interesting data to work with.