Contents

MLActivityClassifier

A model you train to classify motion sensor data.

Declaration

struct MLActivityClassifier

Overview

An activity classifier is a machine-learning model that your app can use to categorize user activities, based on the motion of the user’s device.

You create an activity classifier by gathering a training dataset of a device’s motion sensors, such as the accelerometer and gyroscope on an Apple Watch. For example, you can create an activity classifier that recognizes a person waving, shaking hands, or throwing a ball by gathering the motion-sensor data from people performing those activities.

Evaluate your trained activity classifier by calling evaluation(on:featureColumns:labelColumn:recordingFileColumn:) evaluation(on:) with a dataset that’s completely distinct from the training and validation datasets. Inspect the metrics the method returns and decide whether the activity classifier performs with enough accuracy. For example, you can assess how often the activity classifier confuses a person waving for shaking hands, or vice versa. If the classifier makes too many mistakes, you can train another classifier with different parameters, or with a training dataset that has more or better motion-sensor examples.

When you’re satisfied with an activity classifier, save it as a Core ML model file, and add it to your Xcode project. Use it to predict the user’s activity based on the motion-sensor data your app captures from the user’s device.

Topics

Training an activity classifier asynchronously

Creating an activity classifier from a checkpoint

Training an activity classifier synchronously

Evaluating an activity classifier

Testing an activity classifier

Saving an activity classifier

Inspecting an activity classifier model

Describing an activity classifier

Supporting types

Default Implementations