Run ❯
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
Python code
data.csv
import pandas from sklearn import linear_model from sklearn.preprocessing import StandardScaler scale = StandardScaler() df = pandas.read_csv("data.csv") X = df[['Weight', 'Volume']] y = df['CO2'] scaledX = scale.fit_transform(X) regr = linear_model.LinearRegression() regr.fit(scaledX, y) scaled = scale.transform([[2300, 1.3]]) predictedCO2 = regr.predict([scaled[0]]) print(predictedCO2)
Car,Model,Volume,Weight,CO2 Toyoty,Aygo,1.0,790,99 Mitsubishi,Space Star,1.2,1160,95 Skoda,Citigo,1.0,929,95 Fiat,500,0.9,865,90 Mini,Cooper,1.5,1140,105 VW,Up!,1.0,929,105 Skoda,Fabia,1.4,1109,90 Mercedes,A-Class,1.5,1365,92 Ford,Fiesta,1.5,1112,98 Audi,A1,1.6,1150,99 Hyundai,I20,1.1,980,99 Suzuki,Swift,1.3,990,101 Ford,Fiesta,1.0,1112,99 Honda,Civic,1.6,1252,94 Hundai,I30,1.6,1326,97 Opel,Astra,1.6,1330,97 BMW,1,1.6,1365,99 Mazda,3,2.2,1280,104 Skoda,Rapid,1.6,1119,104 Ford,Focus,2.0,1328,105 Ford,Mondeo,1.6,1584,94 Opel,Insignia,2.0,1428,99 Mercedes,C-Class,2.1,1365,99 Skoda,Octavia,1.6,1415,99 Volvo,S60,2.0,1415,99 Mercedes,CLA,1.5,1465,102 Audi,A4,2.0,1490,104 Audi,A6,2.0,1725,114 Volvo,V70,1.6,1523,109 BMW,5,2.0,1705,114 Mercedes,E-Class,2.1,1605,115 Volvo,XC70,2.0,1746,117 Ford,B-Max,1.6,1235,104 BMW,216,1.6,1390,108 Opel,Zafira,1.6,1405,109 Mercedes,SLK,2.5,1395,120
[107.2087328]