Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SimranShaikh20 committed Nov 8, 2024
1 parent 89c5053 commit 3781959
Show file tree
Hide file tree
Showing 6 changed files with 1,779 additions and 0 deletions.
817 changes: 817 additions & 0 deletions models/PreOwnedCarPrediction/data/Cleaned_Car_data.csv

Large diffs are not rendered by default.

893 changes: 893 additions & 0 deletions models/PreOwnedCarPrediction/data/raw_car_data.csv

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions models/PreOwnedCarPrediction/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
import joblib

class CarPriceModel:
def __init__(self):
self.model = LinearRegression()

def load_data(self, filepath):
data = pd.read_csv(filepath)
return data

def preprocess_data(self, data):
# Perform preprocessing steps here
X = data.drop('price', axis=1) # Assuming 'price' is the target column
y = data['price']
return train_test_split(X, y, test_size=0.2, random_state=42)

def train(self, X_train, y_train):
self.model.fit(X_train, y_train)

def save_model(self, model_path):
joblib.dump(self.model, model_path)

if __name__ == "__main__":
car_model = CarPriceModel()
data = car_model.load_data('data/car_data.csv') # Example path
X_train, X_test, y_train, y_test = car_model.preprocess_data(data)
car_model.train(X_train, y_train)
car_model.save_model('saved_models/car_price_model.pkl')
21 changes: 21 additions & 0 deletions models/PreOwnedCarPrediction/modelEvalution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import joblib
import pandas as pd
from sklearn.metrics import mean_squared_error, r2_score

class ModelEvaluator:
def __init__(self, model_path):
self.model = joblib.load(model_path)

def evaluate(self, X_test, y_test):
predictions = self.model.predict(X_test)
mse = mean_squared_error(y_test, predictions)
r2 = r2_score(y_test, predictions)
print("Mean Squared Error:", mse)
print("R^2 Score:", r2)

if __name__ == "__main__":
data = pd.read_csv('data/car_data.csv') # Load your test data
X_test = data.drop('price', axis=1) # Adjust based on your dataset
y_test = data['price']
evaluator = ModelEvaluator('saved_models/car_price_model.pkl')
evaluator.evaluate(X_test, y_test)

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions models/PreOwnedCarPrediction/predict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import joblib
import pandas as pd

class CarPricePredictor:
def __init__(self, model_path):
self.model = joblib.load(model_path)

def predict(self, input_data):
return self.model.predict(input_data)

if __name__ == "__main__":
predictor = CarPricePredictor('saved_models/car_price_model.pkl')
# Example input data, replace with actual data
input_data = pd.DataFrame([[...]], columns=[...]) # Replace with actual column names
predictions = predictor.predict(input_data)
print(predictions)

0 comments on commit 3781959

Please sign in to comment.