Model Development in Python

Once we have processed the data, the next step is the development of the Model. The Model will then be trained and after that will start making the predictions for us for the given input features.

Model Development in Python
Model Development in Python

A Model can be thought of as a mathematical equation used to predict a value given, one or more other values. It relates one or more independent variables to dependent variables.

1) Linear Regression

Simple linear regression is a method to help us understand the relationship between two variables.

Lets say X is the predictor or the independent variable and Y is the target or the dependent variable.

First step in python:

from sklearn.linear_model import LinearRegression

We define the predictor variable and target variable.


We create the linear regression object.


We then fit the train X and Y data in it.,Y)

We then make the predictions.


The prediction gives the price of laptops for which it was not trained for. We can compare the prediction price of the laptop with the actual price to see how good our model is.

2) Multiple Regression

It is same as Linear Regression except that there are multiple linear equation variables for making the predictions.

3) Polynomial Regression

Polynomial Regression is a particular case of the general linear regression model or multiple linear regression models. We get non-linear relationship by squaring or setting higher order terms of the predictor variables.

How to create a PolynomialFeatures object of degree 2?

from sklearn.preprocessing import PolynomialFeatures



How to fit the data?

It is done as follows:

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import StandardScaler

For simplifying the data for processing we perform the following steps.

Input=[('scale',StandardScaler()), ('polynomial', PolynomialFeatures(include_bias=False)), ('model',LinearRegression())]



Here we have developed the model and got the predicted output. But are the predicted outputs correct. To do this we evaluate our model to check its accuracy. We shall see the model evaluation in the next blog article.


Popular posts from this blog

How to remove powered by Blogger?

15 Harmful effects of Cigarette Smoking

33 Interesting English Alphabet Facts

What is Data Science Methodology?

10 Home Remedies For Pimples and Acne

38 Interesting Cheesecake Facts

Are earphones good for your ear