LovnishVerma commited on
Commit
b8d8301
Β·
verified Β·
1 Parent(s): c281c6f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +180 -1
README.md CHANGED
@@ -7,4 +7,183 @@ sdk: docker
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  ---
9
 
10
+ # 🌱 CropSense β€” Crop Recommendation System
11
+
12
+ A Flask web application that predicts the most suitable crop to grow based on soil nutrient parameters. Built with Scikit-learn and deployed with a clean, responsive UI.
13
+
14
+ [![Python](https://img.shields.io/badge/Python-3.8%2B-blue?logo=python)](https://python.org)
15
+ [![Flask](https://img.shields.io/badge/Flask-2.3%2B-black?logo=flask)](https://flask.palletsprojects.com)
16
+ [![Scikit-learn](https://img.shields.io/badge/Scikit--learn-1.3%2B-orange?logo=scikit-learn)](https://scikit-learn.org)
17
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
18
+
19
+ ---
20
+
21
+ Live Demo: https://crop-predict-wgrr.onrender.com/
22
+
23
+ Alternate Link: https://lovnishverma-croppredict.hf.space/
24
+
25
+ ## πŸ“Œ Overview
26
+
27
+ CropSense takes 11 soil parameters as input and recommends the most suitable crop using a **Logistic Regression** model trained on the [Crop dataset](https://raw.githubusercontent.com/lovnishverma/datasets/refs/heads/main/Crop.csv). It also returns the **top-3 predictions with confidence percentages**.
28
+
29
+ This project was developed as a teaching artifact for the **IndiaAI Foundations of Artificial Intelligence** programme at **NIELIT Ropar**, demonstrating the end-to-end ML workflow: data β†’ model β†’ deployment.
30
+
31
+ ---
32
+
33
+ ## πŸ—‚οΈ Project Structure
34
+
35
+ ```
36
+ crop-predict/
37
+ β”œβ”€β”€ app.py # Flask application
38
+ β”œβ”€β”€ classification.ipynb # Model training notebook (Colab)
39
+ β”œβ”€β”€ crop_recommendation_model.joblib # Saved trained model
40
+ β”œβ”€β”€ requirements.txt
41
+ β”œβ”€β”€ static/
42
+ β”‚ └── css/ # Stylesheets
43
+ └── templates/
44
+ └── index.html # Frontend UI
45
+ ```
46
+
47
+ ---
48
+
49
+ ## πŸ§ͺ Input Features
50
+
51
+ The model uses 11 soil parameters:
52
+
53
+ | Feature | Description | Unit |
54
+ |---------|----------------------|--------|
55
+ | N | Nitrogen | kg/ha |
56
+ | P | Phosphorus | kg/ha |
57
+ | K | Potassium | kg/ha |
58
+ | ph | pH Level | β€” |
59
+ | EC | Electrical Conductivity | dS/m |
60
+ | S | Sulfur | mg/kg |
61
+ | Cu | Copper | mg/kg |
62
+ | Fe | Iron | mg/kg |
63
+ | Mn | Manganese | mg/kg |
64
+ | Zn | Zinc | mg/kg |
65
+ | B | Boron | mg/kg |
66
+
67
+ **Sample values** (pomegranate): `175, 36, 216, 5.9, 0.15, 0.28, 15.69, 114.20, 56.87, 31.28, 28.62`
68
+
69
+ ---
70
+
71
+ ## βš™οΈ ML Pipeline
72
+
73
+ ```
74
+ Dataset (Crop.csv)
75
+ ↓
76
+ Feature/Target Split (X = 11 soil params, y = crop label)
77
+ ↓
78
+ Train-Test Split (80/20, random_state=42)
79
+ ↓
80
+ Logistic Regression (sklearn)
81
+ ↓
82
+ Evaluation (accuracy_score, classification_report, confusion matrix)
83
+ ↓
84
+ Model Serialization (joblib β†’ .joblib file)
85
+ ↓
86
+ Flask REST API (/predict)
87
+ ```
88
+
89
+ See [`classification.ipynb`](classification.ipynb) for the full training walkthrough.
90
+
91
+ ---
92
+
93
+ ## πŸš€ Getting Started
94
+
95
+ ### 1. Clone the repository
96
+
97
+ ```bash
98
+ git clone https://github.com/lovnishverma/crop-predict.git
99
+ cd crop-predict
100
+ ```
101
+
102
+ ### 2. Install dependencies
103
+
104
+ ```bash
105
+ pip install -r requirements.txt
106
+ ```
107
+
108
+ ### 3. Run the app
109
+
110
+ ```bash
111
+ python app.py
112
+ ```
113
+
114
+ Open your browser at **http://127.0.0.1:5000**
115
+
116
+ > **Note:** The pre-trained `crop_recommendation_model.joblib` is already included. If you want to retrain, open `classification.ipynb` in Google Colab and run all cells β€” it will regenerate the `.joblib` file.
117
+
118
+ ---
119
+
120
+ ## 🌐 API Reference
121
+
122
+ ### `POST /predict`
123
+
124
+ Accepts `multipart/form-data` with all 11 soil parameters.
125
+
126
+ **Request (curl example):**
127
+
128
+ ```bash
129
+ curl -X POST http://127.0.0.1:5000/predict \
130
+ -F "N=175" -F "P=36" -F "K=216" -F "ph=5.9" -F "EC=0.15" \
131
+ -F "S=0.28" -F "Cu=15.69" -F "Fe=114.20" -F "Mn=56.87" \
132
+ -F "Zn=31.28" -F "B=28.62"
133
+ ```
134
+
135
+ **Response:**
136
+
137
+ ```json
138
+ {
139
+ "crop": "pomegranate",
140
+ "top3": [
141
+ { "crop": "pomegranate", "prob": 87.3 },
142
+ { "crop": "mango", "prob": 7.1 },
143
+ { "crop": "grapes", "prob": 3.2 }
144
+ ]
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## πŸ“¦ Requirements
151
+
152
+ ```
153
+ flask>=2.3
154
+ scikit-learn>=1.3
155
+ pandas>=2.0
156
+ joblib>=1.3
157
+ numpy>=1.24
158
+ ```
159
+
160
+ ---
161
+
162
+ ## πŸ“Š Dataset
163
+
164
+ - **Source:** [`lovnishverma/datasets`](https://github.com/lovnishverma/datasets) β†’ `Crop.csv`
165
+ - **Features:** 11 soil nutrient columns
166
+ - **Target:** `label` β€” crop name (e.g. pomegranate, wheat, rice, maize, etc.)
167
+
168
+ ---
169
+
170
+ ## πŸ™‹ Author
171
+
172
+ **Lovnish Verma**
173
+ Project Engineer, NIELIT Ropar (Deemed University), Punjab
174
+
175
+ [![GitHub](https://img.shields.io/badge/GitHub-lovnishverma-black?logo=github)](https://github.com/lovnishverma)
176
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-lovnishverma-blue?logo=linkedin)](https://linkedin.com/in/lovnishverma)
177
+ [![HuggingFace](https://img.shields.io/badge/HuggingFace-lovnishverma-yellow?logo=huggingface)](https://huggingface.co/lovnishverma)
178
+ [![Portfolio](https://img.shields.io/badge/Portfolio-lovnishverma.in-green)](https://lovnishverma.in)
179
+
180
+ ---
181
+
182
+ ## πŸ“„ License
183
+
184
+ This project is licensed under the MIT License.
185
+
186
+ ---
187
+
188
+ > Built for IndiaAI students at NIELIT Ropar · No brainrot. Just facts. 🌾
189
+