Cover: Machine Learning for iOS Developers by Abhishek Mishra

Machine Learning for iOS Developers

 

 

Abhishek Mishra

 

 

 

 

 

 

Wiley Logo

To my wife, Sonam, for her love and support through all the years we've been together.

To my daughter, Elana, for bringing joy and happiness into our lives.

—Abhishek

About the Author

Abhishek Mishra has been active in the IT industry for more than 19 years and has extensive experience with a wide range of programming languages, enterprise systems, service architectures, and platforms. He earned his master's degree in computer science from the University of London and currently provides consultancy services to Lloyds Banking Group in London as a security and fraud solution architect. He is the author of several books including Machine Learning in the AWS Cloud and Amazon Web Services for Mobile Developers.

About the Technical Editor

Paul Pires has been developing iOS apps professionally for the past five years, having worked within a range of industries such as finance, media, and fashion. He earned his bachelor's degree in computer science from City University in London and currently works as a freelance iOS consultant.

Acknowledgments

This book would not have been possible without the support of the team at Wiley, including Jim Minatel, Kenyon Brown, Kezia Endsley, Kim Wimpsett, and Pete Gaughan.

I would also like to thank Paul Pires for his keen eye for detail.

It has been my privilege working with all of you. Thank you.

Introduction

Machine learning is one of the hottest trends in computing and deals with the problem of creating computer programs that can generalize and predict information reliably, quickly, and with accuracy, resembling what a human would do with similar information. With the recent hype in mainstream media around novel applications of machine learning, you may be inclined to think that machine learning is a relatively new discipline, but that is far from the truth. In fact, machine learning has been around for several decades, and it is because of recent advances in storage, processor, and GPU technology that it is possible to build and deploy machine learning systems at scale and get results in real time.

This book is targeted at intermediate/advanced iOS developers who are looking to come to grips with the fundamentals of machine learning, learn about some of the common tools used by data scientists, and learn how to build and deploy models into their iOS applications. This book at all times attempts to balance theory and practice, giving you enough visibility into the underlying concepts while providing you with the best practices and practical advice that you can apply to your workplace right away.

Machine learning is a rapidly evolving field. I have made every attempt to keep the content up-to-date and relevant. Even though this makes the book susceptible to being outdated on a few rare instances, I am confident the content will remain useful and relevant through the next releases of iOS.

What Does This Book Cover?

This book covers the fundamental concepts of machine learning as well as the use of these concepts to build real-world models and use them in your iOS apps.

  • Chapter 1: Introduction to Machine Learning This chapter introduces the different types of machine learning models commonly found in real-world applications as well as tools and libraries used by data scientists to build these models. The chapter also includes examples of real-world applications of machine learning and sources of training data.
  • Chapter 2: The Machine-Learning Approach This chapter examines a hypothetical scenario in which a rule-based system is used to process credit card applications. The limitations of the rule-based system are examined, and a machine learning system is devised to address some of those limitations. The chapter concludes with an overview of the steps involved in building a typical machine learning solution.
  • Chapter 3: Data Exploration and Preprocessing This chapter focuses on the data exploration and feature engineering stage, specifically the use of popular Python libraries NumPy, Pandas, and Scikit-learn for tabular data. The chapter also explores feature selection techniques.
  • Chapter 4: Implementing Machine Learning on Mobile Apps This chapter explores the options available to you as an iOS developer to integrate machine learning techniques on your apps. The chapter compares the pros and cons of an edge-based versus server-based deployment model and introduces both Apple offerings as well as other third-party offerings that can be used from within your apps.
  • Chapter 5: Object Detection Using Pre-trained Models This chapter focuses on the use of pre-trained models for object detection in your iOS apps. The chapter also covers the basics of artificial neural networks (ANNs) and convolutional neural networks (CNNs).
  • Chapter 6: Creating an Image Classifier with the Create ML App This chapter covers the use of Apple's Create ML app to train a machine learning model that can detect the dominant object in an image. The model is trained on a subset of the Kaggle Dogs vs. Cats dataset and exported to the Core ML format. The exported model is used within an iOS app.
  • Chapter 7: Creating a Tabular Classifier with Create ML This chapter covers the use of Apple's Create ML app to train a classification model on tabular data. The model is trained on the popular UCI ML wine dataset and exported to the Core ML format using the Create ML app. The trained model is then used in an iOS app that allows users to input the chemical characteristics of wine and learn the quality of the beverage.
  • Chapter 8: Creating a Decision Tree Classifier This chapter focuses on the use of Scikit-learn to create a decision tree classification model on the popular Iris flowers dataset. The trained model is then exported to the Core ML format using the Core ML Tools Python library and used in an iOS app.
  • Chapter 9: Create a Logistic Regression Model Using Scikit-learn and Core ML This chapter focuses on the use of Scikit-learn to create a logistic regression model on the popular Pima Indians diabetes dataset. The trained model is then exported to the Core ML format using the Core ML Tools Python library and used in an iOS app.
  • Chapter 10: Building a Deep Convolutional Neural Network with Keras This chapter covers the creation and training of a popular deep convolutional neural network architecture called Inception V4 using the Keras functional API. The Inception V4 network is trained on a small publicly available dataset and then used in an iOS app.
  • Appendix A: Anaconda and Jupyter Notebook Setup This appendix helps you install Anaconda Navigator on your computer, set up a Python environment that includes several common machine learning libraries, and configure Jupyter Notebook.
  • Appendix B: Introduction to NumPy and Pandas This appendix shows you how to use NumPy and Pandas. These libraries are commonly used during the data exploration and feature engineering phases of a project.

Additional Resources

In addition to this book, here are some other resources that can help you learn more about machine learning.

  • Apple Machine Learning Journal: https://machinelearning.apple.com
  • Scikit-learn User Guide: https://scikit-learn.org/stable/user_guide.html
  • Core ML Developer Documentation: https://developer.apple.com/documentation/coreml
  • Core ML Tools Documentation: https://apple.github.io/coremltools/
  • Keras Documentation: https://keras.io

Reader Support for This Book

We provide support for this book in a couple of ways.

Companion Download Files

As you work through the examples in this book, the project files you need are all available for download from www.wiley.com/go/machinelearningforiosdevelopers.

How to Contact the Publisher

If you believe you've found a mistake in this book, please bring it to our attention. At John Wiley & Sons, we understand how important it is to provide our customers with accurate content, but even with our best efforts an error may occur.

To submit your possible errata, please email it to our customer service team at wileysupport@wiley.com with the subject line “Possible Book Errata Submission.”

Part 1
Fundamentals of Machine Learning

  • Chapter 1:  Introduction to Machine Learning
  • Chapter 2:  The Machine-Learning Approach
  • Chapter 3:  Data Exploration and Preprocessing
  • Chapter 4:  Implementing Machine Learning on Mobile Apps