File size: 4,982 Bytes
15f93c7
 
10cab27
15f93c7
 
 
 
 
10cab27
 
15f93c7
10cab27
 
 
 
 
 
15f93c7
 
 
10cab27
15f93c7
10cab27
 
 
 
 
 
 
15f93c7
 
 
10cab27
15f93c7
10cab27
 
 
 
 
 
 
 
 
 
 
15f93c7
 
 
10cab27
15f93c7
10cab27
 
83e0fd9
10cab27
 
 
 
15f93c7
 
 
 
 
10cab27
15f93c7
 
 
 
10cab27
15f93c7
 
 
10cab27
15f93c7
 
 
10cab27
15f93c7
10cab27
 
 
 
15f93c7
10cab27
 
 
 
 
15f93c7
 
 
10cab27
15f93c7
10cab27
 
 
 
 
 
15f93c7
 
 
10cab27
15f93c7
 
 
 
 
10cab27
 
 
 
 
 
 
 
 
 
15f93c7
 
 
 
10cab27
15f93c7
10cab27
 
 
 
 
 
 
 
15f93c7
 
 
10cab27
 
 
 
 
 
 
 
 
 
 
 
 
15f93c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# 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! πŸ’Žβœ¨

---