Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
24 views
Lab Sheet 1
Uploaded by
syedkashif047
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Lab sheet 1 For Later
Download
Save
Save Lab sheet 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
24 views
Lab Sheet 1
Uploaded by
syedkashif047
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Lab sheet 1 For Later
Carousel Previous
Carousel Next
Save
Save Lab sheet 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 6
Search
Fullscreen
2123723, 11:48.AM py/t_linear_regression ipynb at master -codebasiesipy © codebasics / py Public <> Code © Issues so 17 Pullrequests 65 © Actions (Projects PB master + py/ML/ 1linear_reg / 1_linear_regression.ipynb gp dhavalsays Fixed issues in linear regression tutorial x1 contributor 749 Lines (748 sioc) | 26.6 KB hitpssgthub.convcodebasies/pyblobimasteriML/1_l CO wiki © Security WY In D History ws2123723, 11:48 AM py/t_linear_regression pynb at master - codebasiesipy Machine Learning With Python: Linear Regression With One Variable Sample problem of predicting home price in monroe, new jersey (USA) Below table represents current home prices in monroe township based on square feet area, new jersey 2600 550000 3000 565000 3200 610000 3600 680000 4000 725000 Problem Statement Given above data build a machine learning model that can predict home prices based on square feet ares You can represent values in above table as a scatter plot (values are shown in red markers) After that one can draw a straight line that best fits values on chart 725000 700000 675000 2 @ 650000 Qo “= 625000 a 600000 575000 550000} + 525000 2600 2800 3000 3200 3400-3600 3800 4000 area You can draw multiple lines like this but we choose the one where total sum of error is minimum hitpssigthub.convcodebasicsipyblobimasteriML/1_linear_eg/t_linear_regressionpynb 2162123723, 11:48 AM hitpssgthub.convcodebasiesipyblobimasteriML/1_l py/t_linear_regression pynb at master - codebasiesipy 725000 700000 675000 @ £0000 Minimize yy (ai? ¥ += 625000 00000 575000 550000 525000 2600 2800 3000 3200 3400 3600 3800 4000 area You might remember about linear equation from your high school days math class. Home prices can be presented as following equation, home price = m* (area) +b Generic form of same equation is, price = m*area+b y=mx+b 7 \ ‘Slope (or Gradient) Intercept Reference: htp://wurw.mathsistun.com/algobra/inear-equations. html import pandas as pd import nunpy as np from sklearn import Linear_nodel inport matplotlib.pyplot as plt dF = pd.read_csv(*honeprices.csv") oF area price293, 1148AM yt _tnear_seqression:pynb at master cosebasesipy © 2600 350000 1 3000 565000 2 3200 610000 33600 680000 4 4000 725000 XnatplotLib inline plt.xlabel( area") plt.ylabel( price’) ple. seatter(df.area,df.price,color="red' jnarker='+")
725000 > 700000 575000 “650000 5 25000 00000 75000 50000 | + 2600 2800 3000-3200 3400 3600 3800 4000 new_df = dF.drop(‘price’ ,axise'colums') new_of © 2600 1 3000 2 3200 3 3600 4 4000 price = df.price price 550000 565000 610008 680000 725008 lane: price, dtype: inte # Create Linear regression object reg = Linear model.LinearRegression() hitpssigthub.convcodebasicsipyblobimasteriML/1_linear_eg/t_linear_regressionpynb 462123723, 1148 AM hitpssgthub.convcodebasicsipyblobimasteriML/1_l py/t_linear_regression pynb at master - codebasiesipy reg. t1t(new_ct, price) LinearRegression(copy_XTrue, fit_intercept=True, n_jobs=None, normalize=False) (1) Predict price of a home with atea = 3300 sqr ft rreg-predict([[330@]]) array [628715.75342466]) reg.coef_ array ([135.78767123]) reg. intercest_ 180616. 43835616432 Y= m*X +b (mis coefficient and b is intercept) 3300*135.78767123 + 180616.43835616432 628715. 7534151643 (1) Predict price of a home with area = 5000 sqr ft reg. predict([[5@00]]) array([859554.79452055]) Generate CSV file with list of home price predictions area_éf = pd.read_csv("areas.csv") area_df.head(3) area © 1000 1 1500 2 2300 P= reg.predict (area_d#) P array([ 316404.10958904, 384297.94520548, 492928.08219178, 661304.79452055, 749061.64383562, 799808.21917808, 926890.75342466, 650441.78082192, 825607.87671233, 492928.08219178, 1402705.47945205, 1348390.4109589 , 11447¢8.90410959]) ar_r0g!1_linear_regressionipynb2123723, 1148 AM area_df[ ‘prices’ area_df 1 area 0 1000 1 1500 2 2200 3 3840 4 an20 5 4560 5490 3460 4750 2300 10 9000 118600 12 T00 prices 3.164041e+08 3.842979e+05 4929281¢+0¢ 5613048e+08 7.400616e+05 7.998082e+0¢ 9.260908e+ 05 5 504418e+08 8.256079e+0¢ 4929281¢+0¢ 1.402705e+06 113483900+06 1.148709e+06 py/t_linear_regression pynb at master - codebasiesipy area_df.to_csv("prediction.csv") Exercise Predict canada's per capita income in year 2020. There is an exercise folder here or github at same level as this notebook, download that and you will fine canada_per_capita_income.csv file. Using this build a regression model and predict the er capita income fo canadian citizens in year 2020 Answer 41288,69409442 hitpssgthub.convcodebasicsipyblobimasteriML/1_K
You might also like
1 - Linear - Regression - Ipynb - Colaboratory
PDF
No ratings yet
1 - Linear - Regression - Ipynb - Colaboratory
7 pages
Expt 7
PDF
No ratings yet
Expt 7
3 pages
House price prediction using Linear Regression
PDF
No ratings yet
House price prediction using Linear Regression
1 page
Ex No.: Date: Problem Statement
PDF
No ratings yet
Ex No.: Date: Problem Statement
3 pages
vertopal.com_2_linear_regression_multivariate
PDF
No ratings yet
vertopal.com_2_linear_regression_multivariate
2 pages
ML Regression
PDF
No ratings yet
ML Regression
9 pages
Estimation (Linear Regression) : Muhamad Fathurahman Data Mining Session 26-27 March 2020
PDF
No ratings yet
Estimation (Linear Regression) : Muhamad Fathurahman Data Mining Session 26-27 March 2020
18 pages
Ex 2
PDF
No ratings yet
Ex 2
3 pages
AI Lec 3
PDF
No ratings yet
AI Lec 3
36 pages
2 - Linear - Regression - Multivariate - Ipynb - Colaboratory
PDF
No ratings yet
2 - Linear - Regression - Multivariate - Ipynb - Colaboratory
4 pages
Exp4(Linear Regression)
PDF
No ratings yet
Exp4(Linear Regression)
2 pages
Predicting House Prices
PDF
No ratings yet
Predicting House Prices
9 pages
House Price Prediction: Group Name: Bug Free
PDF
No ratings yet
House Price Prediction: Group Name: Bug Free
32 pages
Price Prediction
PDF
No ratings yet
Price Prediction
4 pages
Exercise4 Solution
PDF
No ratings yet
Exercise4 Solution
20 pages
4 - Học Máy Cơ Bản - Hồi Quy Tuyến Tính
PDF
No ratings yet
4 - Học Máy Cơ Bản - Hồi Quy Tuyến Tính
113 pages
Lab 3 - Linear Regression
PDF
No ratings yet
Lab 3 - Linear Regression
15 pages
Regression Algorithm
PDF
No ratings yet
Regression Algorithm
9 pages
Phase 5
PDF
No ratings yet
Phase 5
5 pages
01.multiple Linear Regression - Ipynb - Colaboratory
PDF
No ratings yet
01.multiple Linear Regression - Ipynb - Colaboratory
10 pages
AI lab7
PDF
No ratings yet
AI lab7
13 pages
ML Lab-3
PDF
No ratings yet
ML Lab-3
14 pages
Lab 2 Linear Regression Representation
PDF
No ratings yet
Lab 2 Linear Regression Representation
6 pages
f3683849-7ca6-4854-8f96-af11b6e837ec
PDF
No ratings yet
f3683849-7ca6-4854-8f96-af11b6e837ec
20 pages
2. Machine Learning Part 1 - Regression.pptx (2)
PDF
No ratings yet
2. Machine Learning Part 1 - Regression.pptx (2)
63 pages
Document From Jahnavi
PDF
No ratings yet
Document From Jahnavi
20 pages
1 Tutorial: Linear Regression
PDF
No ratings yet
1 Tutorial: Linear Regression
8 pages
Regression House Price
PDF
No ratings yet
Regression House Price
34 pages
C1 W1 Lab03 Model Representation Soln-Copy1
PDF
No ratings yet
C1 W1 Lab03 Model Representation Soln-Copy1
7 pages
Linear Regression Program So Far
PDF
No ratings yet
Linear Regression Program So Far
33 pages
USA Real Estate Price Prediction Using Decision Tree Regressor, and AdaBoost Regressor
PDF
No ratings yet
USA Real Estate Price Prediction Using Decision Tree Regressor, and AdaBoost Regressor
14 pages
AIML
PDF
No ratings yet
AIML
5 pages
ML Practical 04
PDF
No ratings yet
ML Practical 04
19 pages
C1 W1 Lab02 Model Representation Soln
PDF
No ratings yet
C1 W1 Lab02 Model Representation Soln
5 pages
Regression (1)-1-4
PDF
No ratings yet
Regression (1)-1-4
4 pages
Linear Regression
PDF
No ratings yet
Linear Regression
15 pages
UtkarshGupta (House Price Prediction)
PDF
No ratings yet
UtkarshGupta (House Price Prediction)
14 pages
Linear Regression in python
PDF
No ratings yet
Linear Regression in python
9 pages
Comparing Linear Regression and Decision Trees For Housing Price Prediction
PDF
No ratings yet
Comparing Linear Regression and Decision Trees For Housing Price Prediction
8 pages
03 Linear Regression Intuition
PDF
No ratings yet
03 Linear Regression Intuition
23 pages
Linear Regression Explained PDF
PDF
No ratings yet
Linear Regression Explained PDF
1 page
ML LinearRegression
PDF
No ratings yet
ML LinearRegression
10 pages
Implementation of Linear Regression With Python
PDF
No ratings yet
Implementation of Linear Regression With Python
5 pages
C1 W1 Lab02 Model Representation Soln
PDF
No ratings yet
C1 W1 Lab02 Model Representation Soln
7 pages
Introduction To Machine Learning (ML) With Sklearn
PDF
No ratings yet
Introduction To Machine Learning (ML) With Sklearn
10 pages
C1 W1 Lab02 Model Representation Soln
PDF
No ratings yet
C1 W1 Lab02 Model Representation Soln
7 pages
C1 W1 Lab02 Model Representation Soln
PDF
No ratings yet
C1 W1 Lab02 Model Representation Soln
5 pages
House Price Prediction PyCharm
PDF
No ratings yet
House Price Prediction PyCharm
9 pages
IoT Task4 21BEC0384
PDF
No ratings yet
IoT Task4 21BEC0384
9 pages
Aastha Mahajan Python File
PDF
No ratings yet
Aastha Mahajan Python File
17 pages
CS435 Ch6
PDF
No ratings yet
CS435 Ch6
14 pages
Prediction of House Rent Using Multiple Linear Regression
PDF
No ratings yet
Prediction of House Rent Using Multiple Linear Regression
20 pages
DSBDAL_Assignment no 4
PDF
No ratings yet
DSBDAL_Assignment no 4
15 pages
California Housing Price Prediction .
PDF
No ratings yet
California Housing Price Prediction .
1 page
Copy of Project 4 _ House Price Prediction.ipynb - Colab
PDF
No ratings yet
Copy of Project 4 _ House Price Prediction.ipynb - Colab
5 pages
Linear Regression Code
PDF
No ratings yet
Linear Regression Code
5 pages
T2_summary_VHA
PDF
No ratings yet
T2_summary_VHA
14 pages
AIand MLlab 5
PDF
No ratings yet
AIand MLlab 5
10 pages
Machine Learning Regression
PDF
No ratings yet
Machine Learning Regression
64 pages