0% found this document useful (0 votes)
27 views25 pages

Smart Farming Assistant

The document presents a project titled 'Smart Farming Assistant,' which aims to enhance agricultural productivity through a machine learning-based system that predicts crop yields and market prices. Utilizing algorithms like XGBoost and Random Forest, the system incorporates SHAP values for interpretability, allowing farmers to understand the factors influencing predictions. The project is designed for small and medium-scale farmers, with a user-friendly web interface to facilitate data-driven decision-making in agriculture.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views25 pages

Smart Farming Assistant

The document presents a project titled 'Smart Farming Assistant,' which aims to enhance agricultural productivity through a machine learning-based system that predicts crop yields and market prices. Utilizing algorithms like XGBoost and Random Forest, the system incorporates SHAP values for interpretability, allowing farmers to understand the factors influencing predictions. The project is designed for small and medium-scale farmers, with a user-friendly web interface to facilitate data-driven decision-making in agriculture.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology

ISSN No:-2456-2165 [Link]

Smart Farming Assistant


Gulam Muddasir Farooqui1; Mohammed Mouzzam Mohiuddin2;
Syed Barkath Ali3
1
(1603-22-73-3015); 2(1603-22-73-3056); 3(1603-22-73-3057)

Submitted in Partial Fulfillment of the Requirements for the Award of the


Degree of Bachelor of Engineering in Computer Science and Engineering

Under the Guidance of Dr. Abdul Khadeer Associate Professor


Department of CSE, DCET Department of Computer Science Engineering
Deccan College of Engineering and Technology (Affiliated to Osmania University) Hyderabad

Publication Date: 2025/08/04

How to Cite: Gulam Muddasir Farooqui; Mohammed Mouzzam Mohiuddin; Syed Barkath Ali (2025) Smart Farming Assistant.
International Journal of Innovative Science and Research Technology, 10(7), 2844-2868.
[Link]

IJISRT25JUL1842 [Link] 2844


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
CERTIFICATE
This is to certify that the project work entitled “Smart Farming Assistant” being submitted by GULAM MUDDASIR
FAROOQUI (160322733015) , MOHAMMED MOUZZAM MOHIUDDIN (160322733056) , SYED BARKATH ALI
(160322733057) , in partial fulfillment for the award of the Degree of Bachelor of Engineering in Computer Science by the Osmania
University is a record of bonafide work carried out by them under my guidance and supervision.

The results embodied in this project report have not been submitted to any other University or Institute for the award of any
Degree or Diploma.

Internal Examiner External Examiner Head of the Department


Dr. Abdul Khadeer Dr. AYESHA AMEEN
Associate Professor Professor & HOD
DCET, Hyderabad.

IJISRT25JUL1842 [Link] 2845


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
DECLARATION
This is to certify that the work reported in the present project entitled “SMART FARMING ASSISTANT” is a record of
work done by us in the Department of Computer Science & Engineering, Deccan College of Engineering and Technology,
Osmania University, Hyderabad. In partial fulfillment of the requirement for the award of the degree of Bachelor of Engineering
in Computer Science & Engineering.

The results presented in this dissertation have been verified and are found to be satisfactory. The results embodied in this
dissertation have not been submitted to any other university for the award of any degree or diploma.

IJISRT25JUL1842 [Link] 2846


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
ACKNOWLEDGEMENT
“Task successful” makes everyone happy. But the happiness will be gold without glitter if we didn’t state the people who have
supported us to make it a success. Success will be crowned to people who made it a reality but people whose constant guidance
and encouragement made it possible will be crowned first on the eve of success.

We are thankful to Principal Dr. [Link] for providing excellent infrastructure and a nice atmosphere for completing
this project successfully.

We are very grateful to Dr. AYESHA AMEEN for giving us the best facilities and an excellent staff that allowed us to focus
our abilities in a proper manner .

We would like to express our sincere gratitude and indebtedness to my project Coordinator Dr. Ramesh Kumar
Chuttugulla for his valuable suggestions and interest in this project.

This project would not have been a success without my internal guide. So, we would extend our deep sense of gratitude to
our internal guide Dr. ABDUL KHADEER , Assistant Professor for the effort he took in guiding us in all the stages of
completion of our project work. We also thank them for their valuable suggestions, advice, guidance, and constructive ideas in
every step, which was indeed a great need towards the successful completion of the project.

We convey our heartfelt thanks to the lab staff for allowing us to use the required equipment whenever needed.

Finally, we would like to take this opportunity to thank the Almighty and the families for their support through the work.

IJISRT25JUL1842 [Link] 2847


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
ABSTRACT
The Smart Farming Assistant is a machine learning-based system designed to aid farmers and agricultural planners
in making informed decisions about crop yield and market pricing. The system utilizes advanced algorithms such as
XGBoost and Random Forest to predict agricultural outcomes based on soil health, weather patterns, and historical
market data.

To ensure transparency and trust in the model’s predictions, the project incorporates SHAP (SHapley Additive
exPlanations) values, allowing users to interpret the influence of each input feature on the model’s output. This enhances
the explainability of the system, making it not only a powerful forecasting tool but also an educational aid for
understanding the relationships between environmental factors and crop performance.

The project includes a user-friendly web interface that enables users to input relevant agricultural parameters and
receive both predictions and interpretive visualizations. By combining accuracy with explainability, this Smart Farming
Assistant bridges the gap between traditional agricultural knowledge and modern artificial intelligence, promoting more
efficient and profitable farming practices.

IJISRT25JUL1842 [Link] 2848


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
TABLE OF CONTENTS
CERTIFICATE…………………………………………………………..……………...2845
DECLARATION……………………………………..…………………..….…………..2846
ACKNOWLEDGEMENT…………………………………………………..…………..2847
ABSTRACT………………………………………………………………….…………...2848
TABLE OF CONTENTS……………………….……………………………….….......2849
LIST OF ABBREVATION...…………………………………………………………….2850
CHAPTER ONE INTRODUCTION 2851

Introduction 2851
Problem Statemen 2851
Problem Definition 2851
Objective 2851
Scope 2851

CHAPTER TWO REVIEW OF LITERATURE 2852

Research Methodologies 2852


Feasibility Studies 2852
proposed System 2852
Existing System 2852
Disadvantages of Existing System 2853
Proposed Methods 2853
System Architecture 2853
Proposed System Advantages 2853
Project Description 2856
General 2856
Modules Description 2856
System Requirement Specification 2856
Hardware Requirements 2856
Software Requirements 2857

CHAPTER THREE DESIGN AND IMPLEMENTATION 2858

Unified Modelling Language 2858


Model 2858
Applications of UML 2859
Use Case Diagram 2859
Class Diagram 2859
Sequence Diagram 2860
Activity Diagram 2860
sample Code 2861
Screenshots 2862

CHAPTER FOUR JUSTIFICATION AND DISCUSSION OF THE RESULTS 2865

Theoretical Justification 2865


Benefit Discussion of the Scheme 2865

CHAPTER FIVE CONCLUSION AND FUTURE ENHANCEMENT 2867

Conclusion 2867
Future Enhancements 2667

REFERENCES 2868

IJISRT25JUL1842 [Link] 2849


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
LIST OF ABBREVATION

ABBREVATION EXPANSION
DB DataBase
JVM Java Virtual Machine
JSP Java Server Page
PWS Personalized Web Search
UPS User Personalized Search
JRE Java Runtime Environment
NC Network Coding
MTD Moving Target Defense
DES Dynamic Encryption Scheme
SQL Structured Query Language
CVEs Common Vulnerabilities and Exposures
AES Asymmetric Encryption Scheme
IDE Integrated Development Environment
CNC Convolutional Network Coding
LNC Linear Network Coding
HTML Hyper Text Markup Language
LPT Left Plain Text
RPT Right Plain Text
UTF Unicode Transformation Format
GF Galois field
Θ Greek Capital Letter Theta
◊ Lozenge
Π Greek Capital Letter Pi
∞ Infinity
~ Reversed Not Sign
√ Square Root

IJISRT25JUL1842 [Link] 2850


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
CHAPTER ONE
INTRODUCTION
 Introduction
Agriculture plays a vital role in the economic development of countries like India. Despite its importance, traditional farming
methods often result in inconsistent yields due to poor planning, unpredictable weather, and lack of actionable data. With the rise
of Machine Learning and Artificial Intelligence, it is now possible to enhance agricultural productivity through predictive
analytics.

This project, Smart Farming Assistant, integrates supervised ML algorithms such as Random Forest and XG Boost with
SHAP values to provide predictive insights and interpretability. The system predicts crop yields and estimates market prices based
on key input parameters like soil properties, historical weather patterns, and real-time market data. These predictions assist
farmers in planning crops, minimizing losses, and maximizing profit.

The Smart Farming Assistant aims to bridge the gap between traditional farming techniques and modern technological
solutions, ultimately contributing to data-driven agriculture in a scalable, user-friendly way.

 Problem Statement
Farmers often face difficulties in choosing the right crop and predicting yield and market prices. This leads to poor planning,
low profitability, and resource mismanagement. Unpredictable weather, lack of knowledge of soil health, and fluctuating market
prices further contribute to low productivity and increased risk.

There is a need for a reliable, data-driven system that helps farmers make better decisions by analyzing historical data and
generating accurate predictions on yield and pricing. Additionally, the solution must be interpretable so that farmers and
stakeholders can trust and understand the logic behind the predictions.

 Problem Definition
Traditional farming practices often rely on intuition and outdated methods, leading to unpredictable crop yields and poor
financial returns. Farmers struggle to choose the right crop or predict how much they can produce and sell it for, due to the
complexity of factors like soil health, weather variability, and volatile market prices. These uncertainties result in under-utilized
resources, financial losses, and reduced food security.

There is a pressing need for a smart, interpretable, and data-driven decision support system that can accurately predict crop
yield and market prices. The system must integrate soil, weather, and market data, use advanced machine learning algorithms for
prediction, and provide clear explanations of how decisions are made, so that farmers and agricultural stakeholders can trust and
act on the insights.

 Objectives
The key objectives of the Smart Farming Assistant project are:

 To develop a machine learning-based predictive system for crop yield and market price forecasting.
 To use SHAP values to explain the predictions made by ML models, ensuring transparency and interpretability.
 To integrate weather, soil, and market data for more accurate and context-aware predictions.
 To provide an accessible and intuitive web interface for farmers and agricultural decision-makers.
 To reduce risks, optimize crop selection, and improve agricultural planning and productivity.

 Scope
The scope of the Smart Farming Assistant includes the following:

 Focused prediction of crop yield and market price using pre-cleaned datasets related to soil, weather, and market data.
 Use of XGBoost for yield prediction and Random Forest for price prediction.
 Implementation of SHAP for model explainability, enabling users to understand the influence of each feature on the output.
 Development of a web-based interface for input and result visualization.
 Targeted for small and medium-scale farmers with potential for scaling.

IJISRT25JUL1842 [Link] 2851


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
CHAPTER TWO
REVIEW OF LITERATURE
 Research Methodologies
Numerous research studies have explored the application of machine learning in agriculture. Traditional models like Support
Vector Machines (SVM), Decision Trees, and Random Forests have shown moderate success in predicting crop yields and pricing
trends. However, these models lacked interpretability, making it difficult for users to understand or trust the results.

Recent advancements in Explainable AI (XAI) introduced SHAP (SHapley Additive exPlanations) as a powerful tool for
feature attribution. SHAP can identify which input variables most significantly impacted a model’s prediction, thus increasing
trust and reliability in ML systems.

XGBoost has proven to be highly effective in various machine learning competitions and real-world tasks, particularly in
handling tabular agricultural datasets with missing or noisy values. This project builds upon these advancements, combining
robust ML techniques with explainability for practical deployment in the farming sector

 Feasibility Studies
The feasibility study of the Smart Farming Assistant project was conducted to determine whether the proposed system is
practical and viable for development and deployment. The analysis was carried out under the following categories:

 Technical Feasibility
The system is technically feasible and is developed using widely accepted tools and technologies such as Python, Flask,
XGBoost, Random Forest, and SHAP for machine learning and model interpretability. The frontend is designed with HTML, CSS, and
basic JavaScript. These are open-source and platform-independent tools, making the solution technically robust, scalable, and easy to
deploy.

 Economic Feasibility
The project is highly cost-effective. Since it uses free and open-source tools (e.g., Python, scikit-learn, SHAP, Flask, VS
Code), there is no need for expensive licenses or proprietary platforms. Hosting can be done on free-tier platforms like Render,
Vercel, or GitHub Pages, ensuring minimal to zero operational costs during development and demonstration phases.

 Operational Feasibility
The system is user-friendly and requires minimal technical knowledge to operate. Farmers or agricultural officers can use it
through a simple web interface to enter soil, weather, and crop data and receive instant predictions and visual explanations. The
design ensures that the system can be operated without specialized training.

 Legal Feasibility
This project does not involve any third-party proprietary data or services that violate copyright or data privacy regulations. All
datasets used for model training are publicly available for educational use (e.g., Kaggle, government agricultural portals). No user-
sensitive data is collected, ensuring compliance with data protection policies.

 Schedule Feasibility
The project was divided into logical development phases: requirement gathering, model building, explainability integration,
frontend development, and testing. All tasks were completed within the given academic time frame. The modular structure allowed
easy parallel development and debugging.

 Proposed System

 Existing System
In the current agricultural landscape, several government and private platforms provide data portals or advisory services for
farmers. These systems generally include:

 Static crop advisory based on region and season


 Weather updates from sources like IMD or AccuWeather
 Soil health cards or nutrient maps
 Market price updates from local mandis

While these tools offer valuable information, they are largely manual, generic, and non-predictive. Most systems do not
leverage advanced analytics or personalized recommendations based on a farmer’s specific field conditions.

IJISRT25JUL1842 [Link] 2852


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 Disadvantages of Existing System

 Lack of Personalization
Existing advisory tools give broad suggestions but fail to adapt to specific soil, weather, or market conditions at the farm
level.

 No Predictive Capabilities
Most platforms don’t offer predictions for yield or price; they only display historical or static data.

 Poor Interpretability
Where ML is used, the outputs are often black-box predictions without explanations, leading to trust issues among users.

 Data Silos
Weather, soil, and market data are scattered across different platforms, requiring manual integration by the farmer.

 Complex Interfaces
Government portals are often not user-friendly, especially for farmers with limited digital literacy.

 Lack of Visual Insight


Even when predictions are available, they are not visualized in a way that is intuitive or easy to act upon.

 Internet Dependence
Some systems are not optimized for low-bandwidth or mobile access, limiting usage in rural or remote areas.

 Proposed Methods
The proposed Smart Farming Assistant system uses a supervised machine learning approach to predict both crop yields and
market prices. It processes input features such as soil type, pH, nitrogen, phosphorus, potassium content, weather data
(temperature, rainfall, humidity), and historical market prices.

The backend consists of two key ML models:

 XGBoost: For crop yield prediction due to its superior performance on tabular data.
 Random Forest: For price prediction, leveraging its robustness to overfitting.

The model outputs are interpreted using SHAP values, which show the influence of each feature on the final prediction. This
brings transparency to the black-box ML models and increases user trust.

The system consists of:

 A data preprocessing module for cleaning and normalizing input data.


 A training pipeline with evaluation metrics like RMSE, MAE, and R² score.
 A Flask-based API to handle user input and predictions.
 A frontend dashboard that visualizes predictions and SHAP values.

 System Architecture

 Proposed System Advantages

 Predicts crop yields and prices even with incomplete or low-resolution input data
 Adapts to different regions and climate conditions without recalibration
 Cost-effective solution using open-source tools and public API data

IJISRT25JUL1842 [Link] 2853


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 System Architecture

Fig 1 System Architecture

The architecture of the Smart Farming Assistant is structured to integrate multiple data sources and generate accurate,
explainable predictions using machine learning models. The system is modular and consists of distinct components that work
together to process environmental and agricultural data into actionable insights.

 High-Level Architecture
At the core of the system is a feature integration pipeline called Features_SLR, which collects and organizes data from the
following main categories:

 Crop Information

 Growth Process: Captures the biological growth stage of the crop.


 Leaf Area Index: A key indicator for assessing canopy development and productivity.

 Soil Map

 Soil Type
 pH of Soil
 CEC (Cation Exchange Capacity)

IJISRT25JUL1842 [Link] 2854


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
These parameters are essential for understanding soil fertility and how it interacts with nutrient application and water
retention.

 Soil Information

 Crop Area
 Rainfall
 Humidity
 Precipitation

These metrics impact both the choice of crop and the expected yield under given weather conditions.

 Nutrients

 Nutrients in Soil
 Added Nutrients

This includes both natural soil fertility and external fertilization, which directly influences yield prediction.

 Field Management

 Irrigation
 Fertilization

These are controllable inputs that can be adjusted to improve yield and profitability.

 Solar Information

 Gamma Radiation
 Temperature
 Photoperiod
 Shortwave Radiation

These environmental parameters affect plant photosynthesis and growth cycles.

 Other Features

 Wind Speed
 Atmospheric Pressure
 Images (optional for satellite or field-level analysis)

These are used for finer analysis or potential model enhancements through image-based crop health detection.

 Calculated Features

 NDVI (Normalized Difference Vegetation Index)


 EVI (Enhanced Vegetation Index)

These remote sensing indices, when available, serve as strong indicators of crop health and biomass.

 Data Flow Overview

 All input parameters are processed into a feature vector.


 The ML pipeline uses XGBoost and Random Forest models to predict:

 Crop Yield
 Market Price

 SHAP values are calculated to explain model predictions.


 Results are rendered on a web dashboard with graphs and interpretation tools.

IJISRT25JUL1842 [Link] 2855


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 Project Description

 General
The Smart Farming Assistant is a predictive system that helps farmers make informed decisions by estimating crop yield and
market price based on soil, weather, and market data. It uses machine learning models like XGBoost and Random Forest,
combined with SHAP values for interpretability.

Users input data through a simple web interface. The system processes this information, predicts outcomes, and visually
explains which factors influenced the results. It is designed to be user-friendly, scalable, and educational — turning complex ML
insights into actionable advice for the agricultural community.

The platform is built with a modular, scalable design. It features:

 A backend pipeline for data ingestion, preprocessing, model training, and SHAP explanation generation.
 A web-based frontend where users can input their soil/weather/crop parameters and visualize predictions and insights.
 A REST API layer for integration with future mobile apps or third-party systems.

The primary users of the system include farmers, agricultural officers, researchers, and policy-makers. The tool serves as a
bridge between AI research and field-level application.

 Modules Description

 Data Collection Module

 Accepts historical and current soil, weather, and market data.


 Validates and stores the data.

 Machine Learning Module

 Trains models using XGBoost and Random Forest.


 Performs cross-validation and hyperparameter tuning.

 Prediction Module

 Takes new input and predicts crop yield and expected price.
 Integrates SHAP for model interpretability.

 Explainability Module

 Visualizes SHAP plots to explain predictions.


 Enables users to understand “why” a prediction was made.

 Frontend Module

 User-friendly input forms.


 Visualizes results and graphs using Plotly/[Link].

 Deployment Module

 Application hosted using platforms like Render, Vercel, or Heroku.


 Supports API-based prediction requests.

 System Requirements Specification

 Hardware Requirements

 Processor: Intel i5
 Ram: 8 GB
 Hard Disk: 60 GB
 Input Devices: Keyboard & Mouse

IJISRT25JUL1842 [Link] 2856


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 Software Requirements

 Operating System: Windows


 Front End: HTML, CSS,
 Server-side Script: PHP
 Programming Language: Python

IJISRT25JUL1842 [Link] 2857


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
CHAPTER THREE
DESIGN AND IMPLEMENTATION
A. Unified Modelling Language
UML diagrams are used to visually represent the structure, behavior, and interactions within a system.

 Model

 Use Case Diagram

 Purpose: Represents interactions between users (Actors) and the system.

 Actors:

 Farmer: Inputs Data, views predictions


 Admin: Manages dataset uploads and model retraining

 Class Diagram

 Purpose: Shows the structure of classes and relationships between them.

 Key Classes:

 User: id, name, email


 InputData: soil features, weather, market data
 MLModel: train(), predict() , explain()
 Prediction: yield, price, shap_values

 Relationships:

 User → Input Data (1-to-many)


 ML Model → Prediction (many-to-1)

 Sequence Diagram

 Purpose: Describes the order of interactions in processes like booking a room.

 Example Flow:
User → Enters input data → Frontend → Groq API →ML Engine →Returns yield and price predictions → Groq API sends
info to Frontend → Frontend displays results.

 Activity Diagram

 Purpose: Shows the flow of actions in a process (e.g., making a booking).

 Example:
Start → Input Data → Validate → Predict →Generate SHAP → Display Results→ End

 Component Diagram

 Purpose: Represents the high-level components of the system and how they interact.

 Components:

 User Interface
 Backend API (Flask Server)
 ML Engine
 SHAP Interpretability Module
 Data Handling Module

IJISRT25JUL1842 [Link] 2858


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 Deployment Diagram

 Purpose: Visualizes the physical deployment of the application.

 Nodes:

 Client (Web Browser)


 Web Server (Flask + Python)
 Model Storage

 Applications of UML

 Helps visualize the system’s architecture and components.


 Models user interactions via use case diagrams.
 Represents workflows and system logic using activity diagrams.
 Shows interaction flow between components with sequence diagrams.
 Serves as technical documentation for easier understanding.
 Enhances team communication and collaboration.
 Assists in system maintenance and future upgrades.

 Use Case Diagram

Fig 2 Use Case Diagram

 Class Diagram

Fig 3 Class Diagram

IJISRT25JUL1842 [Link] 2859


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 Sequence Diagram

Fig 4 Sequence Diagram

 Activity Diagram

Fig 5 Activity Diagram

IJISRT25JUL1842 [Link] 2860


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
 Collaboration Diagram

Fig 6 Collaboration Diagram

 Sample Code

import streamlit as st
from groq import Groq

# Initialize Groq client


client = Groq(api_key="gsk_********")

st.set_page_config(page_title="Smart Crop Dashboard", layout="wide")

[Link]("🌾 Smart Crop Prediction & Analysis Dashboard")


[Link]("Get recommendations, risk analysis, and financial estimations based on your inputs.")

# --- Input Fields ---


col1, col2, col3 = [Link](3)
with col1:
crop = st.text_input("🧪 Crop Name", "Barley")

with col2:
area = st.number_input("🌍 Area in Acres", min_value=0.1, step=0.1, value=1.0)

with col3:
soil = [Link]("🧪 Soil Type", ["Alluvial", "Black", "Red", "Laterite", "Mountain", "Desert"])

# --- Translation Selector ---


language = [Link]("🌐 Translate Output To", ["English", "Hindi", "Telugu"])

# --- AI Recommendation ---


def get_ai_recommendation(crop, area, soil):
prompt = f"""
Act as an experienced Indian agricultural advisor.
Provide detailed, organized, and farmer-friendly advice on growing {crop} on {area} acre of {soil} soil in India.
Include soil suitability, sowing time, seed rate, fertilizers, irrigation, pest management, harvesting, and expected returns.
Present the info in clean bullet or section format.
"""
response = [Link](
model="meta-llama/llama-4-scout-17b-16e-instruct",
messages=[{"role": "user", "content": prompt}]
)
return [Link][0].[Link]

# --- AI Balance Sheet ---


def get_ai_balance_sheet(crop, area, soil):
prompt = f"""
Act like an agricultural economist and create a realistic and farmer-friendly investment and profit balance sheet for growing
{crop} on {area} acre of {soil} soil in India.
Use latest realistic prices and yield data. Present this in a clear table format with:
- Estimated cost breakdown: seeds, fertilizers, labour, irrigation, pesticides, machinery
- Total investment

IJISRT25JUL1842 [Link] 2861


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
- Expected yield per acre and total yield
- Market selling price per quintal
- Gross income and net profit
- Tips or notes for cost-saving or increasing profit
All values should be in INR, and keep everything highly readable for Indian farmers.
"""
response = [Link](
model="meta-llama/llama-4-scout-17b-16e-instruct",
messages=[{"role": "user", "content": prompt}]
)
return [Link][0].[Link]

# --- Translator Function ---


def translate_text(text, lang):
if lang == "English":
return text
lang_code = {"Hindi": "hi", "Telugu": "te"}[lang]
translation_prompt = f"Translate the following text to {lang} ({lang_code}):\n\n{text}"
response = [Link](
model="meta-llama/llama-4-scout-17b-16e-instruct",
messages=[{"role": "user", "content": translation_prompt}]
)
return [Link][0].[Link]

# --- Recommendation Button ---


if [Link]("🧪 Get AI Recommendation"):
[Link]("📊 Real-time Analysis & Advice")
with [Link]("🔍 Analyzing with AI..."):
ai_output = get_ai_recommendation(crop, area, soil)
ai_output = translate_text(ai_output, language)
[Link](ai_output)

# --- Balance Sheet Button ---


if [Link]("📑 Show Balance Sheet"):
[Link]("📈 Crop Investment & Profit Estimation Sheet")
with [Link]("🧪 Preparing AI-generated balance sheet..."):
ai_balance_sheet = get_ai_balance_sheet(crop, area, soil)
ai_balance_sheet = translate_text(ai_balance_sheet, language)
[Link](ai_balance_sheet

 Screenshots

IJISRT25JUL1842 [Link] 2862


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]

IJISRT25JUL1842 [Link] 2863


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]

IJISRT25JUL1842 [Link] 2864


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
CHAPTER FOUR
JUSTIFICATION AND DISCUSSION OF THE RESULTS
A. Theoretical Justification
The selection of technologies and methodologies in the Smart Farming Assistant is backed by solid theoretical foundations in
machine learning and data science.

 Use of Supervised Machine Learning


Supervised learning algorithms like XGBoost and Random Forest are theoretically proven to handle high-dimensional
tabular data with excellent performance. These ensemble models reduce variance and bias through boosting and bagging
techniques, which improves prediction accuracy for real-world data like crop yields and prices.

 XGBoost (Extreme Gradient Boosting) is based on gradient descent optimization and decision tree ensembles. It is robust
against overfitting and performs well on sparse and noisy agricultural datasets.
 Random Forest uses multiple decision trees and aggregates their results to make accurate, stable predictions. It’s particularly
effective for price prediction where relationships are nonlinear and noisy.

 Use of SHAP for Explainability


SHAP (SHapley Additive exPlanations) is grounded in cooperative game theory. It attributes the contribution of each input
feature to the model’s output, ensuring fairness and interpretability.

Theoretically, SHAP satisfies key properties like:

 Additivity (the sum of feature contributions equals the output),


 Consistency (more important features get higher values),
 Local accuracy (exact explanation for a given prediction).

This makes SHAP ideal for agriculture, where stakeholders require transparency to trust automated decisions.

 Feature Engineering and Data Preprocessing


Agricultural data often contain missing values, outliers, and nonlinear patterns. Preprocessing techniques like normalization,
label encoding, and imputation are used based on standard statistical principles to ensure the data fits ML model assumptions and
performs well.

 Visualization and user Interaction


The project uses basic web development principles (HTML, CSS, JavaScript) and data visualization libraries (e.g., Plotly,
Matplotlib) to present complex ML predictions in a form that’s easy to understand — combining human-computer interaction
theory with explainable AI.

This theoretical foundation ensures the system is not only practically effective but also scientifically sound, justifying its
adoption in real-world agricultural decision support.

B. Benefit Discussion of the Scheme


The Smart Farming Assistant offers a wide range of practical and technical benefits for both farmers and agricultural
planners:

 Accurate Predictions
By using machine learning models like XGBoost and Random Forest, the system provides high-accuracy forecasts of crop
yield and market prices. This helps farmers reduce uncertainty and make better-informed decisions.

 Explainable Outputs
Traditional ML systems often act as “black boxes,” but this project integrates SHAP values to explain the influence of each
input feature. This increases user trust and helps users understand which factors (e.g., rainfall, soil pH, fertilizer) impact their
results the most.

 Data-Driven Farming
The system promotes data-driven agriculture by combining various inputs such as soil health, weather patterns, and market
trends. This ensures holistic decision-making rather than relying on intuition or outdated practices.

 Cost-Effective and Scalable


The project uses open-source tools and free cloud platforms, making it highly economical. It can be scaled further to support

IJISRT25JUL1842 [Link] 2865


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
mobile apps, more crops, or even integrate IoT/sensor data.

 User-Friendly Interface
A simple and responsive web interface ensures that even non-technical users can interact with the system easily. Farmers can
quickly input data and receive actionable insights within seconds.

 Educational Value
Besides practical use, the system has strong academic value. It demonstrates real-world applications of machine learning,
model explainability, and system integration — useful for students, researchers, and educators.

 Environmental and Economic Impact


By improving crop planning and reducing resource wastage, the system contributes to sustainable agriculture and helps
improve farmer income, aligning with broader national and global agricultural goals.

IJISRT25JUL1842 [Link] 2866


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
CHAPTER FIVE
CONCLUSION AND FUTURE ENHANCEMENT
 Conclusion
The Smart Farming Assistant successfully integrates ML and explainability to provide farmers with actionable insights. It
predicts yields and prices with high accuracy and explains the reasoning behind the predictions using SHAP. The web dashboard
makes it easy for users to interact with the system.

 Future Enhancements
While the current version is fully functional, several improvements can be made in future versions:

 Integration with IoT sensors for real-time soil/weather monitoring.


 Mobile app version for offline usability.
 Multi-language support for regional farmers.
 Add feedback-based model improvement loop.

IJISRT25JUL1842 [Link] 2867


Volume 10, Issue 7, July – 2025 International Journal of Innovative Science and Research Technology
ISSN No:-2456-2165 [Link]
REFERENCES
[1]. Friedman, J. H. (2001). Greedy Function Approximation: A Gradient Boosting Machine.
[2]. Breiman, L. (2001). Random Forests.
[3]. Lundberg, S. M., & Lee, S.-I. (2017). A Unified Approach to Interpreting Model Predictions.
[4]. [Link]
[5]. [Link]
[6]. [Link] for crop/soil/weather data
[7]. [Link]
[8]. [Link]
[9]. [Link] for visualizations

IJISRT25JUL1842 [Link] 2868

You might also like