YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

πŸ’Ž Diamond Price Prediction & Valuation System

An end-to-end Machine Learning web application designed to predict diamond retail prices with high accuracy using a Random Forest Regressor trained on the classic 53,940+ diamonds dataset. The application features an interactive Streamlit user interface allowing users to adjust the 4 C's and diamond proportions in real time to receive immediate valuations and confidence estimates.


πŸ“Œ Project Overview

Diamond pricing is traditionally complex and heavily dependent on specific qualitative and quantitative grading metrics known as the 4 C's (Carat, Cut, Color, and Clarity) alongside geometric table and depth proportions.

This project encompasses:

  • Exploratory Data Analysis (EDA): Feature correlations, distribution analysis, and scatter plots comparing diamond dimensions against price.
  • Machine Learning Pipeline: Data transformation using ColumnTransformer with OneHotEncoder and modeling with RandomForestRegressor.
  • Interactive Web App: A responsive, modern Streamlit UI with cached model deserialization (@st.cache_resource) for instant predictions and zero lag.

πŸš€ Key Features

  • Real-Time Price Valuation: Instant price estimates calculated dynamically as you adjust sliders and inputs.
  • The 4 C's Controls:
    • Carat: Precise weight control from 0.20 to 5.00 carats.
    • Cut Quality: Fair, Good, Very Good, Premium, Ideal.
    • Color Grade: From D (completely colorless) to J (faint color).
    • Clarity Grade: From I1 (included) to IF (internally flawless).
  • Proportions & Dimensional Measurements: Adjustable Total Depth %, Table %, Length ($x$), Width ($y$), and Depth ($z$) in millimeters.
  • Valuation Presets: Quick one-click setups for popular diamond types:
    • 1.00ct Engagement Ring (Ideal)
    • 0.50ct Budget Diamond
    • 2.00ct Luxury Solitaire
  • Confidence Range: Displays an estimated 95% price range based on the model's Mean Absolute Error ($MAE \approx $270$).

πŸ“Š Model Architecture & Performance

The model was trained on the standard Seaborn Diamonds dataset (80/20 train/test split, random state 42).

Metric Score / Value
Algorithm Random Forest Regressor (n_estimators=100)
$R^2$ Score ~0.981 (98.1% of variance explained)
Mean Absolute Error (MAE) ~$270
Pre-processing One-Hot Encoding (drop='first', handle_unknown='ignore') for categorical variables, passthrough for continuous numericals

πŸ“ Repository Structure

Diamond Price Prediction/
β”œβ”€β”€ app.py                 # Streamlit web application
β”œβ”€β”€ diamond_model.pkl      # Pre-trained Random Forest Regressor model (compressed ~62 MB, GitHub-friendly)
β”œβ”€β”€ encoder.pkl            # Pre-fitted ColumnTransformer preprocessor
β”œβ”€β”€ model.ipynb            # Jupyter Notebook with EDA, training, and evaluation
β”œβ”€β”€ requirements.txt       # Project dependencies
└── README.md              # Project documentation

πŸ› οΈ Installation & Setup

1. Clone or Open the Repository

cd "Diamond Price Prediction"

2. Set Up a Virtual Environment (Optional, Recommended)

# Windows
python -m venv venv
venv\Scripts\activate

# macOS / Linux
python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the Streamlit Application

streamlit run app.py

The app will open automatically in your browser at: πŸ‘‰ http://localhost:8501


πŸ“– How to Use the App

  1. Select a Preset or Custom Setup: Use the sidebar dropdown to choose between quick presets or customize all parameters yourself.
  2. Configure the 4 C's:
    • Adjust the Carat Weight slider.
    • Select the Cut, Color, and Clarity grades matching your diamond's certificate (e.g., GIA or IGI).
  3. Fine-tune Dimensions: Adjust Depth %, Table %, and physical measurements ($x$, $y$, $z$) in millimeters.
  4. View Valuation: The estimated retail market price and 95% confidence range will update instantly in the valuation card on the right.

πŸ“¦ Requirements

  • Python 3.9+
  • streamlit
  • scikit-learn
  • pandas
  • numpy
  • seaborn
  • matplotlib

πŸ“„ License

This project is open-source and available under the MIT License. # Diamond-Price-Predator

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support