Hello and welcome back.
In other videos we show you how to import data, visualize data, or create a model.
In this video we will focus on applying a model.
If you want to follow along you can download the data file and import it.
The 'Data loading process'-video will show you how it is done and how you can import the 'process'-files as well.
So let's get started.
First thing we will do is to create a copy of one of our previous processes,
namely '02 build decision tree model' as the basis for our next actions.
So we right click it and select 'copy'.
To paste it into our existing folder we can just right click the subfolder 'processes' and select paste.
Then we chose 'Insert copy of entry' and finally we rename our process
- again by using the right mouse button - and call it: '03 apply the model'.
So, why do we call it ‘apply the model’?
In the video on how to create a model we built a 'decision tree' and we talked a little bit about, how,
based on our sample of data, somebody belongs to a certain branch based on their gender, age,
and last transaction characteristics.
But, following the tree for every customer by just doing it by hand is a tedious way of doing things.
Hence, now we want to do it automatically using RapidMiner Studio
and this action is commonly referred to as 'applying a model'.
Okay so let's review the steps which our process does for us so far.
The process loads in data, then filters out some of the examples and creates a decision tree.
To get a preview on the data we can hover over the 'out' port of the 'retrieve' operator
and the hit the 'F3'-key to pin the pop-up.
We can see now where the data has come from, how many attributes we have and that 'Churn'
is our special attribute - with the role 'label' - for which we want to predict the 96 missing examples.
The 'filter examples' operator was used to remove the examples without information in the 'label',
before we built the model to predict the missing information for those examples.
So now we need to separate out from our data those customers, which we want to predict -
which we want to label as potential 'Loyal' or 'Churn' customers.
To do so we will create a second branch, where we only filter out and keep the missing ones
to which we can apply the model we built in the first branch.
So how will we do that?
Quite easily, let's go ahead and select these operators here by dragging a window
and just moving them a little bit down the connection.
And since we're going to use another 'filter example' operator,
let's go look for that now and drag it into the process panel.
Before we define the connection between the operators there is one thing to keep in mind.
In RapidMiner one output-port can only be connected to one other port.
If I connect the 'retrieve'-operator with our new 'filter'-operator then the other one disconnects automatically.
Well is there a way that I can make a copy of this data and feed one branch into here
and another branch into here?
Yes, the way we do that is with the 'multiply' operator.
You can do it buy getting it from the 'operators'-panel, but RapidMiner has another,
very handy way of making a multiplication.
If I just drag this connection again over here now to the 'filter example', then you'll see another little icon show up
If you click on this icon it will create a second branch, by making a copy of the data,
through automatically applying the 'multiply'-operator.
But this looks a little bit messy, so let's go use our right mouse button to clean this up.
Hover over on this output port, right click and disconnect.
Oh - RapidMiner already moved the remaining connection to the top position, and left me another port.
Let's reconnect that one then to our new 'filter'-operator and then we can proceed to set the parameters.
Remember, we only want the examples with a 'missing entry' in the label to remain in the second example-set.
We will select the 'add filters' and will set it to the 'churn' attribute and then choose the option: 'is missing'.
Now let's hit okay and let's connect the branch to the results.
Let's briefly review before we hit the 'run process' button.
The process we created will retrieve the data and will make two copies of it.
It will then filter out for one example-set the 'loyal' and 'churn' and keep them to build a 'decision tree'
and create another branch which will only filter out the missing values
and will port them both together over here.
Let's run the process now and let's inspect the data.
Great, you can see here that I have 96 examples and they have nothing in the 'churn'-column.
Great, and of course from the other branch we have our 'decision tree' tab here,
which we inspected and discussed in the respective video.
We have to do one more step now.
Let's go back to the design view.
Now what we need to do, is we need to take the model that we built in the upper branch
and we need to apply it to the un-scored example set of the lower branch,
so we can score or put those examples into the 'loyal' or 'churn' bucket.
If you listened carefully you just heard me basically say that we need to 'apply the model'.
And if you look to the 'Recommended operators' tab you can immediately see that 'apply model'
is for us the next recommended step by our 'Wisdom of the crowds'.
I am saying next step even though we see two other recommendations first
but we already know that we will use all attributes and we had already defined the role during loading.
So let's pull in 'apply model' and drop it on the upper branch where it can pick up the model information.
Now to combine the upper and lower branch we can just drag the operator with
the connection down here and drop it on the lower branch.
So what did RapidMiner do here?
It automatically connected the 'MOD' - which stands for 'model' - output to the MOD input
of our 'apply model' operator.
Then, when we dropped it on the lower branch it connected EXA output
- which are our examples after filtering - and connected them to the UNL port.
UNL stands for 'Unlabeled' data, which are our examples with 'missing' or 'Question mark' in the 'label'-attribute
- in our case the label we are looking for is 'churn' or 'loyal'.
So let's switch back and take a look at the output of the 'apply model' operator.
So this output part will now give us predicted 'labels' for our examples and
the second connection will output the model again too.
Let take a moment to save our process first before running it.
I am doing it with shortcuts this time - first control-S or Command-S - and the F11.
Congratulations we just did some predictions.
Now let's take a look at the results.
I have my churn-attribute - which we defined as 'label' - with the missing entries,
and also I have three new special attributes.
I have a prediction attribute. And I have confidence, for 'loyal' and a confidence for 'churn'.
For this example, the model is predicting that, this candidate - who is female, 39 and paid by credit card,
and has at last transaction of 177 days - will 'churn'.
It has a 79.8% confidence, that it has correctly put them in that 'churn'-bucket.
But what about the ones that are loyal?
Let's come down here to this person.
The model says it has a 89% confidence that it is a 'loyal' person, who happens to be male, 63,
and paying by credit card.
Congratulations on your first prediction - on applying and scoring the data.
The next step in the 'predictive Analytics Lifecycle' is to actually validate your results,
to get a true perspective on how good your model is, before you can operationalize it.
Because ultimately you want to have the confidence, that the model is correct
and will give you the correct predictions going forward.
Thank you very much for watching!