CoreML: Machine Learning in iOS

Fidan Musazade
3 min readDec 27, 2020

One of the most interesting findings for me recently was the presence of a library, which would make it possible to train and use machine learning models inside an iOS mobile application.

CoreML was released in iOS 11, around 3 years ago. It is very powerful, as you can build models using TensorFlow, scikit-learn, and other frequently used technologies, then simply convert it to CoreML format and integrate it into the mobile app.

CoreML supports a great number of models, including Support Vector Machines (SVMs), tree ensembles (e.g. Random Forests), Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Deep Neural Networks (DNNs).

However, there are obviously certain advantages and disadvantages we can discuss. Basically, CoreML gives you a set of pre-trained models you can use or even develop your own.

Advantages:

  • The model operates on the edge. This means that they are calculated on the device and do not need to wait for request to get the result. Therefore, the latency is low and you get almost real-time results
  • It can be used offline. As there are no requests/responses from the external API, the model can operate without an internet connection. This gives the app advantage as it can be used without the Internet
  • The data is private, as it is not sent anywhere and stays on the device all the time. Privacy issues are therefore eliminated by using a CoreML model
  • The cost of operating this app is also lower, as there are no API calls and nothing has to be hosted anywhere on the cloud. With traditional models, the back-end has to be hosted somewhere in order to send and receive API calls

Disadvantages:

  • The size of the application can become very large if the model is big. Even with small models, the presence of the CoreML still adds to the size of the app as the model has to be kept on the device
  • As the computation and prediction is done on the device, the app consumes an extensive amount of battery and may add additional issues to the older devices, which are not that powerful
  • The model would need to be constantly trained, and if there is any change to it, the app should be updated. This could lead to very frequent updates required to operate the app correctly

--

--

Fidan Musazade

Data Scientist & Machine Learning Engineer @ The International Bank of Azerbaijan