Try It Yourself
Enter values below, then hit Predict to see what the model says.
Raw Dataset (original data)
| Car_Name | Year | Selling_Price_USD | Present_Price_USD | Kms_Driven | Fuel_Type | Seller_Type | Transmission | Owner |
|---|
Cleaned Dataset (the version we feed to the model)
| Car_Age_Yrs | Kilometers_Driven | Original_Price | Selling_Price |
|---|
The Code (how we built this model)
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
df = pd.read_csv('used_cars_original.csv')
df = df[['Year', 'Kms_Driven', 'Present_Price', 'Selling_Price']]
df = df.dropna()
df = pd.get_dummies(df, drop_first=True)
X = df.drop('Selling_Price', axis=1)
y = df['Selling_Price']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
scaler = MinMaxScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
model = LinearRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
print(r2_score(y_test, y_pred))
Under the Hood (the equation the model learned)
Price = $3,264 − $533 × Age − $0.00 × Kms + $0.52 × Original Price
Age is the main killer of value (−$533/year). Kilometers driven barely matters at this scale. And you recover about 52 cents on every dollar of original price.
Try the Equation Yourself
Predicted Result
—