hç
commited on
Upload 7 files
Browse files- Proje Özeti.txt +21 -0
- README.md +31 -84
- app.py +28 -35
- model_columns.pkl +2 -2
- project_description.txt +60 -0
- requirements.txt +1 -1
- rf_model.pkl +2 -2
Proje Özeti.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Proje Özeti
|
| 2 |
+
Amaç: Sentetik olarak oluşturulmuş bir veri seti kullanarak, değerli taşların fiyatlarını tahmin etmek.
|
| 3 |
+
|
| 4 |
+
Problem Türü: Regresyon (sürekli değer tahmini)
|
| 5 |
+
|
| 6 |
+
Veri Özellikleri: Tamamı sayısal sütunlardan oluşan, temiz ve eksiksiz bir veri seti.
|
| 7 |
+
|
| 8 |
+
Hedef Değişken: price
|
| 9 |
+
|
| 10 |
+
Kullanım Alanları: Makine öğrenimi algoritmalarının karşılaştırılması, modelleme pratiği, özellik mühendisliği ve hiperparametre optimizasyonu.
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
Eğitim Odaklı: Kaggle'ın Playground serisi, öğrenme ve pratik yapma amacıyla tasarlanmıştır.
|
| 14 |
+
|
| 15 |
+
Temiz Veri: Eksik değer içermeyen, tamamen sayısal bir veri seti.
|
| 16 |
+
|
| 17 |
+
Modelleme Fırsatları: Regresyon problemleri için çeşitli makine öğrenimi algoritmalarını deneme imkanı sunar.
|
| 18 |
+
|
| 19 |
+
Görselleştirme ve Analiz: EDA (Exploratory Data Analysis) ve veri görselleştirme için zengin bir veri seti.
|
| 20 |
+
|
| 21 |
+
Gemstone Price Prediction
|
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title: "
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
app_file: app.py
|
| 8 |
pinned: true
|
|
@@ -11,106 +11,53 @@ tags:
|
|
| 11 |
- regression
|
| 12 |
- machine-learning
|
| 13 |
- streamlit
|
| 14 |
-
-
|
| 15 |
-
-
|
| 16 |
---
|
| 17 |
|
| 18 |
-
#
|
| 19 |
|
| 20 |
-
This
|
| 21 |
|
| 22 |
-
##
|
| 23 |
|
| 24 |
-
-
|
| 25 |
-
-
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
---
|
| 28 |
|
| 29 |
-
##
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
- Different species of pollinators (honeybee, bumblebee, osmia...)
|
| 34 |
-
- Environmental conditions (rainfall days, temperature ranges...)
|
| 35 |
-
- Fruit attributes (fruit mass, fruit set, seed count...)
|
| 36 |
-
|
| 37 |
-
🎯 **Goal**: Predict the `yield` (kg/ha) of blueberries based on input features.
|
| 38 |
-
|
| 39 |
-
---
|
| 40 |
-
|
| 41 |
-
## 📊 Dataset Info
|
| 42 |
-
|
| 43 |
-
- `train.csv`: 15,289 samples with 18 features
|
| 44 |
-
- `test.csv`: same structure, no target
|
| 45 |
-
- No missing values, clean numerical data
|
| 46 |
|
| 47 |
---
|
| 48 |
|
| 49 |
-
##
|
| 50 |
-
|
| 51 |
-
1. **EDA (Exploratory Data Analysis)**
|
| 52 |
-
- Checked for missing values ✅
|
| 53 |
-
- Analyzed feature distributions & target (`yield`)
|
| 54 |
-
- Built correlation heatmaps — strongest positive correlations:
|
| 55 |
-
- `fruitmass`, `fruitset`, `seeds`
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
- No categorical encoding needed (all numerical)
|
| 61 |
|
| 62 |
-
3. **Model Training**
|
| 63 |
-
- Model: `RandomForestRegressor`
|
| 64 |
-
- Train-Test Split: 80/20
|
| 65 |
-
- **Results**:
|
| 66 |
-
- RMSE ≈ **573.8**
|
| 67 |
-
- R² Score ≈ **0.81** ✅
|
| 68 |
|
| 69 |
-
4. **Test Prediction & Submission**
|
| 70 |
-
- Predictions made on `test.csv`
|
| 71 |
-
- `submission.csv` generated for Kaggle submission
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
---
|
| 79 |
|
| 80 |
-
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
[Hugging Face Space Link](https://huggingface.co/spaces/yazodi/blueberry-yield-regression-app)
|
| 84 |
-
|
| 85 |
-
---
|
| 86 |
-
|
| 87 |
-
## 🔮 What Could Be Improved?
|
| 88 |
-
|
| 89 |
-
| Area | Suggestion |
|
| 90 |
-
|------|------------|
|
| 91 |
-
| Feature Engineering | Create interaction terms, try log/ratio features |
|
| 92 |
-
| Model | Try LightGBM, XGBoost, or stacking |
|
| 93 |
-
| Tuning | GridSearchCV or Optuna for hyperparameter optimization |
|
| 94 |
-
| Visualization | Add interactive charts in Streamlit app |
|
| 95 |
-
| Real-World Data | Add satellite weather data, soil types, historical trends |
|
| 96 |
-
|
| 97 |
-
---
|
| 98 |
-
|
| 99 |
-
## 📁 Project Structure
|
| 100 |
-
|
| 101 |
-
📦 blueberry-yield-regression
|
| 102 |
-
├── app.py
|
| 103 |
-
├── rf_model.pkl
|
| 104 |
-
├── model_columns.pkl
|
| 105 |
-
├── requirements.txt
|
| 106 |
-
├── submission.csv
|
| 107 |
-
└── README.md
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
---
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
-
|
| 115 |
|
| 116 |
-
---
|
|
|
|
| 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
|
|
|
|
| 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
CHANGED
|
@@ -3,48 +3,41 @@ import pandas as pd
|
|
| 3 |
import numpy as np
|
| 4 |
import joblib
|
| 5 |
|
| 6 |
-
|
| 7 |
-
st.
|
| 8 |
-
st.write("Bu uygulama, çevresel ve biyolojik faktörlere göre yaban mersini verimini tahmin eder.")
|
| 9 |
|
| 10 |
# Giriş alanları
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
seeds = st.slider("Tohum Sayısı", 0.0, 100.0, 50.0)
|
| 21 |
|
| 22 |
-
#
|
| 23 |
user_input = pd.DataFrame([{
|
| 24 |
-
"
|
| 25 |
-
"
|
| 26 |
-
"
|
| 27 |
-
"
|
| 28 |
-
"
|
| 29 |
-
"
|
| 30 |
-
"
|
| 31 |
-
"
|
| 32 |
-
"
|
| 33 |
-
"seeds": seeds
|
| 34 |
}])
|
| 35 |
|
| 36 |
-
# Model ve
|
| 37 |
model = joblib.load("rf_model.pkl")
|
| 38 |
-
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
|
| 42 |
-
if col not in user_input.columns:
|
| 43 |
-
user_input[col] = 0
|
| 44 |
-
|
| 45 |
-
user_input = user_input[model_columns]
|
| 46 |
|
| 47 |
# Tahmin
|
| 48 |
-
if st.button("Tahmini Göster"):
|
| 49 |
-
|
| 50 |
-
st.success(f"
|
|
|
|
| 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
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 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
|
@@ -2,4 +2,4 @@ streamlit
|
|
| 2 |
pandas
|
| 3 |
numpy
|
| 4 |
scikit-learn
|
| 5 |
-
|
|
|
|
| 2 |
pandas
|
| 3 |
numpy
|
| 4 |
scikit-learn
|
| 5 |
+
jobli
|
rf_model.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e41679192d03f13b8bbfc23b104659d12bc2b9966bc5126a54e30cbdcf36328
|
| 3 |
+
size 7300001
|