Lecture1 U5
Lecture1 U5
Lecture1 U5
Evaluation
Unit-5
Model Development and Evaluation with
Python
Model Development
• In this section, we will develop several models
that will predict the price of the car using the
variables or features. This is just an estimate
but should give us an objective idea of how
much the car should cost.
Model Development and Evaluation with
Python
Some questions we want to ask in this kernel
1. do I know if the dealer is offering fair value for my
trade-in?
2. do I know if I put a fair value on my car?
Output:
Mounted at /content/drive
Model Development and Evaluation with Python
df = pd.read_csv('/content/drive/MyDrive/dataanalysis/auto_clean.csv')
df.head()
Output:
Model Development and Evaluation with
Python
1. Linear Regression
• One example of a Data Model that we will be
using is Simple Linear Regression.
• Simple Linear Regression is a method to help us
understand the relationship between two
variables:
i. The predictor/independent variable (X)
ii. The response/dependent variable (that we
want to predict)(Y)
Model Development and Evaluation with
Python
• The result of Linear Regression is a linear
function that predicts the response
(dependent) variable as a function of the
predictor (independent) variable.
Y : Response Variable
X : Predictor Variables
Model Development and Evaluation with
Python
Linear function:
• a refers to the intercept of the regression
line0, in other words: the value of Y when X is
0
• b refers to the slope of the regression line, in
other words: the value with which Y changes
when X increases by 1 unit
Model Development and Evaluation with
Python
• Lets load the modules for linear regression
from sklearn.linear_model import LinearRegression
Output:
Model Development and Evaluation with
Python
How could Highway-mpg help us predict car price?
For this example, we want to look at how highway-mpg can help
us predict car price. Using simple linear regression, we will
create a linear function with "highway-mpg" as the predictor
variable and the "price" as the response variable.
X = df[['highway-mpg']]
Y = df['price']
Model Development and Evaluation with
Python
• Fit the linear model using highway-mpg.
lm.fit(X,Y)
Output:
Yhat=a+bX
• Plugging in the actual values we get:
• price = 38423.31 - 821.73 x highway-mpg
Model Development and Evaluation with
Python
Reference:
• https://www.kaggle.com/code/fazilbtopal/model-
development-and-evaluation-with-python