# AI-Based Diamond Price Prediction and Classification This project utilizes **machine learning and AI techniques** to predict **diamond grading prices** (GIA-certified prices, grading prices, and bygrading prices) based on various diamond attributes. Additionally, it provides classification-based recommendations for changes in diamond parameters. The system is built using **Flask**, **scikit-learn**, and **XGBoost**, and it is deployed as a web application with a user-friendly interface. --- ## 🚀 Project Overview ### Problem Statement Manually evaluating diamond prices and certification costs is a **time-consuming and error-prone** task. This project automates the process by leveraging AI models to analyze historical data and provide **accurate predictions and recommendations** based on diamond attributes. ### Key Features ✅ **Diamond Price Prediction**: Predicts GIA, grading, and bygrading prices using AI. ✅ **Parameter Change Analysis**: Identifies and suggests modifications in diamond attributes. ✅ **Automated Data Processing**: Cleans and preprocesses input data for better model accuracy. ✅ **Web-Based Interface**: Flask-based UI for easy file uploads and result visualization. ✅ **Downloadable Reports**: Users can download CSV reports for predictions and analysis. --- ## ⚙️ Tech Stack | Component | Tools/Technologies Used | |---------------|----------------------| | **Backend** | Flask, scikit-learn, XGBoost, NumPy, Pandas | | **Frontend** | HTML, CSS, Jinja Templates | | **Database** | CSV/Excel file-based input | | **Deployment** | Docker, Gunicorn | | **Machine Learning** | Linear Regression, Decision Trees, Random Forest, K-Nearest Neighbors, XGBoost | --- ## 📌 Project Workflow ### 🔹 Input: - Users upload a CSV/Excel file containing **diamond attributes** (Tag, Carat, Shape, Quality, Color, Cut, Polish, Symmetry, Fluorescence, etc.). ### 🔹 Processing: - **Prediction Models** estimate GIA prices, grading prices, and bygrading prices. - **Classification Models** analyze changes in diamond parameters (e.g., carat, color, cut). ### 🔹 Output: - Users receive **predicted values** and **recommendations** based on AI models. - Results are displayed in a structured table. - Users can **download reports** as CSV files. --- ## 🛠️ Setup Instructions ### 1️⃣ Clone the Repository ```bash git clone https://huggingface.co/spaces/WebashalarForML/DiamRapo cd diamond-price-prediction ``` ### 2️⃣ Create a Virtual Environment (Optional) ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ``` ### 3️⃣ Install Dependencies ```bash pip install -r requirements.txt ``` ### 4️⃣ Run the Application ```bash python app.py ``` Visit `http://127.0.0.1:5000` in your browser. --- ## 📦 Running with Docker ### 1️⃣ Build the Docker Image ```bash docker build -t diamond-prediction . ``` ### 2️⃣ Run the Container ```bash docker run -p 7860:7860 diamond-prediction ``` Now, visit `http://localhost:7860` to use the app. --- ## 📜 API Endpoints | Endpoint | Method | Description | |----------|--------|-------------| | `/` | GET | Home page | | `/predict` | POST | Uploads a CSV/Excel file and predicts diamond prices | | `/download_pred` | GET | Downloads prediction results as CSV | | `/download_class` | GET | Downloads classification analysis as CSV | --- ## 📂 Project Structure ``` . ├── app.py # Flask application ├── templates/ │ ├── index.html # Home page template │ ├── output.html # Output display template ├── static/ # CSS and static files ├── Model/ # Trained ML models (.joblib) ├── Label_encoders/ # Pretrained label encoders ├── uploads/ # Uploaded files storage ├── data/ # Processed data files ├── requirements.txt # Dependencies list ├── Dockerfile # Docker setup └── README.md # Documentation ``` --- ## 📊 Example Use Cases ### 1️⃣ Predicting Diamond Prices - Upload a **diamond dataset (CSV/Excel)**. - The AI model predicts **GIA price, grading price, and bygrading price**. - Download the results as a structured report. ### 2️⃣ Identifying Diamond Parameter Changes - AI analyzes changes in **carat, cut, color, and other attributes**. - Alerts users to potential modifications in the diamond properties. --- ## 🔍 Future Enhancements - ✅ Improve model accuracy with deep learning. - ✅ Add support for **real-time API integration** with diamond pricing databases. - ✅ Extend the system to predict **market trends** using time-series forecasting. --- ## 💡 Credits Developed by **Webashlar**, a leading IT company specializing in AI, data science, and software solutions. Happy predicting! 💎✨ ---