Untitled
unknown
plain_text
2 years ago
558 B
6
Indexable
import pandas as pd
import matplotlib.pyplot as plt
cars = pd.read_csv('cars.csv')
avrg_brand = cars.groupby('Brand')['Price'].mean()/cars['Price'].mean()
avrg_body = cars.groupby('Body')['Price'].mean()/cars['Price'].mean()
avrg_etype = cars.groupby('Engine Type')['Price'].mean()/cars['Price'].mean()
x1 = cars['Year']
x2 = cars['Mileage']
y = cars['Price']
def func(k,x):
return k[0]*x[0]+k[1]*x[1]+k[2]
def error(k):
s = 0
for i in range(0, len(x1)):
e = abs(func(k,[x1[i],x2[i]])-y[i])
s += e
return s
Editor is loading...
Leave a Comment