3 min to read
MAKING PREDICTIONS WITH TRAINED MODELS
Time to see the the magic ball.
Welcome to the last and very important video of the whole series and in this video we will be making predictions by using our trained models.
First of all we have to create a sample. It should be a numpy array we will be using
np.array() function and pass it a list of lists. There should be nine different numbers in our list because there were 9 features in our data. As we know that each of the attribute was in the range from one to ten the integers in the list should also be in the range from 1-10 just like the range of our data. The line of code below will just do the job:
Let’s make the first protection and making prediction is way too easy. We will store it in the variable
result and then use this function
model.predict() we will have to pass it sample and print the result like so.
0 gets printed out and we know that zero represents “Benign” tumors. Let’s do one thing to print the results in much more elegant way. We will create a list with two strings “Benign” and “Malignant”, so that the zeroth item is bening and first item is malignent. Then we will index out the results in such a way that it prints “Benign” and “Malignent” accordingly. See the updated piece of code below:
Now we can see that Benign is printed.
Finally let’s take a sample from our data to see that it is really making the correct preduction i-e
[3,1,1,1,2,2,3,1,1]. We will run the similar code:
It printed Benign.
After taking a quick look on the data we can figure out that the data points in which the feature values are closer to 10 are Malignent tumors. We can figure this out because our data is very simple for the sake of this beginner tutorieal.Let’s take another sample
[8,10,10,8,7,10,9,7,1] and this time the result should be Malignnent.
Wollah! the result is Malignent. That’s all for this whole series. You can check out the whole script of this code on this git hub repo.