commited on
Commit
6a537b5
·
verified ·
1 Parent(s): 6189726

Upload 7 files

Browse files
Files changed (7) hide show
  1. Proje Özeti.txt +21 -0
  2. README.md +31 -84
  3. app.py +28 -35
  4. model_columns.pkl +2 -2
  5. project_description.txt +60 -0
  6. requirements.txt +1 -1
  7. 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: "🍇 Blueberry Yield Regression"
3
- emoji: 🌾
4
  colorFrom: indigo
5
- colorTo: green
6
  sdk: streamlit
7
  app_file: app.py
8
  pinned: true
@@ -11,106 +11,53 @@ tags:
11
  - regression
12
  - machine-learning
13
  - streamlit
14
- - kaggle
15
- - agriculture
16
  ---
17
 
18
- # 🍇 Blueberry Yield Prediction with Machine Learning
19
 
20
- This project is a complete machine learning pipeline that predicts the **yield of wild blueberries** using various environmental and biological features such as pollinator counts, rainfall, and fruit measurements.
21
 
22
- ## 📌 Project Type
23
 
24
- - Supervised Learning
25
- - Regression Problem
 
 
 
26
 
27
  ---
28
 
29
- ## 🔍 Problem Description
30
 
31
- Predicting agricultural yield is a crucial component in planning, sustainability, and food economics. The dataset used in this project comes from the **Kaggle Playground Series S3E14** competition and contains information on:
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
- ## 📈 What We Did (Pipeline Summary)
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
- 2. **Data Preprocessing**
58
- - Removed `id` column
59
- - Standard feature selection based on correlation
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
- 5. **Streamlit App**
74
- - Users input bee counts, rain days, and fruit measurements
75
- - Predicts blueberry yield in kg/ha
76
- - Uses trained model (`rf_model.pkl`) behind the scenes
 
 
77
 
78
- ---
79
 
80
- ## 🚀 Try it Online
 
81
 
82
- 🌐 You can try this app live here:
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
- ## 📜 License
113
 
114
- MIT License – Free to use, modify and distribute.
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
- # Başlık
7
- st.title("🍇 Blueberry Yield Prediction App")
8
- st.write("Bu uygulama, çevresel ve biyolojik faktörlere göre yaban mersini verimini tahmin eder.")
9
 
10
  # Giriş alanları
11
- clonesize = st.slider("Klon Boyutu", 0.0, 10.0, 1.0)
12
- honeybee = st.slider("Bal Arısı Sayısı", 0.0, 10.0, 1.0)
13
- bumbles = st.slider("Bumblebee Sayısı", 0.0, 10.0, 1.0)
14
- andrena = st.slider("Andrena Sayısı", 0.0, 10.0, 1.0)
15
- osmia = st.slider("Osmia Sayısı", 0.0, 10.0, 1.0)
16
- RainingDays = st.slider("Yağmurlu Günler", 0.0, 100.0, 20.0)
17
- AverageRainingDays = st.slider("Ortalama Yağmurlu Günler", 0.0, 100.0, 30.0)
18
- fruitset = st.slider("Fruit Set", 0.0, 1.0, 0.5)
19
- fruitmass = st.slider("Fruit Mass", 0.0, 10.0, 5.0)
20
- seeds = st.slider("Tohum Sayısı", 0.0, 100.0, 50.0)
21
 
22
- # DataFrame'e dönüştür
23
  user_input = pd.DataFrame([{
24
- "clonesize": clonesize,
25
- "honeybee": honeybee,
26
- "bumbles": bumbles,
27
- "andrena": andrena,
28
- "osmia": osmia,
29
- "RainingDays": RainingDays,
30
- "AverageRainingDays": AverageRainingDays,
31
- "fruitset": fruitset,
32
- "fruitmass": fruitmass,
33
- "seeds": seeds
34
  }])
35
 
36
- # Model ve sütunlar yükleniyor
37
  model = joblib.load("rf_model.pkl")
38
- model_columns = joblib.load("model_columns.pkl")
39
 
40
- # Eksik sütunları ekle
41
- for col in model_columns:
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
- pred = model.predict(user_input)[0]
50
- st.success(f"🌱 Tahmini Yaban Mersini Verimi: {pred:.2f} kg/ha")
 
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:2f8f2353d1c8c3d79295e022ad6bd9a36aa8bc6bb2ce3f6b597b67cc2fea59ac
3
- size 255
 
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
- joblib
 
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:68b74682bb46d81c2aa0e680cea3abae0a97da6f372a366babe5a3bebd77e300
3
- size 108065345
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e41679192d03f13b8bbfc23b104659d12bc2b9966bc5126a54e30cbdcf36328
3
+ size 7300001