Spaces:
Sleeping
Sleeping
Add README.md with Hugging Face configuration
Browse files
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Iris Flower Classification
|
| 3 |
+
emoji: πΈ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
sdk_version: "4.36.2"
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# πΈ Iris Flower Classification API
|
| 14 |
+
|
| 15 |
+
Aplikasi Machine Learning untuk klasifikasi bunga Iris menggunakan Decision Tree Algorithm. API ini dapat memprediksi spesies bunga Iris (Setosa, Versicolor, atau Virginica) berdasarkan fitur morfologi bunga.
|
| 16 |
+
|
| 17 |
+
## π Dataset & Model
|
| 18 |
+
|
| 19 |
+
- **Dataset**: Iris Dataset dari scikit-learn
|
| 20 |
+
- **Algorithm**: Decision Tree Classifier
|
| 21 |
+
- **Features**:
|
| 22 |
+
- Sepal Length (cm)
|
| 23 |
+
- Sepal Width (cm)
|
| 24 |
+
- Petal Length (cm)
|
| 25 |
+
- Petal Width (cm)
|
| 26 |
+
- **Target Classes**: Setosa, Versicolor, Virginica
|
| 27 |
+
|
| 28 |
+
## π API Endpoints
|
| 29 |
+
|
| 30 |
+
### 1. Home Page
|
| 31 |
+
```
|
| 32 |
+
GET /
|
| 33 |
+
```
|
| 34 |
+
Web interface interaktif untuk testing model
|
| 35 |
+
|
| 36 |
+
### 2. Predict Species
|
| 37 |
+
```
|
| 38 |
+
POST /predict
|
| 39 |
+
Content-Type: application/json
|
| 40 |
+
|
| 41 |
+
{
|
| 42 |
+
"sepal_length": 5.1,
|
| 43 |
+
"sepal_width": 3.5,
|
| 44 |
+
"petal_length": 1.4,
|
| 45 |
+
"petal_width": 0.2
|
| 46 |
+
}
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### 3. Model Information
|
| 50 |
+
```
|
| 51 |
+
GET /model-info
|
| 52 |
+
```
|
| 53 |
+
Informasi detail tentang model dan feature importance
|
| 54 |
+
|
| 55 |
+
### 4. Health Check
|
| 56 |
+
```
|
| 57 |
+
GET /health
|
| 58 |
+
```
|
| 59 |
+
Status kesehatan API
|
| 60 |
+
|
| 61 |
+
## π§ͺ Example Usage
|
| 62 |
+
|
| 63 |
+
### Prediksi Setosa:
|
| 64 |
+
```json
|
| 65 |
+
{
|
| 66 |
+
"sepal_length": 5.1,
|
| 67 |
+
"sepal_width": 3.5,
|
| 68 |
+
"petal_length": 1.4,
|
| 69 |
+
"petal_width": 0.2
|
| 70 |
+
}
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
### Prediksi Versicolor:
|
| 74 |
+
```json
|
| 75 |
+
{
|
| 76 |
+
"sepal_length": 7.0,
|
| 77 |
+
"sepal_width": 3.2,
|
| 78 |
+
"petal_length": 4.7,
|
| 79 |
+
"petal_width": 1.4
|
| 80 |
+
}
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
### Prediksi Virginica:
|
| 84 |
+
```json
|
| 85 |
+
{
|
| 86 |
+
"sepal_length": 6.3,
|
| 87 |
+
"sepal_width": 3.3,
|
| 88 |
+
"petal_length": 6.0,
|
| 89 |
+
"petal_width": 2.5
|
| 90 |
+
}
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## π Model Performance
|
| 94 |
+
|
| 95 |
+
- **Accuracy**: 100% (pada test set)
|
| 96 |
+
- **Algorithm**: Decision Tree dengan random_state=42
|
| 97 |
+
- **Training Data**: 120 samples
|
| 98 |
+
- **Test Data**: 30 samples
|
| 99 |
+
|
| 100 |
+
## π Key Decision Rules
|
| 101 |
+
|
| 102 |
+
Berdasarkan Decision Tree yang dihasilkan:
|
| 103 |
+
|
| 104 |
+
1. **Setosa**: Petal Length β€ 2.45 cm
|
| 105 |
+
2. **Versicolor**: Petal Length > 2.45 cm AND Petal Width β€ 1.75 cm
|
| 106 |
+
3. **Virginica**: Petal Length > 2.45 cm AND Petal Width > 1.75 cm
|
| 107 |
+
|
| 108 |
+
## π οΈ Technology Stack
|
| 109 |
+
|
| 110 |
+
- **Backend**: Flask + Python 3.11
|
| 111 |
+
- **ML**: scikit-learn, pandas, numpy
|
| 112 |
+
- **Model Persistence**: joblib
|
| 113 |
+
- **Container**: Docker
|
| 114 |
+
- **Deployment**: Hugging Face Spaces
|
| 115 |
+
|
| 116 |
+
## π¨βπ» Author
|
| 117 |
+
|
| 118 |
+
Tugas 27 - Machine Learning Model Deployment
|
| 119 |
+
**Universitas/Institusi**: Infinite Learning
|