import pandas as pd

df = pd.read_excel('http://cdn.sundog-soft.com/Udemy/DataScience/cars.xls')


df.head()

"""
Explanation: Multivariate Regression
Let's grab a small little data set of Blue Book car values:
End of explanation
"""


import statsmodels.api as sm

df['Model_ord'] = pd.Categorical(df.Model).codes
X = df[['Mileage', 'Model_ord', 'Doors']]
y = df[['Price']]

X1 = sm.add_constant(X)
est = sm.OLS(y, X1).fit()

est.summary()

y.groupby(df.Doors).mean()

"""
Explanation: We can use pandas to split up this matrix into the feature vectors we're interested in, and the value we're trying to predict.
Note how we use pandas.Categorical to convert textual category data (model name) into an ordinal number that we can work with.
End of explanation
"""


