Everything you need to know about Core ML (A Machine Learning for iOS)

Sathik
Sathik
Sep 4, 2018 · 7 min read
Core ML (Machine Learning for iOS)

The world is gradually evolving to become more techs reliant and machine learning is one of the most important technologies that is expected to revolutionize the future. From trivial startups to sophisticated enterprises, every business is trying to incorporate machine learning in its operations. AI was talked about even 25 years ago but what makes it suddenly become the buzzword of the decade? The answer is machine learning! Advancement in technology like deep learning and neural networks has made it possible for AI to make dramatic breakthroughs. For example, the kind of precision that machine translate has achieved last year is better than the cumulative of the past few years. The ability of computers to learn things just like human beings is hitting a tipping point with neural networks. The ability that once seemed like fiction is here today.

Machine Learning 101 — Digging deep into the basics

The term Artificial Intelligence refers to any technique that makes machines mimic human intelligence using logics. Machine learning is a subset of Artificial Intelligence which includes the methods that detect patterns of data and use the uncovered patterns to predict future data. It also makes other kinds of useful decisions under uncertainty, so artificial intelligence helps to take right decision in businesses. In a nutshell, machine learning is all about using data to answer questions. You make the computer learn by feeding in lots of data based on which the computer produce results called Inferences.

The world is filled with data and it doesn’t look like the data generation is going to slow down anytime soon. This will only continue to grow in the years to come.Traditionally humans have analysed data and adapted to the changing patterns. However, the amount of data surpasses the human ability to analyse it and this resulted in the need to automate data. As a solution, machine learning was created to make data analysis suitable for the shifting landscape. Machine learning tries to derive a meaning from all of that data and uses them to answer questions that humans can’t.

Layers of machine learning algorithms are embedded into most of the tech applications we use today. Yet they are not so apparent. For example, every time you make a google search you are making use of millions of machine learning algorithms without even realizing it. Right from the tagging suggestions you get in social media to the predictive text that your keyboard gives you, machine learning algorithms are constantly working to help technologies serve you better. Today, the applications of machine learning are already quite wide ranging and the notorious ones are image recognition, recommendation systems, fraud detection, text and speech systems. The machine learning systems are used in a variety of industries that include medicine, transport, hospitality and retail. Google recently published a paper that talks about detecting diabetic retinopathy (which is the fastest growing cause of blindness in the world) in the early stages solely by using machine learning.

What is Core ML?

Core ML is the machine learning framework used across Apple products and foundation for domain-specific frameworks and functionality. Core ML supports Vision for image study, Natural Language for natural language processing, and GameplayKit for evaluating learned decision trees. Core ML allows you to perform real-time predictions of live images or video on the device.

Machine learning on the Edge using Core ML

Machine learning is taking mobile app development to a new level. ML can now recognize not just text, speech and images but gestures too. They can interpret voices with extraordinary success rate. It gives us new and compelling ways to interact with the people and objects in the world around us. Machine learning is making our smart devices smarter enabling mobile developers to create a bridge between the technology and devices. Mobile apps use pre trained data models to make predictions. But these models are initially trained outside of the app, typically in a cloud. Also the advances in cloud computing have greatly reduced the time it takes to train these models from weeks to hours. This doesn’t just accelerate the production but expands the time to market as well. There are also plenty of third-party API driven machine learning services hitting the market who can do all the heavy lifting for you. This means, you get more than enough sources to either build your own machine learning app or let someone else build it for you.

There are three types of machine learning namely

  • Supervised learning
  • Unsupervised learning
  • Reinforcement learning

90% of practical users of mobile apps focus on supervised learning. Supervised learning is a system of all labelled data and predictive model. They use labelled data to train a mode and, use the trained model to make predictions on new unlabelled data. The trained model is the core of the topic when it comes to mobile app machine learning. Supervised learning consists of two tasks that includes regression and classification. Regression involves the input of a continuous numerical value.and outputs a real value like a currency or weight. For example, if you input the features of a car like the mileage and tank capacity, the machine learning tells you the price of the car. Classification is when the output is a variable. For example, when you take a picture of your pet, the machine learning tells you what animal it is.

As iOS developer, Apple has provided us with machine learning tools like Core ML, mission framework and AR kit. Core ML is the framework used across Apple products for providing optimized and on-device inference. In this case, the model is fully trained in the cloud, converted to Core ML and added to your X-code project. For Android development, you can use TensorFlow Lite which comes with functions similar to core ML by providing a model for on-device inference. With all the latest platform frameworks, we can now make our mobile apps smarter without any extra effort. AI and ML will soon be the norm and your customers will expect and even demand these solutions in your products.

How is Core ML better?

For machine learning inference, Core ML is one of the three choices that developers have.The other two choices are being able to host a machine learning model in the cloud and send data from the device to the hosted endpoint to provide predictions or use third-party API driven machine learning cloud services. Core ML is used to access a local on-device trained model.

Core ML is the foundational machine learning framework used across Apple devices. Core ML renders fast performance with Easy integration of trained machine learning models on the edge. There are four major advantages of using Core ML:

  • Low latency & near real-time results: You don’t need to make a network call sending the data and waiting for the response. This could be critical for video applications processing successive frames from the on-device camera.
  • Offline availability: The application runs effectively without even requiring network connection.
  • Privacy: The data never leaves the device
  • Pocket friendliness: With Core ML, you can save the money you would rather spend on network connections, API, and the model stored in the cloud.

Core ML supports the convolutional and most common deep learning and neural networks. Core ML is tightly integrated and it supports the vision for image analysis, natural language processing (NPL) and game play kit frameworks. The vision frameworks perform face detection, text detection, image recognition and feature tracking. When using Core ML to solve computational problems like object classification and object detection, use the vision framework as Apple has made it super simple to use vision as a pipeline from the camera to Core ML. The foundational API offers natural language processing and speech recognition. Also it deeply understands texts using features like language identification, tokenization and detecting names from texts. Talking about the gameplay which is for architecting and organizing your game logic, Core ML incorporates things like random number generation, artificial intelligence, pathfinding and agent behaviour.

But, there are some downsides to Core ML because on-device model means, increasing the size of the application. Also this will eventually increase the system utilization and drain battery fast. Also, the model on the device has to be continually trained in most cases. Any change to the model results in the app needing to update the model onto device. However, given its advantages and cutting edge capabilities, the downsides are negligible and they can be easily overcome by using systems with more memory and battery back up.

Closing thoughts

It wasn’t long ago when a company using machine learning looked novel to the entire industry. But now, most of the tech companies are pivoting to use machine learning products in someway. Artificial Intelligence is becoming an expected feature of a tech product in someway. In the future, machine learning will help us do things that are far out of reach from the ability of the human intellect. It will enable tasks to be performed better, faster and easier than before. Thankfully, it is not difficult to take advantage of machine learning today. The tooling has gone quite good. All you need is data, developers and the willingness to take the plunge. If you are planning to hire iOS app developers, feel free to get in touch with us. We help you hire the best iOS developers who have been working across different industries in the niche.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade