Skip to content

mohamed-jilani/ML-Diamond-Price-Prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Diamond Price Prediction Project This project aims to predict the prices of diamonds based on their features such as carat, cut, color, clarity, depth, and table. The dataset used for this project was sourced from a diamond price prediction competition, and various machine learning models were implemented to forecast the diamond prices.

Table of Contents Project Overview Dataset Features Exploratory Data Analysis (EDA) Data Preprocessing Models Used Results Installation Usage Contributing License Project Overview The goal of this project is to build a predictive model that accurately estimates the price of a diamond given several features. The models implemented in this project include linear regression (Lasso), decision trees, random forests, XGBoost, and polynomial regression. Feature engineering and data preprocessing techniques, such as scaling and categorical encoding, were applied to prepare the dataset for model training.

Dataset The dataset contains various attributes of diamonds, including:

Carat: Weight of the diamond Cut: Quality of the cut (e.g., Ideal, Premium, Good, Very Good, Fair) Color: Diamond color grading (D being the best and J the worst) Clarity: A measure of how clear the diamond is Depth: Total depth percentage Table: Width of the top of the diamond relative to the widest part Volume: A calculated feature based on x, y, and z dimensions (created during preprocessing) Price: The target variable (diamond price) The data used for training and testing is sourced from the diamond price prediction dataset.

Features The following features were used for the model:

carat: Weight of the diamond cut: Categorical feature representing the quality of the cut color: Categorical feature representing the color grade clarity: Categorical feature representing the clarity grade depth: Numeric feature representing the total depth percentage table: Numeric feature representing the table width percentage volume: Numeric feature created by multiplying the x, y, and z dimensions Exploratory Data Analysis (EDA) EDA was performed to better understand the relationships between features and the target variable (price). Key insights included:

Strong correlation between carat and price. Categorical features like cut, clarity, and color were visualized using count plots and pie charts. High correlation between volume and carat, leading to the decision to drop the x, y, and z dimensions. Data Preprocessing Handling Missing Values: No missing values were found in the dataset. Feature Engineering: A new feature volume was created from the product of the x, y, and z dimensions. Scaling: Numeric features were scaled using StandardScaler to standardize the range of values. Encoding: Categorical variables (cut, color, clarity) were encoded into numeric values to prepare them for model training. Models Used The following models were implemented and trained:

Lasso Regression: Linear regression with L1 regularization to reduce overfitting. Decision Tree Regressor: A non-parametric model that splits the data based on feature thresholds. Random Forest Regressor: An ensemble method that uses multiple decision trees to improve performance. XGBoost Regressor: A gradient boosting algorithm known for its accuracy and speed. Polynomial Regression: A model used to capture non-linear relationships between the features and the target variable. Results The models were evaluated, and predictions were generated for the test dataset. The final predictions were submitted for evaluation, with XGBoost performing the best among the models.

Installation To run this project locally, follow these steps:

Clone the repository:

bash Copier le code git clone https://github.com/mohamed-jilani/ML-Diamond-Price-Prediction cd diamond-price-prediction Install the required packages:

bash Copier le code pip install -r requirements.txt The required packages include:

pandas numpy matplotlib seaborn scikit-learn xgboost category_encoders Ensure you have the dataset downloaded from Kaggle and placed in the appropriate directory.

Usage To run the project and make predictions:

Ensure your environment is set up as described in the Installation section.

Preprocess the data and train models by running the following script:

bash Copier le code python train_model.py To generate predictions for the test data:

bash Copier le code python predict.py The predictions will be saved in a submission.csv file.

Contributing Contributions are welcome! Feel free to submit a pull request or open an issue if you find bugs or have suggestions for improvement.

License This project is licensed under the MIT License. See the LICENSE file for more information.

About

ML-Diamond-Price-Prediction

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published