Can ML predict where my cat is now — part 1

Predicting where Snowy the cat is likely to be based on time and weather
Predicting where Snowy the cat is likely to be based on time and weather

Summary

With some inexpensive hardware (and a cat ambivalent to data privacy concerns) I wanted to see if I could train a machine learning (ML) model to predict where Snowy would go throughout her day.

Hardware for room level cat tracking

The first task was to collect a lot of data on where Snowy historically spent her time — along with environmental factors such as temperature & rainfall. I set an arbitrary target of collecting hourly updates for around three months of movement in and around the house.

Finding the room Snowy is in relies on a base station in each likely location
Finding the room Snowy is in relies on a base station in each likely location
A collection of ESP32 modules and a BLE Tile (white square)

Hardware for logging environmental information

Snowy avoids the outside garden when it rains, and tends to fall asleep in the warm (but not hot) rooms of the house. I wanted to collect environmental conditions, as I figured temperature and rainfall would play a significant role in determining where Snowy would hang out.

Xiaomi Aqara Temperature and Humidity Sensors

Integration — building a data collection platform

For the data collection platform I used Home Assistant running on a Raspberry Pi. Home Assistant is a free and open-source software for home automation that is designed to be the central control system for smart home devices. I was able to track Snowy’s location via the binary sensor configuration. Essentially the room based beacon receiving the strongest signal from Snowy’s BLE tile updates an MQTT topic with her current location.

Home Assistant display of location
Home Assistant display of temperature and humidity

Data preparation — extracting data from Home Assistant

Home Assistant by default uses a SQLite database with a 10 day retention. I actually wanted to retain a lot more historic data to train the model. By modifying the recorder integration I pushed all the data storage into a Postgres database with 6 months of retention.

Extract of hourly location and environmental readings

What’s next in part 2

This first blog described the the method for locating Snowy and data collection platform. The next blog will describe building the prediction model, and how accurate can a ML model be when determining where a cat is likely to be.

Snowy looking forward to reviewing the confusion matrix

Continue reading part-2

Part 2 is here.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Aubury

Simon Aubury

579 Followers

Day job: data steaming & system architecture. Night gig: IoT and random project hacking