Transcript
[ Music ]
[ Applause ]
>> Hello. I'm Hoyt, from the
Turi team at Apple, and I'm here
to tell you about the Create ML
Recommender.
Create ML Recommenders are a
fantastic way to add
personalization and intelligence
into the user experience of your
app.
Suppose I have a hiking journal
where I can log different hikes
I've taken and how much I like
or dislike each of them.
Wouldn't it be great if this
also recommended new trails for
me to try based on the
preferences I already expressed?
Or suppose I have a math quiz
app, where the user has to solve
a number of math problems in a
timed session.
It would make sense here to
choose the next problem to ask
based on which of the previously
problems the user got correct or
incorrect.
Or let's take a look at a
shopping list where I can list
out the ingredients I need to
buy the next time I go to the
grocery store.
Now, this is really simple here.
But if it suggested ingredients
that I may have forgotten, it
makes the experience more
engaging and interesting.
My goal today is to enable you
to create these kind of user
experiences in your app through
the Create ML recommender.
Let's dive into how we're going
to do this and let's start with
the data.
Recommenders work by looking for
patterns in groups of items.
Back to the shopping list.
When I'm going to the grocery
store, it's likely I have a few
recipes in mind.
I want to buy the ingredients
for them and make something
delicious.
And, well what are recipes?
They are groups of ingredients.
And it turns out this is a
perfect example of the kind of
data you can use for
Recommender.
In fact, all you need to do here
is to take these recipes and
turn them into a table with a
group column and an item column.
Each row here says that a
particular item belongs to a
particular group.
Now, here the groups are recipes
and the items are ingredients.
But this can be much more
general.
Let's go to the math quiz app.
Here, the group can be the
particular session that a
problem was asked in.
The item is the problem.
And, well, I need to introduce
one more concept here.
We need to be able to give the
model feedback.
We need to tell it which
problems the user got correct or
incorrect.
And so the Recommender also
works with a rating column.
A rating is a measure of how
good or how desirable a
particular interaction is.
Here, we could assign a 1 if the
user got the problem correct, or
a 0 if they got it wrong.
Now, with the hiking app, the
data there has the user, has the
group being the user, the trail
being the item, and a rating
being an explicit feedback from
the user about how much they
liked or disliked that
particular trail.
Now, in your app, you would
query it with the same kind of
data.
You would locally track these
interactions and you would feed
in a set of items or item rating
pairs to your model.
Your model would then recommend
new items based on the
preferences and patterns
expressed in your input data.
Let's see this particular one in
action.
So, I have here a simple hiking
journal.
I don't have any hikes logged
yet and so it's actually
recommending popular items,
things that get consistently
high ratings.
Let's go see if there's any
interesting ones in here.
Well, I'm adventurous, let's try
this one.
Well, okay.
Actually too hot, too dry.
Didn't really like it.
So, I'm going to say it's not
for me.
Now, what we see here is that
this hiking journal has now
updated the hikes based on the
preferences I've expressed
already.
It's recommending different
landscapes.
Ah. This one looks really nice.
I grew up in Colorado.
I love aspens, I love tall
mountains.
Let's try it.
Okay. It was fantastic.
Loved it. And here the model is
learning more about my
preferences now.
It knows I like mountains,
rocks, and colorful foliage.
So, let's try another one.
All right.
There we go.
Now I'm exhausted.
Three hikes in one day.
That's quite a bit [laughter].
Let's go back to the slides
here.
[ Applause ]
Now, I already showed you an
example of the type of data used
to train this particular model.
Now I would like to dive into
how the Create ML Recommender
extracts the patterns from this
data and builds a model that you
can use in your app.
The Create ML Recommender works
by learning relationships
between the items.
What items tend to go with what
other items?
Let's suppose we have three
hikes here.
Two of these are up tall, steep,
mountain peaks, possibly the
kind I would like.
And one of these is a nice
stroll by a sandy beach.
Now, that information is not
actually present in the model.
All we have are hikers, trails,
and ratings.
However, if you like climbing
these tall mountain peaks, it's
likely you would give both of
these similar ratings.
And so what we would see in the
data is that the same hiker
would give each of these hikes
similar ratings.
Likewise, because you go out and
enjoy a nice stroll by the
beach, it doesn't necessarily
mean you want to climb a tall,
cold, windy mountain.
And, or vice versa.
And so you may give these two
trails different ratings.
The Create ML Recommender would
find these patterns in the data
and learn that these first two
hikes are similar to each other.
They tend to go together.
And the third one is different.
Now, when you throw all the
items into the mix, the
Recommender builds a graph of
which items tend to go with
which other items.
How they're all related.
And it's this graph that gets
packaged into your model.
All of the user data and the
group data present in your
training data is not explicitly
present in the final model.
Now, to do this in your app, the
easiest way to build this model
is through the Recommender
template in the Create ML app.
That, like all of the other
templates, guides you through
the process of loading your
data, building your model,
evaluating your model's
performance, and exporting your
model to Core ML.
Now, if you want to do it
programmatically, this is also
possible through the Create ML
framework.
And here the process is the
same.
First we load our training data
from a CSV file or a JSON file.
We then specify what the group
or user column, what's the item
column, and optionally, which is
the rating column.
If we have data that's not
present in the training data, we
can evaluate how well our model,
how accurately our model can
anticipate those new data by
using the model evaluate method.
And finally, we can write this
model out to Core ML.
Now, in your app, you would
locally track the interactions.
If your model uses ratings, you
would track a dictionary of
items to ratings.
Otherwise, you would simply use
a list of items.
Then, you would construct the
input to your model by also
specifying how many items you
wanted to recommend.
And finally, your model will
return a ranked list of
suggested items based on the
input preferences it believes
most go with your input set.
Let me wrap this up with a few
final considerations here.
First, these models are very
flexible.
They can be used in many
scenarios that don't fall into
the traditional user, item,
rating system of recommenders.
We, I gave you several examples
here but I'm excited to see how
you as creative app developers
can incorporate this into the
user experiences of your app.
Second, these models shift with
your app.
That means they're on the device
and they work offline and
they're fast.
It's perfect for just adding
that touch of personalization
into your user experience.
Finally, because they are with
your app and work offline, that
means they're also privacy
preserving.
That way you can guarantee to
your users that their data is
secure, even though the app
adapts and responds to their
preferences.
Finally, to wrap up this entire
session, you heard about some
amazing new advances in text
classification that allow us to
take advantage of the semantic
meaning of the text, even with
the limited amount of input
data.
You also heard about the new
activity classification, which
allows you to understand and
assign meaning to the motion and
activities of your user.
And finally, I just introduced
the recommender which allows you
to personalize the user
experience of your app into the
many, many different ways.
For more information on any of
these things, please visit the
website associated to this
session, or come talk to us in
the lab tomorrow.
Thank you.
[ Applause ]