hç
commited on
Upload 6 files
Browse files- README.md +63 -20
- app.py +43 -0
- model_columns.pkl +3 -0
- project_description.txt +60 -0
- requirements.txt +5 -3
- rf_model.pkl +3 -0
README.md
CHANGED
|
@@ -1,20 +1,63 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: "💎 Gemstone Price Regression"
|
| 3 |
+
emoji: 💰
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: true
|
| 9 |
+
license: mit
|
| 10 |
+
tags:
|
| 11 |
+
- regression
|
| 12 |
+
- machine-learning
|
| 13 |
+
- streamlit
|
| 14 |
+
- diamonds
|
| 15 |
+
- synthetic-data
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# 💎 Gemstone Price Prediction App
|
| 19 |
+
|
| 20 |
+
This Streamlit app predicts the price of a gemstone using its physical and quality-related features.
|
| 21 |
+
|
| 22 |
+
## 🧠 Project Overview
|
| 23 |
+
|
| 24 |
+
- This project simulates a **gemstone pricing system** using synthetic tabular data.
|
| 25 |
+
- Features include: `carat`, `depth`, `table`, `x`, `y`, `z`, `clarity_score`, `color_score`, and `cut_score`.
|
| 26 |
+
- The target variable is **price** (USD).
|
| 27 |
+
- Model: **RandomForestRegressor**
|
| 28 |
+
- Trained on 1000 synthetic samples.
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## 📊 Performance
|
| 33 |
+
|
| 34 |
+
- RMSE: **605.16**
|
| 35 |
+
- R² Score: **0.9549**
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## 🚀 How to Run Locally
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
pip install -r requirements.txt
|
| 43 |
+
streamlit run app.py
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
🔮 Future Work
|
| 48 |
+
Area Improvement
|
| 49 |
+
Model Try XGBoost, LightGBM
|
| 50 |
+
Feature Engineering Interaction terms, log/carat scaling
|
| 51 |
+
Deployment Add API endpoint with FastAPI
|
| 52 |
+
Real-world Data Integrate real gemstone datasets
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
📁 Files
|
| 56 |
+
app.py: Streamlit interface
|
| 57 |
+
|
| 58 |
+
rf_model.pkl: Trained model
|
| 59 |
+
|
| 60 |
+
model_columns.pkl: List of input features
|
| 61 |
+
|
| 62 |
+
requirements.txt: Required libraries
|
| 63 |
+
|
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
st.title("💎 Gemstone Price Estimator")
|
| 7 |
+
st.write("Bu uygulama, değerli taşların fiyatını tahmin eder.")
|
| 8 |
+
|
| 9 |
+
# Giriş alanları
|
| 10 |
+
carat = st.slider("Carat", 0.2, 5.0, 1.0)
|
| 11 |
+
depth = st.slider("Depth", 50.0, 70.0, 60.0)
|
| 12 |
+
table = st.slider("Table", 50.0, 70.0, 58.0)
|
| 13 |
+
x = st.slider("x (mm)", 3.0, 10.0, 6.0)
|
| 14 |
+
y = st.slider("y (mm)", 3.0, 10.0, 6.0)
|
| 15 |
+
z = st.slider("z (mm)", 2.0, 6.0, 4.0)
|
| 16 |
+
clarity_score = st.slider("Clarity Score", 1, 10, 5)
|
| 17 |
+
color_score = st.slider("Color Score", 1, 7, 3)
|
| 18 |
+
cut_score = st.slider("Cut Score", 1, 5, 3)
|
| 19 |
+
|
| 20 |
+
# Veriyi dataframe yap
|
| 21 |
+
user_input = pd.DataFrame([{
|
| 22 |
+
"carat": carat,
|
| 23 |
+
"depth": depth,
|
| 24 |
+
"table": table,
|
| 25 |
+
"x": x,
|
| 26 |
+
"y": y,
|
| 27 |
+
"z": z,
|
| 28 |
+
"clarity_score": clarity_score,
|
| 29 |
+
"color_score": color_score,
|
| 30 |
+
"cut_score": cut_score
|
| 31 |
+
}])
|
| 32 |
+
|
| 33 |
+
# Model ve kolonlar yükleniyor
|
| 34 |
+
model = joblib.load("rf_model.pkl")
|
| 35 |
+
columns = joblib.load("model_columns.pkl")
|
| 36 |
+
|
| 37 |
+
# Sıra uyumu
|
| 38 |
+
user_input = user_input[columns]
|
| 39 |
+
|
| 40 |
+
# Tahmin
|
| 41 |
+
if st.button("Tahmini Fiyatı Göster"):
|
| 42 |
+
prediction = model.predict(user_input)[0]
|
| 43 |
+
st.success(f"💰 Tahmini Fiyat: ${prediction:,.2f}")
|
model_columns.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ba62c0315c390a17bf49a71aa039e95ff212a5951b61580313c9e309f56c9c8
|
| 3 |
+
size 94
|
project_description.txt
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Proje Adı:
|
| 2 |
+
Gemstone Price Prediction – Makine Öğrenmesi ile Değerli Taş Fiyat Tahmini
|
| 3 |
+
|
| 4 |
+
# Proje Türü:
|
| 5 |
+
Regresyon – Sürekli Değer Tahmini
|
| 6 |
+
|
| 7 |
+
# Veri Seti:
|
| 8 |
+
Yapay olarak oluşturulmuş 1000 satırlık tabular veri seti.
|
| 9 |
+
Veri seti, değerli taşlara ait fiziksel ölçümler (carat, depth, x, y, z...) ve kalite puanları (clarity_score, color_score, cut_score) ile oluşturulmuştur.
|
| 10 |
+
|
| 11 |
+
# Amaç:
|
| 12 |
+
Verilen fiziksel ve kalite özelliklerine göre değerli bir taşın fiyatını (USD) tahmin etmektir.
|
| 13 |
+
|
| 14 |
+
# Kullanılan Kütüphaneler:
|
| 15 |
+
- pandas
|
| 16 |
+
- numpy
|
| 17 |
+
- scikit-learn
|
| 18 |
+
- streamlit
|
| 19 |
+
- joblib
|
| 20 |
+
- matplotlib / seaborn (EDA için)
|
| 21 |
+
|
| 22 |
+
# Aşamalar:
|
| 23 |
+
|
| 24 |
+
1. 📊 Veri Keşfi (EDA):
|
| 25 |
+
- Veri tipi ve dağılımları incelendi
|
| 26 |
+
- Korelasyon analizi ile fiyat üzerinde en etkili değişkenler belirlendi: carat, clarity_score, cut_score
|
| 27 |
+
|
| 28 |
+
2. 🧹 Veri Ön İşleme:
|
| 29 |
+
- Eksik değer bulunmadığı için doğrudan modellemeye geçildi
|
| 30 |
+
- Özellikler normalize edilmedi (Random Forest bu gereksinime ihtiyaç duymaz)
|
| 31 |
+
|
| 32 |
+
3. 🧠 Modelleme:
|
| 33 |
+
- Kullanılan algoritma: RandomForestRegressor
|
| 34 |
+
- Train-Test ayrımı %80 / %20 olarak yapıldı
|
| 35 |
+
- Model performansı:
|
| 36 |
+
- RMSE: 605.16
|
| 37 |
+
- R²: 0.9549 → yüksek doğruluk
|
| 38 |
+
|
| 39 |
+
4. 🧪 Test Senaryosu:
|
| 40 |
+
- Kullanıcıdan alınan fiziksel ve kalite değerlerine göre tahmin yapacak yapı kuruldu
|
| 41 |
+
|
| 42 |
+
5. 🌐 Streamlit Arayüzü:
|
| 43 |
+
- Kullanıcıdan `carat`, `depth`, `x`, `y`, `z`, `clarity_score`, `cut_score`, vb. bilgiler alınıyor
|
| 44 |
+
- Eğitilen model tahmin yapıyor ve fiyatı ekranda gösteriyor
|
| 45 |
+
|
| 46 |
+
# Çıktılar:
|
| 47 |
+
- `rf_model.pkl` → Eğitilmiş model dosyası
|
| 48 |
+
- `model_columns.pkl` → Modelin beklediği özellik listesi
|
| 49 |
+
- `app.py` → Streamlit uygulama arayüzü
|
| 50 |
+
- `requirements.txt` → Gerekli kütüphaneler listesi
|
| 51 |
+
|
| 52 |
+
# Gelecek Geliştirmeler:
|
| 53 |
+
- XGBoost, LightGBM gibi algoritmalar denenebilir
|
| 54 |
+
- Gerçek veri entegrasyonu yapılabilir (örneğin: gerçek elmas veri setleri)
|
| 55 |
+
- Özellik mühendisliği: log dönüşümü, oranlar, etkileşimli değişkenler
|
| 56 |
+
- API servisi ile RESTful endpoint oluşturulabilir
|
| 57 |
+
|
| 58 |
+
# Projenin Amacı:
|
| 59 |
+
Bu proje, regresyon temelli bir fiyat tahmini probleminde uçtan uca makine öğrenmesi sürecinin (veri üretimi, modelleme, değerlendirme, dağıtım) tamamını göstermektedir. Gerçek veriye benzer yapay veri ile çalışmak, gerçek dünya problemlerine yaklaşımı öğrenme açısından faydalı bir simülasyon sunmaktadır.
|
| 60 |
+
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
pandas
|
| 3 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
pandas
|
| 3 |
+
numpy
|
| 4 |
+
scikit-learn
|
| 5 |
+
jobli
|
rf_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e41679192d03f13b8bbfc23b104659d12bc2b9966bc5126a54e30cbdcf36328
|
| 3 |
+
size 7300001
|