esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Machine Learning Foundations / Beginner / 01.44

Mobile apps as a data source

A phone app can record what people do, where they are and what the phone senses. That is powerful data for machine learning, and it comes with duties.

14 min readFree

Why apps are a rich source

Most people carry a phone all day. Wikipedia defines a mobile app as 'a computer program or software application designed to run on a mobile device such as a smartphone, tablet, or smartwatch.' Every tap, every swipe and every opened screen happens inside software, so the app can write each one down.

Key words

Event
One small record of something that happened, such as 'the user opened the search screen at 10:42'.
Session
One visit to the app, from opening it to closing it or leaving it idle. A session holds many events.
Log
A running list of events. Wikipedia says logging is 'the act of keeping a log of events that occur in a computer system, such as problems, errors or broad information on current operations.'
Telemetry
Data sent back automatically from a remote place. Wikipedia describes it as 'the in situ collection of measurements or other data at remote points and their automatic transmission to receiving equipment (telecommunication) for monitoring.'
SDK
Short for software development kit. It is a bundle of ready-made code that an app team adds to their app, for example to record events.
Personal data
Any information about a person who is, or could be, identified. We define it exactly below.
Consent
A person's clear yes to a use of their data, given before it is collected.

What apps produce

An app can record many kinds of data. Here are the main ones. Which of them a real app records is the team's choice, and some need the user's permission first.

  • Usage events

    Taps, screens opened, buttons pressed, searches made and purchases completed. Each is one row: who, what, and when. Wikipedia says that in software, telemetry is used to gather data on the use of applications, 'e.g. how often certain features are used, measurements of start-up time and processing time, hardware, application crashes, and general usage statistics and/or user behavior.'

  • Device and sensor data

    Android's documentation says its platform 'supports three broad categories of sensors': motion sensors, which 'measure acceleration forces and rotational forces along three axes', environmental sensors, which measure things like 'ambient air temperature and pressure, illumination, and humidity', and position sensors, which 'measure the physical position of a device'. Sensor data is the main subject of the next lesson.

  • Location

    Where the phone is. On Android, each location permission has two traits: a 'Category', either foreground location or background location, and an 'Accuracy', either precise location or approximate location. Location is some of the most revealing data an app can hold.

There is more. Crash logs record what went wrong and on which phone model. Text that people type into the app, such as a search or a review, is data. So are photos or voice they choose to add. Text, images and audio are unstructured data, as the last lesson explained, so they need extra work before a model can use them.

Quick check

Which of these is a usage event?

How the data is collected

The app does not magically know what you want to measure. A person decides which events to record and writes code that records them. This is called instrumenting the app.

Teams often do this with an SDK. Apple's documentation describes 'third-party code, such as advertising or analytics SDKs', and says an app that uses it must describe 'what data it collects, how it is used, and whether it tracks users.'

  1. 1

    1. Decide the question

    Start from what you want to learn, such as 'where do people give up when they sign up?' Do not start from 'record everything'.

  2. 2

    2. Name the events

    Pick a few clear names, such as signup_started and signup_done. Give each event the fewest details it needs.

  3. 3

    3. Record each event on the phone

    When the user does the thing, the app writes one event: an id, a user or device id, the screen, and a time.

  4. 4

    4. Send the events to a server

    The app sends events to a server, often in small groups. The phone may be offline for a while, so the app can keep events and send them later.

  5. 5

    5. Store and clean them

    The server stores the events as a log, and the team removes bad rows before training.

Android permissions

Android's documentation says app permissions protect 'restricted data', such as system state and contact information, and 'restricted actions', such as connecting to a paired device and recording audio.

There are different types. Some permissions, called install-time permissions, 'are automatically granted when your app is installed.' Others, called runtime permissions, 'require your app to go a step further and request the permission at runtime.' Android also calls runtime permissions dangerous permissions. They give 'additional access to restricted data' or let the app 'perform restricted actions that more substantially affect the system and other apps.' When an app asks, the system shows a prompt, and the person chooses.

Android's advice to app makers is also a good rule for data work. Its basic principles say to 'Ask for a permission in context, when the user starts to interact with the feature that requires it.' And if the user says no, 'gracefully degrade your app so that the user can continue using your app, possibly by disabling the feature that requires the permission.' So some people will always say no, and your data will have gaps.

iOS and tracking

Apple handles one special case with a framework called App Tracking Transparency, or ATT. Apple's page says that in iOS 14.5 and later 'you need to receive the user's permission through the App Tracking Transparency (ATT) framework in order to track them or access their device's advertising identifier.'

The word tracking has a narrow meaning here. Apple says: 'Tracking refers to the act of linking user or device data collected from your app with user or device data collected from other companies' apps, websites, or offline properties for targeted advertising or advertising measurement purposes. Tracking also refers to sharing user or device data with data brokers.' By that definition, ATT is about joining an app's data with other companies' data, not about an app counting its own screens.

Quick check

On Android, what does a runtime permission mean?

Privacy basics

A permission prompt on the phone is only part of the story. Laws also say what a team may do with the data after it arrives. The best-known one in Europe is the GDPR, the General Data Protection Regulation. This is a high-level explanation, not legal advice.

Article 4 of the GDPR defines personal data as 'any information relating to an identified or identifiable natural person'. It adds that an identifiable person 'is one who can be identified, directly or indirectly, in particular by reference to an identifier such as a name, an identification number, location data, an online identifier'. Notice that location data and online identifiers are on that list. A device id and a set of GPS points can be personal data even with no name attached.

Collect less

Article 5 sets out principles for handling personal data. One of them is data minimisation: personal data shall be 'adequate, relevant and limited to what is necessary in relation to the purposes for which they are processed'. Another is storage limitation: data should be kept in a form that identifies people 'for no longer than is necessary for the purposes for which the personal data are processed'.

Pseudonymised or anonymous?

People often mix up two ideas. The GDPR keeps them apart.

  • Pseudonymisation

    Article 4 defines it as processing personal data 'in such a manner that the personal data can no longer be attributed to a specific data subject without the use of additional information', as long as that extra information 'is kept separately' and protected. An example is swapping a name for a code, while a separate table maps codes back to names.

  • Still personal data

    Recital 26 says that 'Personal data which have undergone pseudonymisation, which could be attributed to a natural person by the use of additional information should be considered to be information on an identifiable natural person.' In plain words, a code instead of a name does not make the data free of the rules.

  • Anonymous information

    Recital 26 describes it as 'information which does not relate to an identified or identifiable natural person or to personal data rendered anonymous in such a manner that the data subject is not or no longer identifiable.' Whether someone is identifiable depends on 'all the means reasonably likely to be used, such as singling out'. The principles of data protection 'should therefore not apply to anonymous information'.

The practical lesson: replacing user names with ids is a good safety step, but it is pseudonymisation, not anonymisation. Do not call a dataset anonymous unless you have checked that nobody can be singled out from it, with the means reasonably available.

On the phone or on a server?

Once you have the data, there is a design choice. Do you send it to a server and train there? Or do you keep it on the phone and run the model there?

Wikipedia describes edge computing as 'any design that pushes computation physically closer to a user, so as to reduce the latency compared to when an application runs on a centralized data center.' A phone running a model itself is a close-to-the-user design. Wikipedia lists the gains: this approach 'minimizes latency, reduces bandwidth consumption, and enhances real-time responsiveness', and 'by keeping and processing data at the edge, it is possible to increase privacy by minimizing the transmission of sensitive information to the cloud.'

There is a middle path. Wikipedia describes federated learning as a technique where 'multiple entities (often called clients) collaboratively train a model while keeping their data decentralized, rather than centrally stored.' The principle is 'training local models on local data samples and exchanging parameters' between nodes to build a shared model. It is 'generally concerned with and motivated by issues such as data privacy, data minimization, and data access rights.' Wikipedia notes that the nodes can be smartphones, and that they commonly rely on Wi-Fi and battery-powered systems, so they may drop out.

Quality traps in app data

App data is easy to collect and easy to get wrong. Google's course lists common causes of unreliable data, such as omitted values and 'Duplicate examples. For example, a server mistakenly uploaded the same log entries twice.' Here are four traps that are especially common in apps. The first three are cases we describe from the way phones and servers work. They are made-up examples, not statistics.

  • Late and repeated events

    A phone can be offline for a while and send its events later, or send the same group again after a bad connection. Rows then arrive late or twice. Give every event its own id so repeats can be spotted and dropped.

  • Clocks and time zones

    Python's documentation says an 'aware' time value 'represents a specific moment in time that is not open to interpretation', while a 'naive' one 'does not contain enough information to unambiguously locate itself relative to other date/time objects.' Store times with their zone, and convert them for display.

  • App versions change

    When a new version renames an event or moves a button, counts drop or jump without any change in behaviour. Record the app version on each event and note every change.

The fourth trap is bias. Wikipedia defines sampling bias as 'systematic error due to a non-random sample of a population, causing some members of the population to be less likely to be included than others'. App data only describes people who installed the app, said yes to the prompts and kept using it. Heavy users can also write far more events than light users, so a model trained on raw rows may learn mostly what the busiest people do.

Quick check

An app sends events in groups when the phone is back online. Two copies of the same group arrive. What should you do first?

Try it: clean a few app events

Let's clean a tiny made-up log with Python. Each line is one event in JSON, a text format for records. The data and the numbers are invented for this lesson. We will count events per screen, drop duplicate event ids, and show a time in two zones. We only use Python's standard library.

  1. 1

    1. Read the events

    json.loads turns each line into a dictionary. Our log has five lines.

  2. 2

    2. Drop duplicates

    We keep a set of event ids we have already seen. A line whose id is in the set is skipped.

  3. 3

    3. Count per screen

    A Counter from the collections module counts how many events each screen has.

  4. 4

    4. Convert the times

    Each time is stored in UTC. We convert it with zoneinfo, which provides IANA time zone support in the standard library.

Python
import json
from collections import Counter
from datetime import datetime, timezone
from zoneinfo import ZoneInfo

lines = [
    '{"event_id": "e1", "user": "u1", "screen": "home", "ts": "2026-07-01T23:30:00+00:00"}',
    '{"event_id": "e2", "user": "u1", "screen": "search", "ts": "2026-07-01T23:31:10+00:00"}',
    '{"event_id": "e2", "user": "u1", "screen": "search", "ts": "2026-07-01T23:31:10+00:00"}',
    '{"event_id": "e3", "user": "u2", "screen": "home", "ts": "2026-07-02T00:05:00+00:00"}',
    '{"event_id": "e4", "user": "u2", "screen": "settings", "ts": "2026-07-02T00:06:30+00:00"}',
]

events = [json.loads(line) for line in lines]
print("events received:", len(events))

seen = set()
unique = []
for e in events:
    if e["event_id"] not in seen:
        seen.add(e["event_id"])
        unique.append(e)
print("after dropping duplicates:", len(unique))

per_screen = Counter(e["screen"] for e in unique)
print("per screen:", dict(per_screen))

london = ZoneInfo("Europe/London")
for e in unique[:2]:
    when = datetime.fromisoformat(e["ts"])
    print(e["event_id"], "UTC:", when.astimezone(timezone.utc).strftime("%d %b %H:%M"), "London:", when.astimezone(london).strftime("%d %b %H:%M"))

by_user = Counter(e["user"] for e in unique)
print("events per user:", dict(by_user))

Output

events received: 5
after dropping duplicates: 4
per screen: {'home': 2, 'search': 1, 'settings': 1}
e1 UTC: 01 Jul 23:30 London: 02 Jul 00:30
e2 UTC: 01 Jul 23:31 London: 02 Jul 00:31
events per user: {'u1': 2, 'u2': 2}

Read the output slowly. Five events came in, but one was a repeat, so four are real. The home screen has two events. And look at the times: the same moment is still 1 July in UTC but already 2 July in London, because London is an hour ahead of UTC in July. If you counted 'events per day' with the wrong zone, the same event would land on a different day.

The last sample shows the heavy-user trap with made-up numbers: ten users, where two of them are very busy.

Python
events_per_user = [120, 95, 3, 2, 2, 1, 1, 1, 1, 1]

total = sum(events_per_user)
top_two = sum(sorted(events_per_user, reverse=True)[:2])
print("users:", len(events_per_user))
print("events:", total)
print("share of events from the 2 busiest users:", round(100 * top_two / total), "%")

Output

users: 10
events: 227
share of events from the 2 busiest users: 95 %

Two of ten users produce 95 percent of the rows. A model trained on these rows would mostly learn those two people. Before training, teams often count users, not only events, or cap how many rows one user can add.

What to remember

Apps make fresh data all the time: events, sessions, sensor readings, location, crash logs and text. People decide what to record, and the phone systems make users choose what to share. Collect only what you need, call pseudonymised data what it is, think about keeping the model on the phone, and clean the log before you trust it.

Next: IoT and sensor data. A phone is one small sensor box. The next lesson looks at devices that do nothing but sense, and at what makes their readings tricky.

Sources

How is this lesson?

Last updated on 16 November 2026

Learn with me

Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.