Linear Regression

 

Linear Regression Using SKlearn



We will predict the hosing price here by creating Machine Learning's Linear Regression Model.

let's start :

First we import the necessary library 


Now we import the data from csv file. You can import csv file in python using pandas library's read_csv  method.




lets visualise the data using matplotlib library



we have to supply X & Y variable  means independent and dependent variable in leaner model so here independent variable is area and we will here predict price of home using area so price is depend on area size so price is dependent variable.



you can drop column in pandas using drop  method . here x = new_df & y = df.price

Now we build a leaner regression model 


here we have to pass our x & y in fit method which will train our model.

Lets predict the price of house which have 5000 sqft area.


Predict method always accept 2D Array thats why we use double bracket here. price of 5000 sqft area house is 859554 . 


You can download the data(CSV File) here.

If you want this code click here to download my github repo.







Comments

Popular posts from this blog

Multivariate logistic regression in Python

Decision tree for titanic dataset in Python

K Means Cluster Algorithm