People motion recognition using inertial sensors
Wouldn't it be awesome at the end of every day to see the statistics of it: how much time have you spent doing things you like, and how much time you've wasted? With this kind of report, you could make your time management decisions based on real data, not just a gut feeling. Wait, but there are a lot of time trackers out there on the App Store, right? Sure, but there is one problem with most of them: you have to fill them in manually, because they can't detect what are you doing at every moment. You can't teach them to recognize types of your activities. Fortunately, we can fix this using machine learning; specifically, time series classification.
Time series data type is common in iOS applications: among examples are signals from inertial sensors, measurements from HealthKit, and any other data that has a clear time correspondence and sampled regularly. Some other types of data, such as application logs or records of user activity, can be reduced to a special type of time series: categorical time series, where categories are in place of numbers.
The motion recognition task is important in health monitoring and fitness applications, but can also have some unusual use cases. For example, the Walk Me Up! Alarm Clock app makes you get out of your bed, because it doesn't allow you to snooze your alarm until you take a number of steps. It distinguishes real steps from attempts to cheat by shaking the device.
The Core Motion framework provides APIs to get a history of a user's movements or a real-time stream of data from motion sensors. It can also distinguish a limited set of movement types, but we're going to teach our app to recognize more types than the Core Motion can. With the growth in popularity of wearable accessories, the motion sensor became a very common source of data; however, the method described in this chapter is not specific to sensor data, so you can apply these algorithms to many other practical problems. That's the good thing about general-purpose machine learning algorithms: you can apply them to any kind of data, you only need to find an appropriate representation for the data.