Skip to content

Introduction to ArcKit v2.0.0

Matt Greenfield edited this page Sep 16, 2017 · 5 revisions

Introduction to ArcKit v2.0.0

NOTE: This release requires Xcode 9. If you wish to build your project in Xcode 8, you should pin to ArcKit ~> 1.0 instead.

ArcKit v2 introduces a machine learning engine, providing ML classifiers for determining the activity types of LocomotionSamples.

The supported types are the base types provided by Core Motion (stationary, transport, walking, running, cycling), as well as extended transport types (car, train, bus, motorcycle, boat, airplane).

The ArcKit Demo App has been updated to demonstrate the classifiers in use. Fire it up and walk around or go for a drive to see it in action!

Note that the Demo App only shows one way of using the classifiers, although there are many different potential ways to use them, depending on your needs.

What is a Classifier?

A classifier contains the statistical data models for each activity type (walking, running, car, etc) within a specific geographic region. When given a LocomotionSample the classifier will return results containing matching probability scores for each activity type. The highest scoring type in the classifier results is the “best match” type for that LocomotionSample.

How Do I Use a Classifier?

The Demo App uses a two classifiers approach. It maintains a classifier for “base” activity types and a separate classifier for “transport” activity types.

The Demo App’s “base” classifier contains the ML models for stationary, walking, running, cycling, and transport.

The Demo App’s “transport” classifier contains the ML models for car, train, bus, motorcycle, airplane, and boat.

For demonstration purposes the Demo App is applying both classifiers to every new LocomotionSample, but in practice it should be optimised to only engage the “transport” classifier if the base classifier has chosen transport as its best match type.

For example, if the base classifier chooses “walking” as the best match, there is no point in asking the transport classifier on its opinion, because the transport classifier doesn’t know anything about different kinds of walking. It would just be wasted CPU cycles. However if the base classifier chooses “transport” as its best match, then it is probably worth asking the transport classifier which type of transport it thinks it is.

Fetching a Classifier

Have a look at updateTheBaseClassifier() or updateTheTransportClassifier() in the Demo App,to see how to create a classifier instance.

The classifier init method will attempt to get activity type ML models from ArcKit’s local models cache to match your requested types. If matching models for the given types and coordinate (eg the user’s current location) are available, it will return a suitable classifier. If however there are not yet any matching models cached locally, it will fetch them from the ArcKit server and immediately return nil.

You can then attempt to create a classifier again a moment later (eg when the next LocomotionSample arrives), and most likely will get a result, now that the local ML models cache is ready.

Transport Classifier Availability

Classifying transport types (car, train, bus, etc) requires local knowledge. ArcKit’s models have comprehensive transport type knowledge for many major cities around the world and are constantly expanding, but it is not universal.

If you need to accurately detect the difference between car trips, train trips, bus trips, etc, in a specific city or geographic region, you will want to check the current coverage maps.

You can also check local coverage by fetching a transport types classifier for a desired coordinate and check the classifier’s completenessScore property. In practice, a completeness score above 0.2 (20%) is enough to expect usable results. Arc App currently uses a threshold of 0.15 (15%) before engaging the local transport classifier.

More Documentation Coming Soon!

I’m still in the process of writing up the API docs and more details on different classifier usage patterns. But if there’s anything I’ve missed out so far that you want to know, please do ask!

Thanks :D

Matt