Simple Linear Regression using Python - Train Test Set

3 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€44.05
List Price:  €61.68
You save:  €17.62
£37.58
List Price:  £52.62
You save:  £15.03
CA$69.44
List Price:  CA$97.22
You save:  CA$27.78
A$78.41
List Price:  A$109.78
You save:  A$31.37
S$65.75
List Price:  S$92.05
You save:  S$26.30
HK$387.76
List Price:  HK$542.90
You save:  HK$155.13
CHF 41.54
List Price:  CHF 58.16
You save:  CHF 16.61
NOK kr522.97
List Price:  NOK kr732.21
You save:  NOK kr209.23
DKK kr328.90
List Price:  DKK kr460.49
You save:  DKK kr131.58
NZ$83.99
List Price:  NZ$117.60
You save:  NZ$33.60
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.46
৳6,091.40
List Price:  ৳8,528.46
You save:  ৳2,437.05
₹4,271.75
List Price:  ₹5,980.80
You save:  ₹1,709.04
RM218.65
List Price:  RM306.13
You save:  RM87.48
₦80,730.85
List Price:  ₦113,029.65
You save:  ₦32,298.80
₨14,091.30
List Price:  ₨19,728.96
You save:  ₨5,637.65
฿1,677.91
List Price:  ฿2,349.21
You save:  ฿671.30
₺1,920.75
List Price:  ₺2,689.20
You save:  ₺768.45
B$284.04
List Price:  B$397.68
You save:  B$113.64
R945.21
List Price:  R1,323.38
You save:  R378.16
Лв86.13
List Price:  Лв120.59
You save:  Лв34.45
₩71,921.98
List Price:  ₩100,696.53
You save:  ₩28,774.54
₪180.85
List Price:  ₪253.20
You save:  ₪72.35
₱2,814.26
List Price:  ₱3,940.19
You save:  ₱1,125.93
¥7,179.56
List Price:  ¥10,051.96
You save:  ¥2,872.40
MX$983.64
List Price:  MX$1,377.18
You save:  MX$393.53
QR182.75
List Price:  QR255.87
You save:  QR73.11
P686.29
List Price:  P960.87
You save:  P274.57
KSh6,463.70
List Price:  KSh9,049.70
You save:  KSh2,586
E£2,547.49
List Price:  E£3,566.69
You save:  E£1,019.20
ብር6,681.17
List Price:  ብር9,354.18
You save:  ብር2,673
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$46,812.37
List Price:  CLP$65,541.06
You save:  CLP$18,728.69
CN¥364.27
List Price:  CN¥510.01
You save:  CN¥145.74
RD$2,975.10
List Price:  RD$4,165.38
You save:  RD$1,190.28
DA6,619.03
List Price:  DA9,267.17
You save:  DA2,648.14
FJ$112.99
List Price:  FJ$158.20
You save:  FJ$45.20
Q386.10
List Price:  Q540.58
You save:  Q154.47
GY$10,489.05
List Price:  GY$14,685.51
You save:  GY$4,196.46
ISK kr6,375.22
List Price:  ISK kr8,925.82
You save:  ISK kr2,550.60
DH464.99
List Price:  DH651.02
You save:  DH186.03
L862.86
List Price:  L1,208.08
You save:  L345.21
ден2,708.74
List Price:  ден3,792.46
You save:  ден1,083.71
MOP$400.53
List Price:  MOP$560.77
You save:  MOP$160.24
N$935.59
List Price:  N$1,309.90
You save:  N$374.31
C$1,838.46
List Price:  C$2,573.99
You save:  C$735.53
रु6,841.02
List Price:  रु9,577.98
You save:  रु2,736.95
S/185.02
List Price:  S/259.04
You save:  S/74.02
K207.50
List Price:  K290.52
You save:  K83.01
SAR187.51
List Price:  SAR262.53
You save:  SAR75.02
ZK1,410.01
List Price:  ZK1,974.13
You save:  ZK564.11
L219.29
List Price:  L307.02
You save:  L87.73
Kč1,100.07
List Price:  Kč1,540.19
You save:  Kč440.12
Ft17,940.87
List Price:  Ft25,118.65
You save:  Ft7,177.78
SEK kr485.01
List Price:  SEK kr679.06
You save:  SEK kr194.04
ARS$58,712.48
List Price:  ARS$82,202.17
You save:  ARS$23,489.69
Bs346.41
List Price:  Bs485.01
You save:  Bs138.59
COP$215,920.08
List Price:  COP$302,305.39
You save:  COP$86,385.31
₡25,270.56
List Price:  ₡35,380.81
You save:  ₡10,110.24
L1,299.69
List Price:  L1,819.68
You save:  L519.98
₲401,259.06
List Price:  ₲561,794.79
You save:  ₲160,535.73
$U2,086.69
List Price:  $U2,921.54
You save:  $U834.84
zł188.24
List Price:  zł263.56
You save:  zł75.31
Already have an account? Log In

Transcript

Okay in Python to create a testing set in the training set we can do something like this. So I will say we can do something like x equal the data pylon okay and n minus three k W's and y equal the one I love okay then two dot values okay so we These are x&y then I can print the s and the y I'm praying a lie KK s and I have the why. So I want to see the original data. So this is the original data here. So in original data are all five variables one variable two variable, three variables variable by variable. So for these are the ones I look, here, i minus three means that I'm going to take from minus one minus two minus three, so I only be taking this variable and this second variable here.

Then for these are a lot to be taken into one to this variable. So for the y, so I print s and y have something like this S and then I have y here. So, if I say I want to spray the training say to spray the data into training saying testing set, I can do something IDs s train, an S test. Why train and why test equal to equal to this train test, train test spread and x y, the test size I say to 0.2 and then the ram density is zero. So, what this means is that, for this data set I'm going to To take 0.2 or 20% for testing set and then I'm and then I'm going to take a deeper sample the training set Okay, so for these are SSI you're 80% for training and 20% for testing set. So, to use this train test function here, I will need to import this function from this our SK learn model selection library okay so a test say I want to create a linear model, I will need to import linear model from the SK learn library.

So we go into the linear model in our next

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.