Testing of Perceptron ModelThe purpose of the perceptron model is to classify our data and tell us about the chances of cancer, i.e., maximum or minimum on the basis of previously labeled data. Our model is trained, and now, we test our model to know about its work smoothly and give an accurate result or not. For this purpose, we have to add some more functionality in our code. There are the following steps to test our model: Step 1 We will re-plot our fitted model, and for this, we have to make a prediction on a random point which we will initialize. In our case, We will take two points for better understanding. Step 2 Now, our next step is to plot these points for visualization purpose so that we can determine both the points are in which class either 1 or 0. The point p1 and p2 are initially in the form of tensor, so we changed these points into numpy by typecasting. Step 3 We can now make a prediction on each point. We will predict the probabilities of each point belong to the positive region 2 class 1. We know all the orange points are labeled as 1, and all the blue points are labeled as 0. So the probability is determined as The probability of red and black points is equal to its prediction. Step 4 Now, we will going back to our class initialization and create a method called predict which have a parameter. We use self.forward(x) to find the probability. If probability is greater then 0.5 then we will return class 1 otherwise return 0. Step 5 At last we will add two more print statement which tell us about the class using predict method as It's clear that our model works smoothly and give us an accurate result with random data. Complete CodeOutput |
Ansible
Mockito
Talend
Azure
SharePoint
Powershell
Kali Linux
OpenCV
Kafka
Pandas
Joomla
Reinforcement