SlideShare a Scribd company logo
Core MLandyourApp
Howto use Core MLto pushthe limits
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
This talk explains how aspiring app developers/
companies can take full advantage of Core ML to push
their apps to the next level.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
This talk explains how aspiring app developers/
companies can take full advantage of Core ML to push
their apps to the next level.
I'll introduce you to
- The fundamentals of Core ML
- What is possible with machine learning in iOS 11
- What is not possible with machine learning in iOS
11
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
This talk explains how aspiring app developers/
companies can take full advantage of Core ML to push
their apps to the next level.
I'll introduce you to
- The fundamentals of Core ML
- What is possible with machine learning in iOS 11
- What is not possible with machine learning in iOS 11
Lastly, What could potentially be possible in a future
release of iOS (12 and above )
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
» What is Core ML
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
» What is Core ML
» Machine Learning in iOS 11
» Vision
» Natural Language Processing
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
» What is Core ML
» Machine Learning in iOS 11
» Vision
» Natural Language Processing
» Features not yet available
» Retraining models (iOS 12 )
Mugunth Kumar, Itty Bitty Apps, Melbourne
Agenda
» What is Core ML
» Machine Learning in iOS 11
» Vision
» Natural Language Processing
» Features not yet available
» Retraining models (iOS 12 )
» Questions
Mugunth Kumar, Itty Bitty Apps, Melbourne
Core ML
What is Core ML
Mugunth Kumar, Itty Bitty Apps, Melbourne
Core ML
What is Core ML
» Core ML is a framework newly introduced in iOS 11
SDK
Mugunth Kumar, Itty Bitty Apps, Melbourne
Core ML
What is Core ML
» Core ML is a framework newly introduced in iOS 11
SDK
» Once considered complicated
Mugunth Kumar, Itty Bitty Apps, Melbourne
Core ML
What is Core ML
» Core ML is a framework newly introduced in iOS 11
SDK
» Once considered complicated
» Once considered CPU intensive
Mugunth Kumar, Itty Bitty Apps, Melbourne
Core ML
What is Core ML
» Core ML is a framework newly introduced in iOS 11
SDK
» Once considered complicated
» Once considered CPU intensive
» Once considered impossible to be done on the
client
Mugunth Kumar, Itty Bitty Apps, Melbourne
Core ML
What is Core ML
» Core ML is a framework newly introduced in iOS 11
SDK
» Once considered complicated
» Once considered CPU intensive
» Once considered impossible to be done on the
client
» Made easy in iOS 11
!
Mugunth Kumar, Itty Bitty Apps, Melbourne
Featuresavailabletodayin iOS 11
Mugunth Kumar, Itty Bitty Apps, Melbourne
Featuresavailabletodayin iOS 11
» Vision
» Object Tagging and Recognition
Mugunth Kumar, Itty Bitty Apps, Melbourne
Featuresavailabletodayin iOS 11
» Vision
» Object Tagging and Recognition
» Natural Language Processing
» Sentiment Analysis
» Language Tagging
» Parts of Speech Analysis
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
This talk is exclusively on NLP and text processing
for two reasons.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
This talk is exclusively on NLP and text processing
for two reasons.
» Plenty of libraries and blogs already exist on
vision and Object Tagging.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
This talk is exclusively on NLP and text processing
for two reasons.
» Plenty of libraries and blogs already exist on
vision and Object Tagging.
» Vision tagging model files are large (30MB to 200+
MB) and the "side" benefit you get using Core ML
gets defeated.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
This talk is exclusively on NLP and text processing
for two reasons.
» Plenty of libraries and blogs already exist on
vision and Object Tagging.
» Vision tagging model files are large (30MB to 200+
MB) and the "side" benefit you get using Core ML
gets defeated.
» As of iOS 11, you can't on the fly download a Core
ML model on the fly like on-demand resource.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
With Core ML and NLP, your app could do
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
With Core ML and NLP, your app could do
» Sentiment Analysis
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
With Core ML and NLP, your app could do
» Sentiment Analysis
» Parts of Speech Analysis/Language Tagging
Mugunth Kumar, Itty Bitty Apps, Melbourne
Thistalk
With Core ML and NLP, your app could do
» Sentiment Analysis
» Parts of Speech Analysis/Language Tagging
» Combining Both
Mugunth Kumar, Itty Bitty Apps, Melbourne
Who can be benefitted bySentimentAnalysis
Mugunth Kumar, Itty Bitty Apps, Melbourne
Who can be benefitted bySentimentAnalysis
» Apps that show reviews
Mugunth Kumar, Itty Bitty Apps, Melbourne
Who can be benefitted bySentimentAnalysis
» Apps that show reviews
» Social media account classifiers
Mugunth Kumar, Itty Bitty Apps, Melbourne
Who can be benefitted bySentimentAnalysis
» Apps that show reviews
» Social media account classifiers
» Pretty much any app that deals with lots of text
from e-book readers to magazine apps
Mugunth Kumar, Itty Bitty Apps, Melbourne
Getting Started
You need a Core ML Model. You can download from
Or you can convert using coremltools
Mugunth Kumar, Itty Bitty Apps, Melbourne
Getting Started
You need a Core ML Model. You can download from
» https://developer.apple.com/machine-learning/
Or you can convert using coremltools
Mugunth Kumar, Itty Bitty Apps, Melbourne
Getting Started
You need a Core ML Model. You can download from
» https://developer.apple.com/machine-learning/
» https://github.com/likedan/Awesome-CoreML-Models
Or you can convert using coremltools
Mugunth Kumar, Itty Bitty Apps, Melbourne
Getting Started
You need a Core ML Model. You can download from
» https://developer.apple.com/machine-learning/
» https://github.com/likedan/Awesome-CoreML-Models
Or you can convert using coremltools
» https://pypi.python.org/pypi/coremltools
Mugunth Kumar, Itty Bitty Apps, Melbourne
SentimentAnalysis Demo
Mugunth Kumar, Itty Bitty Apps, Melbourne
SentimentAnalysis Demo
» For the demo, I'll be using one such model from
the Awesome-CoreML-Models repo.
Mugunth Kumar, Itty Bitty Apps, Melbourne
SentimentAnalysis Demo
» For the demo, I'll be using one such model from
the Awesome-CoreML-Models repo.
» Specifically SentimentPolarity.mlmodel by Vadym
Markov.
Mugunth Kumar, Itty Bitty Apps, Melbourne
SentimentAnalysis Demo
» For the demo, I'll be using one such model from
the Awesome-CoreML-Models repo.
» Specifically SentimentPolarity.mlmodel by Vadym
Markov.
» It's a very light weight model weighing in at
275Kb.
Mugunth Kumar, Itty Bitty Apps, Melbourne
SentimentAnalysis Demo
Mugunth Kumar, Itty Bitty Apps, Melbourne
The Code!
func predictSentiment(from text: String) -> Sentiment {
do {
var inputFeatures = features(from: text)
guard inputFeatures.count > 1 else { throw Error.featuresMissing }
let output = try model.prediction(input: inputFeatures)
let positiveProb = output.classProbability["Pos"]!
let negativeProb = output.classProbability["Neg"]!
return Sentiment(positiveProbablity: positiveProb, negativeProbablity: negativeProb)
} catch {
preconditionFailure("Error occurred. Model file might be corrupted.")
}
}
Mugunth Kumar, Itty Bitty Apps, Melbourne
More code!
func features(from text: String) -> [String: Double] {
var wordCounts = [String: Double]()
tagger.string = text
let range = NSRange(location: 0, length: text.utf16.count)
tagger.enumerateTags(in: range, scheme: .nameType, options: options) { _, tokenRange, _, _ in
let token = (text as NSString).substring(with: tokenRange).lowercased()
guard token.count >= 2 else { return }
if let value = wordCounts[token] {
wordCounts[token] = value + 1.0
} else {
wordCounts[token] = 1.0
}
}
return wordCounts
}
Mugunth Kumar, Itty Bitty Apps, Melbourne
Performance
Mugunth Kumar, Itty Bitty Apps, Melbourne
Performance
» Reasonably fast.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Performance
» Reasonably fast.
» With more text, performance can take a hit
Mugunth Kumar, Itty Bitty Apps, Melbourne
Performance
» Reasonably fast.
» With more text, performance can take a hit
» As long as you avoid the main thread, you should
be good to go
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» Parts of speech analysis (and Language Tagging)
was introduced since iOS 5.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» Parts of speech analysis (and Language Tagging)
was introduced since iOS 5.
» All those calendar apps you saw were using this
feature to convert your natural language input
into a calendar or a reminder event.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» Parts of speech analysis (and Language Tagging)
was introduced since iOS 5.
» All those calendar apps you saw were using this
feature to convert your natural language input
into a calendar or a reminder event.
» You don't need a model file to do this. Everything
you need is built into the SDK.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» Parts of speech analysis (and Language Tagging)
was introduced since iOS 5.
» All those calendar apps you saw were using this
feature to convert your natural language input
into a calendar or a reminder event.
» You don't need a model file to do this. Everything
you need is built into the SDK.
» So why is this section in this talk?
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» In iOS 11, Parts of Speech Analysis was completely
reimplemented on top of Core ML framework
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» In iOS 11, Parts of Speech Analysis was completely
reimplemented on top of Core ML framework
» Language Tagging wasn't very accurate with some
Eastern European and Asian languages.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis
» In iOS 11, Parts of Speech Analysis was completely
reimplemented on top of Core ML framework
» Language Tagging wasn't very accurate with some
Eastern European and Asian languages.
» This is mostly fixed with Core ML in iOS 11
Mugunth Kumar, Itty Bitty Apps, Melbourne
Lets getour hands dirty!
func tags(from text: String) -> [[String: String]] {
var tagsToReturn = [[String: String]]()
tagger.string = text
let range = NSRange(location: 0, length: text.utf16.count)
// Tokenize and count the sentence
tagger.enumerateTags(in: range, scheme: .lexicalClass, options: options)
{ tag, tokenRange, _, _ in
let token = (text as NSString).substring(with: tokenRange).lowercased()
let tag = (tag?.rawValue ?? "")
tagsToReturn.append([token : tag])
}
return tagsToReturn
}
Mugunth Kumar, Itty Bitty Apps, Melbourne
Parts ofSpeechAnalysis Demo
Mugunth Kumar, Itty Bitty Apps, Melbourne
Mixingthemallup
There are plenty of research articles that argues
sentiment analysis is better done by emphasising
adverbs and adjectives.
Words like beautiful, useless, hopeless, gigantic
convey more "sentiment" information compared to
objects in a sentence like "Australia", "iPhone" or
subjects like "I", "You".
Ex: I can clearly say, Australia is one of the most
beautiful countries on the planet.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Lets getour hands dirty!
func featuresUsingTaggingAlgorithm(from text: String) -> [String: Double] {
let parsedTags = tags(from: text)
var wordCounts = [String: Double]()
for tag in parsedTags {
let (token, tag) = (tag.keys.first!, tag.values.first!)
var valueToAdd = Double(1.0)
if tag == "Adverb" {
valueToAdd = Double(30.0)
}
if tag == "Adjective" {
valueToAdd = Double(35.0)
}
if let value = wordCounts[token] {
wordCounts[token] = value + valueToAdd
} else {
wordCounts[token] = valueToAdd
}
}
return wordCounts
}
Mugunth Kumar, Itty Bitty Apps, Melbourne
MIX UPALGORITHM DEMO
Mugunth Kumar, Itty Bitty Apps, Melbourne
Features notyetavailable
Mugunth Kumar, Itty Bitty Apps, Melbourne
Features notyetavailable
» Retraining models is not possible (iOS 12 )
» Face Recognition can't be performed as of now
» Face Recognition first involves detection of
faces (available since iOS 6)
» Pass these as training data to a classifier
» Face Recognition is however available for the
native Photos app. So it is only a matter of
time.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Features notyetavailable
SARCASM DETECTION!
Mugunth Kumar, Itty Bitty Apps, Melbourne
Whatyou should knowbynow
Mugunth Kumar, Itty Bitty Apps, Melbourne
Whatyou should knowbynow
» Apple has very elegantly abstracted out the inner
workings that, most of Core ML is fairly straight
forward (codewise: under 10 lines) if you know the
foundations.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Whatyou should knowbynow
» Apple has very elegantly abstracted out the inner
workings that, most of Core ML is fairly straight
forward (codewise: under 10 lines) if you know the
foundations.
» Understanding the foundations will let you apply
Core ML in your app easily.
Mugunth Kumar, Itty Bitty Apps, Melbourne
Whatyou should knowbynow
» Apple has very elegantly abstracted out the inner
workings that, most of Core ML is fairly straight
forward (codewise: under 10 lines) if you know the
foundations.
» Understanding the foundations will let you apply
Core ML in your app easily.
» Using CoreML innovatively will help make your app
stand out from the crowd.
Mugunth Kumar, Itty Bitty Apps, Melbourne
That's ME!
I'm a
Mugunth Kumar, Itty Bitty Apps, Melbourne
That's ME!
I'm a
» Developer
Mugunth Kumar, Itty Bitty Apps, Melbourne
That's ME!
I'm a
» Developer
» Author of iOS Programming
Pushing the Limits
Mugunth Kumar, Itty Bitty Apps, Melbourne
That's ME!
I'm a
» Developer
» Author of iOS Programming
Pushing the Limits
» Currently baking some cool
apps @ Itty Bitty Apps,
Melbourne
Mugunth Kumar, Itty Bitty Apps, Melbourne
Questions?
Mugunth Kumar, Itty Bitty Apps, Melbourne

More Related Content

PPTX
AI and Python: Developing a Conversational Interface using Python
PPTX
Chatbot in the library
PPT
Bridging the virtual and the physical space : Kornelia - a chatbot for public...
PPTX
Artificially Intelligent chatbot Implementation
PDF
Introduction to chat bot
PDF
How to Make a Chatbot in Python | Edureka
PPTX
Chatbot ppt
PDF
Voice Tech TO #1
AI and Python: Developing a Conversational Interface using Python
Chatbot in the library
Bridging the virtual and the physical space : Kornelia - a chatbot for public...
Artificially Intelligent chatbot Implementation
Introduction to chat bot
How to Make a Chatbot in Python | Edureka
Chatbot ppt
Voice Tech TO #1

What's hot (11)

PPTX
Building bots to automate common developer tasks - Writing your first smart c...
PPTX
Chatbot and Virtual AI Assistant Implementation in Natural Language Processing
PPTX
Conversation UIs & Chatbots an introduction
PPTX
Using Machine Learning and Chatbots to handle 1st line Technical Support
PPTX
Build your first Chatbot
PPTX
Chatbot interfaces
PDF
Instant speech translation 10BM60080 - VGSOM
PDF
Chat bot technologies overview
PPTX
Final presentation on chatbot
PPTX
Computers have feelings too
PDF
Let's Build a Chatbot!
Building bots to automate common developer tasks - Writing your first smart c...
Chatbot and Virtual AI Assistant Implementation in Natural Language Processing
Conversation UIs & Chatbots an introduction
Using Machine Learning and Chatbots to handle 1st line Technical Support
Build your first Chatbot
Chatbot interfaces
Instant speech translation 10BM60080 - VGSOM
Chat bot technologies overview
Final presentation on chatbot
Computers have feelings too
Let's Build a Chatbot!
Ad

Similar to Using CoreML to Push the Limits of your App (20)

PDF
Quick Start Guide To Large Language Models Second Edition Sinan Ozdemir
PDF
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
PDF
Mobile App Development Company in Noida - Drona Infotech
PDF
eStudio34 presents London Search Love 2015 | Practical tips for the future o...
PDF
SearchLove London 2015 | Will Critchlow | Practical Tips for the Future of ...
PDF
Building a full-stack app with Golang and Google Cloud Platform in one week
PDF
Machine Learning vs. Deep Learning in Mobile App Development: Understanding t...
PDF
Build With AI - In Person Session Slides.pdf
PPTX
Google ML-Kit - Understanding on-device machine learning
PDF
ISS Art. How to do IT. Kotlin Multiplatform
PDF
Kotlin Indepth A Guide To A Multipurpose Programming Language For Serverside ...
PDF
Enterprise Trends for Gen AI - Berkeley LLM AI Agents MOOC
PDF
Add Machine Learning to your iOS 11 App Using Core ML
PDF
Machine Learning on iOS with Core ML
PDF
An Intelligent Chatbot for College Enquiry with Amazon Lex
PDF
How to Find the Best Kotlin Development Company.pdf
PDF
What Is Kotlin and Why Use It For App Development? - 2023 Guide
PDF
Large Language Modelsjjjhhhjjjjjjbbbbbbj.pdf
PDF
How to build and publish a google home app with dialogflow
PDF
Android study jam session 1
Quick Start Guide To Large Language Models Second Edition Sinan Ozdemir
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
Mobile App Development Company in Noida - Drona Infotech
eStudio34 presents London Search Love 2015 | Practical tips for the future o...
SearchLove London 2015 | Will Critchlow | Practical Tips for the Future of ...
Building a full-stack app with Golang and Google Cloud Platform in one week
Machine Learning vs. Deep Learning in Mobile App Development: Understanding t...
Build With AI - In Person Session Slides.pdf
Google ML-Kit - Understanding on-device machine learning
ISS Art. How to do IT. Kotlin Multiplatform
Kotlin Indepth A Guide To A Multipurpose Programming Language For Serverside ...
Enterprise Trends for Gen AI - Berkeley LLM AI Agents MOOC
Add Machine Learning to your iOS 11 App Using Core ML
Machine Learning on iOS with Core ML
An Intelligent Chatbot for College Enquiry with Amazon Lex
How to Find the Best Kotlin Development Company.pdf
What Is Kotlin and Why Use It For App Development? - 2023 Guide
Large Language Modelsjjjhhhjjjjjjbbbbbbj.pdf
How to build and publish a google home app with dialogflow
Android study jam session 1
Ad

More from Mugunth Kumar (6)

PDF
The new Apple TV and the tvOS
PDF
App store economics
PDF
Hi performance table views with QuartzCore and CoreText
PDF
Designing your API Server for mobile apps
KEY
My experience as a indie consultant
KEY
In App Purchases
The new Apple TV and the tvOS
App store economics
Hi performance table views with QuartzCore and CoreText
Designing your API Server for mobile apps
My experience as a indie consultant
In App Purchases

Recently uploaded (20)

PDF
System and Network Administration Chapter 2
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Transform Your Business with a Software ERP System
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
System and Network Administration Chapter 2
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Understanding Forklifts - TECH EHS Solution
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Transform Your Business with a Software ERP System
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Computer Software and OS of computer science of grade 11.pptx
PTS Company Brochure 2025 (1).pdf.......
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Reimagine Home Health with the Power of Agentic AI​
Digital Systems & Binary Numbers (comprehensive )
How to Migrate SBCGlobal Email to Yahoo Easily
CHAPTER 2 - PM Management and IT Context
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03
Softaken Excel to vCard Converter Software.pdf
Odoo Companies in India – Driving Business Transformation.pdf

Using CoreML to Push the Limits of your App

  • 1. Core MLandyourApp Howto use Core MLto pushthe limits Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 2. Agenda This talk explains how aspiring app developers/ companies can take full advantage of Core ML to push their apps to the next level. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 3. Agenda This talk explains how aspiring app developers/ companies can take full advantage of Core ML to push their apps to the next level. I'll introduce you to - The fundamentals of Core ML - What is possible with machine learning in iOS 11 - What is not possible with machine learning in iOS 11 Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 4. Agenda This talk explains how aspiring app developers/ companies can take full advantage of Core ML to push their apps to the next level. I'll introduce you to - The fundamentals of Core ML - What is possible with machine learning in iOS 11 - What is not possible with machine learning in iOS 11 Lastly, What could potentially be possible in a future release of iOS (12 and above ) Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 5. Agenda Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 6. Agenda » What is Core ML Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 7. Agenda » What is Core ML » Machine Learning in iOS 11 » Vision » Natural Language Processing Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 8. Agenda » What is Core ML » Machine Learning in iOS 11 » Vision » Natural Language Processing » Features not yet available » Retraining models (iOS 12 ) Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 9. Agenda » What is Core ML » Machine Learning in iOS 11 » Vision » Natural Language Processing » Features not yet available » Retraining models (iOS 12 ) » Questions Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 10. Core ML What is Core ML Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 11. Core ML What is Core ML » Core ML is a framework newly introduced in iOS 11 SDK Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 12. Core ML What is Core ML » Core ML is a framework newly introduced in iOS 11 SDK » Once considered complicated Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 13. Core ML What is Core ML » Core ML is a framework newly introduced in iOS 11 SDK » Once considered complicated » Once considered CPU intensive Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 14. Core ML What is Core ML » Core ML is a framework newly introduced in iOS 11 SDK » Once considered complicated » Once considered CPU intensive » Once considered impossible to be done on the client Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 15. Core ML What is Core ML » Core ML is a framework newly introduced in iOS 11 SDK » Once considered complicated » Once considered CPU intensive » Once considered impossible to be done on the client » Made easy in iOS 11 ! Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 16. Featuresavailabletodayin iOS 11 Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 17. Featuresavailabletodayin iOS 11 » Vision » Object Tagging and Recognition Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 18. Featuresavailabletodayin iOS 11 » Vision » Object Tagging and Recognition » Natural Language Processing » Sentiment Analysis » Language Tagging » Parts of Speech Analysis Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 19. Thistalk This talk is exclusively on NLP and text processing for two reasons. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 20. Thistalk This talk is exclusively on NLP and text processing for two reasons. » Plenty of libraries and blogs already exist on vision and Object Tagging. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 21. Thistalk This talk is exclusively on NLP and text processing for two reasons. » Plenty of libraries and blogs already exist on vision and Object Tagging. » Vision tagging model files are large (30MB to 200+ MB) and the "side" benefit you get using Core ML gets defeated. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 22. Thistalk This talk is exclusively on NLP and text processing for two reasons. » Plenty of libraries and blogs already exist on vision and Object Tagging. » Vision tagging model files are large (30MB to 200+ MB) and the "side" benefit you get using Core ML gets defeated. » As of iOS 11, you can't on the fly download a Core ML model on the fly like on-demand resource. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 23. Thistalk With Core ML and NLP, your app could do Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 24. Thistalk With Core ML and NLP, your app could do » Sentiment Analysis Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 25. Thistalk With Core ML and NLP, your app could do » Sentiment Analysis » Parts of Speech Analysis/Language Tagging Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 26. Thistalk With Core ML and NLP, your app could do » Sentiment Analysis » Parts of Speech Analysis/Language Tagging » Combining Both Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 27. Who can be benefitted bySentimentAnalysis Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 28. Who can be benefitted bySentimentAnalysis » Apps that show reviews Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 29. Who can be benefitted bySentimentAnalysis » Apps that show reviews » Social media account classifiers Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 30. Who can be benefitted bySentimentAnalysis » Apps that show reviews » Social media account classifiers » Pretty much any app that deals with lots of text from e-book readers to magazine apps Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 31. Getting Started You need a Core ML Model. You can download from Or you can convert using coremltools Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 32. Getting Started You need a Core ML Model. You can download from » https://developer.apple.com/machine-learning/ Or you can convert using coremltools Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 33. Getting Started You need a Core ML Model. You can download from » https://developer.apple.com/machine-learning/ » https://github.com/likedan/Awesome-CoreML-Models Or you can convert using coremltools Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 34. Getting Started You need a Core ML Model. You can download from » https://developer.apple.com/machine-learning/ » https://github.com/likedan/Awesome-CoreML-Models Or you can convert using coremltools » https://pypi.python.org/pypi/coremltools Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 35. SentimentAnalysis Demo Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 36. SentimentAnalysis Demo » For the demo, I'll be using one such model from the Awesome-CoreML-Models repo. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 37. SentimentAnalysis Demo » For the demo, I'll be using one such model from the Awesome-CoreML-Models repo. » Specifically SentimentPolarity.mlmodel by Vadym Markov. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 38. SentimentAnalysis Demo » For the demo, I'll be using one such model from the Awesome-CoreML-Models repo. » Specifically SentimentPolarity.mlmodel by Vadym Markov. » It's a very light weight model weighing in at 275Kb. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 39. SentimentAnalysis Demo Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 40. The Code! func predictSentiment(from text: String) -> Sentiment { do { var inputFeatures = features(from: text) guard inputFeatures.count > 1 else { throw Error.featuresMissing } let output = try model.prediction(input: inputFeatures) let positiveProb = output.classProbability["Pos"]! let negativeProb = output.classProbability["Neg"]! return Sentiment(positiveProbablity: positiveProb, negativeProbablity: negativeProb) } catch { preconditionFailure("Error occurred. Model file might be corrupted.") } } Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 41. More code! func features(from text: String) -> [String: Double] { var wordCounts = [String: Double]() tagger.string = text let range = NSRange(location: 0, length: text.utf16.count) tagger.enumerateTags(in: range, scheme: .nameType, options: options) { _, tokenRange, _, _ in let token = (text as NSString).substring(with: tokenRange).lowercased() guard token.count >= 2 else { return } if let value = wordCounts[token] { wordCounts[token] = value + 1.0 } else { wordCounts[token] = 1.0 } } return wordCounts } Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 42. Performance Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 43. Performance » Reasonably fast. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 44. Performance » Reasonably fast. » With more text, performance can take a hit Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 45. Performance » Reasonably fast. » With more text, performance can take a hit » As long as you avoid the main thread, you should be good to go Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 46. Parts ofSpeechAnalysis Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 47. Parts ofSpeechAnalysis Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 48. Parts ofSpeechAnalysis » Parts of speech analysis (and Language Tagging) was introduced since iOS 5. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 49. Parts ofSpeechAnalysis » Parts of speech analysis (and Language Tagging) was introduced since iOS 5. » All those calendar apps you saw were using this feature to convert your natural language input into a calendar or a reminder event. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 50. Parts ofSpeechAnalysis » Parts of speech analysis (and Language Tagging) was introduced since iOS 5. » All those calendar apps you saw were using this feature to convert your natural language input into a calendar or a reminder event. » You don't need a model file to do this. Everything you need is built into the SDK. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 51. Parts ofSpeechAnalysis » Parts of speech analysis (and Language Tagging) was introduced since iOS 5. » All those calendar apps you saw were using this feature to convert your natural language input into a calendar or a reminder event. » You don't need a model file to do this. Everything you need is built into the SDK. » So why is this section in this talk? Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 52. Parts ofSpeechAnalysis Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 53. Parts ofSpeechAnalysis » In iOS 11, Parts of Speech Analysis was completely reimplemented on top of Core ML framework Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 54. Parts ofSpeechAnalysis » In iOS 11, Parts of Speech Analysis was completely reimplemented on top of Core ML framework » Language Tagging wasn't very accurate with some Eastern European and Asian languages. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 55. Parts ofSpeechAnalysis » In iOS 11, Parts of Speech Analysis was completely reimplemented on top of Core ML framework » Language Tagging wasn't very accurate with some Eastern European and Asian languages. » This is mostly fixed with Core ML in iOS 11 Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 56. Lets getour hands dirty! func tags(from text: String) -> [[String: String]] { var tagsToReturn = [[String: String]]() tagger.string = text let range = NSRange(location: 0, length: text.utf16.count) // Tokenize and count the sentence tagger.enumerateTags(in: range, scheme: .lexicalClass, options: options) { tag, tokenRange, _, _ in let token = (text as NSString).substring(with: tokenRange).lowercased() let tag = (tag?.rawValue ?? "") tagsToReturn.append([token : tag]) } return tagsToReturn } Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 57. Parts ofSpeechAnalysis Demo Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 58. Mixingthemallup There are plenty of research articles that argues sentiment analysis is better done by emphasising adverbs and adjectives. Words like beautiful, useless, hopeless, gigantic convey more "sentiment" information compared to objects in a sentence like "Australia", "iPhone" or subjects like "I", "You". Ex: I can clearly say, Australia is one of the most beautiful countries on the planet. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 59. Lets getour hands dirty! func featuresUsingTaggingAlgorithm(from text: String) -> [String: Double] { let parsedTags = tags(from: text) var wordCounts = [String: Double]() for tag in parsedTags { let (token, tag) = (tag.keys.first!, tag.values.first!) var valueToAdd = Double(1.0) if tag == "Adverb" { valueToAdd = Double(30.0) } if tag == "Adjective" { valueToAdd = Double(35.0) } if let value = wordCounts[token] { wordCounts[token] = value + valueToAdd } else { wordCounts[token] = valueToAdd } } return wordCounts } Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 60. MIX UPALGORITHM DEMO Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 61. Features notyetavailable Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 62. Features notyetavailable » Retraining models is not possible (iOS 12 ) » Face Recognition can't be performed as of now » Face Recognition first involves detection of faces (available since iOS 6) » Pass these as training data to a classifier » Face Recognition is however available for the native Photos app. So it is only a matter of time. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 63. Features notyetavailable SARCASM DETECTION! Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 64. Whatyou should knowbynow Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 65. Whatyou should knowbynow » Apple has very elegantly abstracted out the inner workings that, most of Core ML is fairly straight forward (codewise: under 10 lines) if you know the foundations. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 66. Whatyou should knowbynow » Apple has very elegantly abstracted out the inner workings that, most of Core ML is fairly straight forward (codewise: under 10 lines) if you know the foundations. » Understanding the foundations will let you apply Core ML in your app easily. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 67. Whatyou should knowbynow » Apple has very elegantly abstracted out the inner workings that, most of Core ML is fairly straight forward (codewise: under 10 lines) if you know the foundations. » Understanding the foundations will let you apply Core ML in your app easily. » Using CoreML innovatively will help make your app stand out from the crowd. Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 68. That's ME! I'm a Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 69. That's ME! I'm a » Developer Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 70. That's ME! I'm a » Developer » Author of iOS Programming Pushing the Limits Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 71. That's ME! I'm a » Developer » Author of iOS Programming Pushing the Limits » Currently baking some cool apps @ Itty Bitty Apps, Melbourne Mugunth Kumar, Itty Bitty Apps, Melbourne
  • 72. Questions? Mugunth Kumar, Itty Bitty Apps, Melbourne