Inspiration

The primary inspiration for the Crop Health Analytical System came from the challenges faced by farmers in rural areas. We realized that while modern technology, such as satellite imagery and AI, is advancing rapidly, its practical application often doesn't reach the agricultural sector where it could make the biggest difference. The goal was to build an accessible tool that could help farmers identify potential crop issues like disease, pest infestations, and soil problems early, before they led to significant financial losses. The Smart India Hackathon provided the perfect platform to tackle this real-world problem.

What it Does

Our project is a machine learning-powered system designed to predict the health of a crop based on various environmental and vegetative indicators. It analyzes key data points such as:

  • Vegetation Indices: Values like NDVI ($NDVI = (NIR - Red) / (NIR + Red)$), which tell us about the plant's photosynthetic activity.
  • Soil Parameters: Temperature, pH, moisture, and organic matter content.
  • Stress & Pest Indicators: The presence of crop stress and pest damage levels.
  • Climatic Data: Rainfall and humidity.

The system processes this data to classify a crop as either "healthy" or "unhealthy," providing a critical, early-warning system for farmers.

How We Built It

The project was built in several distinct phases, each with its own set of challenges.

  1. Data Collection and Pre-processing: We sourced a comprehensive dataset from Kaggle, which contained a wealth of information from multispectral imaging and on-field sensors. This dataset was cleaned to remove irrelevant columns and handle categorical features like Crop_Type using one-hot encoding.
  2. Model Training: We chose a Logistic Regression model for its simplicity and interpretability, which is important for a practical, low-cost solution. The model was trained on the pre-processed data to learn the patterns that distinguish healthy crops from unhealthy ones.
  3. Deployment: We used Python with the Streamlit library to build an intuitive and responsive web application. The trained model was saved as a .sav file using pickle and loaded into the web app to make real-time predictions based on user input.

Challenges We Ran Into

We faced several significant hurdles during development.

  • Overfitting: Initially, our model achieved 100% accuracy on the training data but only around 70% on the testing data. This indicated that the model was memorizing the data instead of learning general patterns, making it unreliable.
  • Deployment Errors: Running the Streamlit app correctly from within the Spyder IDE proved to be a persistent problem. We learned that Streamlit requires a separate command-line execution to launch its web server, which is a different process than running a script in an IDE.
  • User Interface Design: The default Streamlit interface was functional but not visually appealing. We had to implement custom CSS to create a dark, clean theme that was easy to read and use. Another challenge was the input widgets. We found that st.number_input with its default behavior was not ideal, so we switched to st.text_input for a cleaner, more controlled user experience.

How We Accomplished It

To overcome the overfitting issue, we explored several techniques, including hyperparameter tuning and cross-validation, to build a more robust model. For the deployment problem, we adopted the correct command-line workflow and learned to separate the model training logic from the application logic. The most recent version of our app uses a deterministic approach for demonstration, which, while not a true AI prediction, effectively showcases the project's capabilities for a presentation. This helped us highlight the user interface and the problem-solving aspect of our project.

What We Learned

This project was a deep dive into the end-to-end lifecycle of a machine learning project. We learned that:

  • A model's performance on training data is not the sole measure of success; testing accuracy and a model's ability to generalize are far more critical for real-world applications.
  • The deployment stage of a project has its own unique challenges, and choosing the right tools (like Streamlit for its simplicity) is crucial.
  • Effective communication and a user-friendly interface are just as important as the model's performance for a project to be considered a success.

What's Next for the Crop Health Analytical System

Looking ahead, we have several plans for the project:

  • Improve Model Accuracy: The immediate next step is to get the model accuracy for testing data to a more acceptable level (e.g., >85%) by using more advanced algorithms like Random Forest or Gradient Boosting.
  • Integrate Real-time Data: We plan to integrate with live data sources, such as weather APIs and satellite data providers, to give farmers real-time predictions.
  • Introduce a Recommendation System: Beyond just identifying an "unhealthy" crop, the system could provide specific, actionable recommendations, such as "apply a nitrogen-rich fertilizer" or "check for fungal blight."
  • Expand to a Multi-Crop System: Currently, our model handles a few crop types, but we aim to expand its capabilities to a wider variety of crops to serve a larger number of farmers.

Built With

  • anaconda
  • googlecolab
  • kaggle
  • python
Share this project:

Updates