Book Image

Machine Learning with Swift

By : Jojo Moolayil, Alexander Sosnovshchenko, Oleksandr Baiev
Book Image

Machine Learning with Swift

By: Jojo Moolayil, Alexander Sosnovshchenko, Oleksandr Baiev

Overview of this book

Machine learning as a field promises to bring increased intelligence to the software by helping us learn and analyse information efficiently and discover certain patterns that humans cannot. This book will be your guide as you embark on an exciting journey in machine learning using the popular Swift language. We’ll start with machine learning basics in the first part of the book to develop a lasting intuition about fundamental machine learning concepts. We explore various supervised and unsupervised statistical learning techniques and how to implement them in Swift, while the third section walks you through deep learning techniques with the help of typical real-world cases. In the last section, we will dive into some hard core topics such as model compression, GPU acceleration and provide some recommendations to avoid common mistakes during machine learning application development. By the end of the book, you'll be able to develop intelligent applications written in Swift that can learn for themselves.
Table of Contents (18 chapters)
Title Page
Packt Upsell

Applications of ML

There are many domains where ML is an indispensable ingredient, some of them are robotics, bioinformatics, and recommender systems. While nothing prevents you from writing bioinformatic software in Swift for macOS or Linux, we will restrict our practical examples in this book to more mobile-friendly domains. The apparent reason for this is that currently, iOS remains the primary target platform for most of the programmers who use Swift on a day-to-day basis.

For the sake of convenience, we'll roughly divide all ML applications of interest for mobile developers into three plus one areas, according to the datatypes they deal with most commonly:

  • Digital signal processing (sensor data, audio)
  • Computer vision (images, video)
  • Natural language processing (texts, speech)
  • Other applications and datatypes

Digital signal processing (DSP)

This category includes tasks where input data types are signals, time series, and audio. The sources of the data are sensors, HealthKit, microphone, wearable devices (for example, Apple Watch, or brain-computer interfaces), and IoT devices. Examples of ML problems here include:

  • Motion sensor data classification for activity recognition
  • Speech recognition and synthesis
  • Music recognition and synthesis
  • Biological signals (ECG, EEG, and hand tremor) analysis

We will build a motion recognition app in Chapter 3, K-Nearest Neighbors Classifier.


Strictly speaking, image processing is also a subdomain of DSP but let's not be too meticulous here.

Computer vision

Everything related to images and videos falls into this category. We will develop some computer vision apps in Chapter 9Convolutional Neural Networks. Examples of computer vision tasks are:

  • Optical character recognition (OCR) and handwritten input
  • Face detection and recognition
  • Image and video captioning
  • Image segmentation
  • 3D-scene reconstruction
  • Generative art (artistic style transfer, Deep Dream, and so on)

Natural language processing (NLP)

NLP is a branch of knowledge at the intersection of linguistics, computer science, and statistics. We'll talk about most common NLP techniques in Chapter 10, Natural Language Processing. Applications of NLP include the following:

  • Automated translation, spelling, grammar, and style correction
  • Sentiment analysis
  • Spam detection/filtering
  • Document categorization
  • Chatbots and question answering systems

Other applications of ML

You can come up with many more applications that are hard to categorize. ML can be done on virtually any data if you have enough of it. Some peculiar data types are:

  • Spatial data: GPS location (Chapter 4, K-MeansClustering), coordinates of UI objects and touches
  • Tree-like structures: hierarchy of folders and files
  • Network-like data: occurrences of people together in your photos, or hyperlinks between web pages
  • Application logs and user in-app activity data (Chapter 5, Association Rule Learning)
  • System data: free space disk, battery level, and similar
  • Survey results