In this assignment you will use pandas, numpy and matplotlib to experiment with a data set of cars. The data set has a number of attributes about the cars such as Number of cylinders and Horse Power along with the corresponding gas consumptions in Miles per Gallon. The intent is to use all the other attributes of a car to predict its gas mileage. We will first explore the data set using pandas. We will then extract the attributes (i.e., independent variables) and the gas mileage (i.e., dependent variable) as numpy arrays. We will use numpy to replace any missing data. We will then implement the linear regression normal equation using numpy and apply it to the mpg data
Assignment 2/mpg.csv cylinders,displacement,horsepower,weight,acceleration,MPG 8,307,130,3504,12,18 8,350,165,3693,11.5,15 8,318,150,3436,11,18 8,304,150,3433,12,16 8,302,140,3449,10.5,17 8,429,198,4341,10,15 8,454,220,4354,9,14 8,440,215,4312,8.5,14 8,455,225,4425,10,14 8,390,190,3850,8.5,15 8,383,170,3563,10,15 8,340,160,3609,8,14 8,400,150,3761,9.5,15 8,455,225,3086,10,14 4,113,95,2372,15,24 6,198,95,2833,15.5,22 6,199,97,2774,15.5,18 6,200,85,2587,16,21 4,97,88,2130,14.5,27 4,97,46,1835,20.5,26 4,110,87,2672,17.5,25 4,107,90,2430,14.5,24 4,104,95,2375,17.5,25 4,121,113,2234,12.5,26 6,199,90,2648,15,21 8,360,215,4615,14,10 8,307,200,4376,15,10 8,318,210,4382,13.5,11 8,304,193,4732,18.5,9 4,97,88,2130,14.5,27 4,140,90,2264,15.5,28 4,113,95,2228,14,25 4,98,95,2046,19,25 6,232,100,2634,13,19 6,225,105,3439,15.5,16 6,250,100,3329,15.5,17 6,250,88,3302,15.5,19 6,232,100,3288,15.5,18 8,350,165,4209,12,14 8,400,175,4464,11.5,14 8,351,153,4154,13.5,14 8,318,150,4096,13,14 8,383,180,4955,11.5,12 8,400,170,4746,12,13 8,400,175,5140,12,13 6,258,110,2962,13.5,18 4,140,72,2408,19,22 6,250,100,3282,15,19 6,250,88,3139,14.5,18 4,122,86,2220,14,23 4,116,90,2123,14,28 4,79,70,2074,19.5,30 4,88,76,2065,14.5,30 4,71,65,1773,19,31 4,72,69,1613,18,35 4,97,60,1834,19,27 4,91,70,1955,20.5,26 4,113,95,2278,15.5,24 4,97.5,80,2126,17,25 4,97,54,2254,23.5,23 4,140,90,2408,19.5,20 4,122,86,2226,16.5,21 8,350,165,4274,12,13 8,400,175,4385,12,14 8,318,150,4135,13.5,15 8,351,153,4129,13,14 8,304,150,3672,11.5,17 8,429,208,4633,11,11 8,350,155,4502,13.5,13 8,350,160,4456,13.5,12 8,400,190,4422,12.5,13 3,70,97,2330,13.5,19 8,304,150,3892,12.5,15 8,307,130,4098,14,13 8,302,140,4294,16,13 8,318,150,4077,14,14 4,121,112,2933,14.5,18 4,121,76,2511,18,22 4,120,87,2979,19.5,21 4,96,69,2189,18,26 4,122,86,2395,16,22 4,97,92,2288,17,28 4,120,97,2506,14.5,23 4,98,80,2164,15,28 4,97,88,2100,16.5,27 8,350,175,4100,13,13 8,304,150,3672,11.5,14 8,350,145,3988,13,13 8,302,137,4042,14.5,14 8,318,150,3777,12.5,15 8,429,198,4952,11.5,12 8,400,150,4464,12,13 8,351,158,4363,13,13 8,318,150,4237,14.5,14 8,440,215,4735,11,13 8,455,225,4951,11,12 8,360,175,3821,11,13 6,225,105,3121,16.5,18 6,250,100,3278,18,16 6,232,100,2945,16,18 6,250,88,3021,16.5,18 6,198,95,2904,16,23 4,97,46,1950,21,26 8,400,150,4997,14,11 8,400,167,4906,12.5,12 8,360,170,4654,13,13 8,350,180,4499,12.5,12 6,232,100,2789,15,18 4,97,88,2279,19,20 4,140,72,2401,19.5,21 4,108,94,2379,16.5,22 3,70,90,2124,13.5,18 4,122,85,2310,18.5,19 6,155,107,2472,14,21 4,98,90,2265,15.5,26 8,350,145,4082,13,15 8,400,230,4278,9.5,16 4,68,49,1867,19.5,29 4,116,75,2158,15.5,24 4,114,91,2582,14,20 4,121,112,2868,15.5,19 8,318,150,3399,11,15 4,121,110,2660,14,24 6,156,122,2807,13.5,20 8,350,180,3664,11,11 6,198,95,3102,16.5,20 6,200,95,2875,17,21 6,232,100,2901,16,19 6,250,100,3336,17,15 4,79,67,1950,19,31 4,122,80,2451,16.5,26 4,71,65,1836,21,32 4,140,75,2542,17,25 6,250,100,3781,17,16 6,258,110,3632,18,16 6,225,105,3613,16.5,18 8,302,140,4141,14,16 8,350,150,4699,14.5,13 8,318,150,4457,13.5,14 8,302,140,4638,16,14 8,304,150,4257,15.5,14 4,98,83,2219,16.5,29 4,79,67,1963,15.5,26 4,97,78,2300,14.5,26 4,76,52,1649,16.5,31 4,83,61,2003,19,32 4,90,75,2125,14.5,28 4,90,75,2108,15.5,24 4,116,75,2246,14,26 4,120,97,2489,15,24 4,108,93,2391,15.5,26 4,79,67,2000,16,31 6,225,95,3264,16,19 6,250,105,3459,16,18 6,250,72,3432,21,15 6,250,72,3158,19.5,15 8,400,170,4668,11.5,16 8,350,145,4440,14,15 8,318,150,4498,14.5,16 8,351,148,4657,13.5,14 6,231,110,3907,21,17 6,250,105,3897,18.5,16 6,258,110,3730,19,15 6,225,95,3785,19,18 6,231,110,3039,15,21 8,262,110,3221,13.5,20 8,302,129,3169,12,13 4,97,75,2171,16,29 4,140,83,2639,17,23 6,232,100,2914,16,20 4,140,78,2592,18.5,23 4,134,96,2702,13.5,24 4,90,71,2223,16.5,25 4,119,97,2545,17,24 6,171,97,2984,14.5,18 4,90,70,1937,14,29 6,232,90,3211,17,19 4,115,95,2694,15,23 4,120,88,2957,17,23 4,121,98,2945,14.5,22 4,121,115,2671,13.5,25 4,91,53,1795,17.5,33 4,107,86,2464,15.5,28 4,116,81,2220,16.9,25 4,140,92,2572,14.9,25 4,98,79,2255,17.7,26 4,101,83,2202,15.3,27 8,305,140,4215,13,17.5 8,318,150,4190,13,16 8,304,120,3962,13.9,15.5 8,351,152,4215,12.8,14.5 6,225,100,3233,15.4,22 6,250,105,3353,14.5,22 6,200,81,3012,17.6,24 6,232,90,3085,17.6,22.5 4,85,52,2035,22.2,29 4,98,60,2164,22.1,24.5 4,90,70,1937,14.2,29 4,91,53,1795,17.4,33 6,225,100,3651,17.7,20 6,250,78,3574,21,18 6,250,110,3645,16.2,18.5 6,258,95,3193,17.8,17.5 4,97,71,1825,12.2,29.5 4,85,70,1990,17,32 4,97,75,2155,16.4,28 4,140,72,2565,13.6,26.5 4,130,102,3150,15.7,20 8,318,150,3940,13.2,13 4,120,88,3270,21.9,19 6,156,108,2930,15.5,19 6,168,120,3820,16.7,16.5 8,350,180,4380,12.1,16.5 8,350,145,4055,12,13 8,302,130,3870,15,13 8,318,150,3755,14,13 4,98,68,2045,18.5,31.5 4,111,80,2155,14.8,30 4,79,58,1825,18.6,36 4,122,96,2300,15.5,25.5 4,85,70,1945,16.8,33.5 8,305,145,3880,12.5,17.5 8,260,110,4060,19,17 8,318,145,4140,13.7,15.5 8,302,130,4295,14.9,15 6,250,110,3520,16.4,17.5 6,231,105,3425,16.9,20.5 6,225,100,3630,17.7,19 6,250,98,3525,19,18.5 8,400,180,4220,11.1,16 8,350,170,4165,11.4,15.5 8,400,190,4325,12.2,15.5 8,351,149,4335,14.5,16 4,97,78,1940,14.5,29 4,151,88,2740,16,24.5 4,97,75,2265,18.2,26 4,140,89,2755,15.8,25.5 4,98,63,2051,17,30.5 4,98,83,2075,15.9,33.5 4,97,67,1985,16.4,30 4,97,78,2190,14.1,30.5 6,146,97,2815,14.5,22 4,121,110,2600,12.8,21.5 3,80,110,2720,13.5,21.5 4,90,48,1985,21.5,43.1 4,98,66,1800,14.4,36.1 4,78,52,1985,19.4,32.8 4,85,70,2070,18.6,39.4 4,91,60,1800,16.4,36.1 8,260,110,3365,15.5,19.9 8,318,140,3735,13.2,19.4 8,302,139,3570,12.8,20.2 6,231,105,3535,19.2,19.2 6,200,95,3155,18.2,20.5 6,200,85,2965,15.8,20.2 4,140,88,2720,15.4,25.1 6,225,100,3430,17.2,20.5 6,232,90,3210,17.2,19.4 6,231,105,3380,15.8,20.6 6,200,85,3070,16.7,20.8 6,225,110,3620,18.7,18.6 6,258,120,3410,15.1,18.1 8,305,145,3425,13.2,19.2 6,231,165,3445,13.4,17.7 8,302,139,3205,11.2,18.1 8,318,140,4080,13.7,17.5 4,98,68,2155,16.5,30 4,134,95,2560,14.2,27.5 4,119,97,2300,14.7,27.2 4,105,75,2230,14.5,30.9 4,134,95,2515,14.8,21.1 4,156,105,2745,16.7,23.2 4,151,85,2855,17.6,23.8 4,119,97,2405,14.9,23.9 5,131,103,2830,15.9,20.3 6,163,125,3140,13.6,17 4,121,115,2795,15.7,21.6 6,163,133,3410,15.8,16.2 4,89,71,1990,14.9,31.5 4,98,68,2135,16.6,29.5 6,231,115,3245,15.4,21.5 6,200,85,2990,18.2,19.8 4,140,88,2890,17.3,22.3 6,232,90,3265,18.2,20.2 6,225,110,3360,16.6,20.6 8,305,130,3840,15.4,17 8,302,129,3725,13.4,17.6 8,351,138,3955,13.2,16.5 8,318,135,3830,15.2,18.2 8