Prediction and linear class
In this, we took a brief introduction to implement a machine learning based algorithm to train a linear model to fit a set of data points.
For this purpose, there is no need to have any prior knowledge of deep learning. We will start with the discussion of supervised learning. We will discuss the notion of supervised learning and how it relates to it.
Machine learning is an application of AI. ML (Machine Learning) provides systems the ability to learn and improve with the help of experience automatically. ML focuses on the development of computer programs which can access data and use it for themselves to learn.
The process of learning begins with data or observation, such as examples, instructions or direct experience, in order to look for patterns in data and make better decisions in the future based on the examples which we provide. Its aim is to allow the computers to learn automatically without human intervention and adjust actions accordingly.
As the name indicates about the presence of a supervisor as a teacher. In supervised learning, we train or teach the machine using well-labeled data. Well labeled means few of the data is already tagged with the correct answer. After that, the machine is provided with a new set of data. Supervised learning algorithm analyses the training data and produces a correct outcome from labeled data.
Supervised learning is classified into two broad categories of algorithm:
In unsupervised learning, the machine is trained using information which is neither classified nor labeled and allow the algorithm to act on that information without guidance. In unsupervised learning, the task is to group unsorted information according to similarities, differences, and patterns without any prior training of data.
There is no supervisor, which means no training will be given to the machine. So, the machine is restricted to find the hidden structure by itself.
Unsupervised learning is classified into two broad categories of algorithm:
Making Prediction (Creating Data Model)
Making a prediction is the initial step of making a linear regression model. In a linear regression model, we use supervised learning because regression is its second broad category. So the learner is trained and makes use of data sets associated with labeled features which define the meaning of our training data.
The learner is able to predict a corresponding output before giving the newly input data to the machine.
Steps to find the prediction
Let see an example to understand how prediction is made in linear regression.
For single data
For multiple data
tensor([[13.], [16.], [19.]], grad_fn=<AddBackward0>)
Prediction using linear class
There is another standard way of binding prediction. For this, we have to import the linear class of torch.nn package. In this, we use manual_seed() method to generate random numbers. When we are creating a model with linear class, it will be given random number values for the linear class, which makes sense since the recall.
Let see an example of how prediction is made with the model and manual_seed() method.
For single data
<torch._C.Generator object at 0x000001FA018DB2B0> Parameter containing: tensor([-0.4414], requires_grad=True) Parameter containing: tensor([[0.5153]], requires_grad=True) tensor([0.5891], grad_fn=<AddBackward0>)
For multiple data
<torch._C.Generator object at 0x00000210A74ED2B0> Parameter containing: tensor([-0.4414], requires_grad=True) Parameter containing: tensor([[0.5153]], requires_grad=True) tensor([[0.5891], [1.6197], [2.6502]], grad_fn=<AddmmBackward>)
Next TopicCustom Module (Creating Data Model)