🏆
Authentic Engineering Platform
Serving Researchers Since 2012

Smart Crop and Nutrient Advisory System using Machine Learning

DOI : https://doi.org/10.5281/zenodo.19594563
Download Full-Text PDF Cite this Publication

Text Only Version

Smart Crop and Nutrient Advisory System using Machine Learning

Mrs. B Sivadharshini

Assistant Professor, Artificial Intelligence and Data Science PPG Institute of Technology Coimbatore – 641 035

Tamil Nadu , India

Sreemathi P

B Tech Artificial Intelligence and Data Science

PPG Institute of Technology Coimbatore – 641 035

Tamil Nadu , India

Sahaya Riana X

B Tech Artificial Intelligence and Data Science

PPG Institute of Technology Coimbatore 641 035 Tamil Nadu , India

Luxciya G

B Tech Artificial Intelligence and Data Science PPG Institute of Technology

Coimbatore 641 035 Tamil Nadu , India

Ruthra Priya T

B Tech Artificial Intelligence and Data Science PPG Institute of Technology

Coimbatore 641 035 Tamil Nadu , India

Abstract – Precision agriculture demands intelligent systems that integrate soil, environmental, and regional parameters for optimized crop planning. This research proposes a hybrid AI-based Smart Crop and Nutrient Advisory system combining multiple machine learning models including Random Forest, XGBoost, CatBoost, Support Vector Machine, and Logistic Regression along with generative AI for region-specific recommendations. A synthetic multi-regional dataset was used for training and stratified validation. Experimental results demonstrate superior ensemble model accuracy in multi-class crop prediction. A generative AI module provides contextual nutrient guidance and expert advisory responses through an interactive web interface, supporting real-time decision-making and sustainable farming practices. The system also incorporates a multilingual quick summary and voice assistance module to improve accessibility for farmers.

Keywords – Precision Agriculture, Crop Recommendation, Ensemble Machine Learning, Generative Artificial Intelligence, Nutrient Advisory System, Decision Support System

INTRODUCTION

Agriculture is a vital sector for economic stability and food security, especially in developing regions where crop yields rely heavily on environmental and soil conditions. Farmers often make decisions based on experience rather than data, which can lead to poor crop choices and inefficient use of nutrients. Recent progress in artificial intelligence and machine learning has led to the creation of smart agricultural advisory systems that can improve decision-making.

This research introduces a hybrid AI-based Smart Crop and Nutrient Advisory System that combines machine learning

techniques with generative artificial intelligence. It offers crop recommendations and nutrient advice tailored to specific regions. By considering soil factors like nitrogen, phosphorus, potassium, pH, temperature, rainfall, and seasonal conditions, the system improves prediction reliability. The framework’s deployment through a real-time web interface also encourages practical use, supporting data-driven and sustainable farming methods.

    1. Background and Motivation

      Agriculture in South India faces major challenges due to changes in climate, irregular monsoon patterns, soil nutrient loss, and local crop suitability issues. Farmers often depend on traditional knowledge and broad advice, which may not consider changing environmental factors or soil health. Differences in temperature, rainfall patterns, and soil types across districts create uncertainty in choosing crops and managing fertilizers. Limited access to expert guidance makes it hard for small and marginal farmers to make informed decisions. These issues emphasize the need for a smart, data- based advisory system that combines soil, seasonal, and regional information to give precise crop recommendations and nutrient management advice.

    2. Importance of Intelligent Crop and Nutrient Advisory

      Region-specific and nutrient-aware advisory systems are important for improving agricultural productivity and sustainability. Soil composition, climate conditions, and

      seasonal changes vary greatly across regions. These differences directly impact crop growth and yield potential. Generic recommendations often lead to wasteful fertilizer use, higher production costs, and harm to the environment from nutrient imbalance. An intelligent advisory system that examines nitrogen, phosphorus, potassium levels, pH, rainfall, and temperature allows for precise crop selection and better nutrient management. This data-driven support reduces resource waste, enhances soil health, and boosts yield efficiency.

      Therefore, including artificial intelligence in agricultural advisory frameworks helps support informed farming practices and long-term sustainability.

    3. Objectives of the Proposed System

      The proposed system aims to develop a hybrid AI-based framework that provides accurate crop recommendations and nutrient advisory based on soil, seasonal, and regional parameters. It seeks to enhance prediction accuracy, support sustainable farming decisions, and deliver real-time, user- friendly agricultural guidance through an interactive web platform.

    4. Hybrid AI Approach

      The proposed system integrates machine learning models for data-driven crop prediction with generative artificial intelligence for contextual nutrient and expert advisory responses. While the classification model ensures accurate crop selection, the generative AI component enhances interpretability by delivering personalized, region-specific recommendations through natural language interaction.

    5. Organization of the Paper

      This paper is set up in a simple way. The next part, Section 2 is about looking at what other people have done with crop recommendation systems and AI-based agricultural advisory models. Section 3 is where we talk about the hybrid AI architecture we came up with including how we got the data ready what features we used how we built the model and how we plan to put it to use. Section 4 is all about the results we got from our experiments how well the models did and how they compare to each other .

      Then there is Section 5 which’s about how to actually make the system work and get it out there in the real world. Finally we wrap up the paper with the things we found out and some ideas for how to make it even better, for farmers and people who work in agriculture so it can be used in a big way.

      1. LITERATURE REVIEW

        Crop recommendation and nutrient management are important areas of research now because of the changing climate and soil problems. We need to find ways to make farming more sustainable. [1]. Traditional farming methods rely on experience and general rules for using fertilizers. These methods do not work well for every region and season. [2]. Early computer programs used statistics and rules to choose crops. These programs were not flexible and could not handle changes in the environment. [3].

        Now with machine learning we can use algorithms like Support Vector Machines and Random Forest to predict which crops will grow well and analyze the soil. [4]. These models utilize parameters including nitrogen, phosphorus, potassium, pH, rainfall, and temperature to classify suitable crops. Ensemble learning methods, particularly Random Forest, have demonstrated improved robustness and generalization by reducing overfitting and handling multi-class agricultural datasets effectively [5]. Regression-based techniques have also been employed for yield estimation and nutrient prediction, though their performance may vary depending on feaure distribution and data imbalance [6].

        Recent developments in artificial intelligence have further expanded agricultural advisory systems through the integration of deep learning and intelligent decision-support frameworks [7]. AI-driven systems are increasingly capable of analyzing large-scale environmental data, automating crop suitability analysis, and providing optimized fertilizer recommendations. However, many existing models primarily focus on prediction accuracy without offering interpretability or user-friendly interaction mechanisms [8].

        The emergence of generative artificial intelligence and conversational AI systems has introduced a new dimension to agricultural support platforms [9]. AI chat-based advisory systems enable farmers to receive contextual, real-time guidance in natural language format, improving accessibility and decision confidence. Despite this progress, limited research has explored the integration of predictive machine learning models with generative AI to create hybrid agricultural advisory frameworks [10]. Furthermore, most studies emphasize crop prediction while neglecting comprehensive nutrient advisory and region-specific contextualization [11].

        These research gaps highlight the necessity for a hybrid AI- based crop and nutrient advisory system that combines ensemble machine learning for accurate classification with generative AI for interpretative and expert-level recommendations. The proposed framework aims to bridge predictive analytics and intelligent advisory support,

        contributing to precision agriculture and sustainable farming practices [12].

        2.2. Comparative Analysis with Base Pafper

        Nutrient Advisory System. The comparison highlights differences in machine learning techniques, dataset design, system architecture, and additional intelligent features such as generative AI integration and user interaction capabilities.

        Table 1 presents a detailed comparative analysis between the selected base paper and the proposed Smart Crop and

        Feature / Aspect

        Base Paper (Sunandini et al., IJERT 2024)

        Proposed System (Smart Crop & Nutrient Advisory)

        Objective

        Soil nutrient monitoring and crop recommendation using IoT sensors

        Hybrid AI-based crop recommendation and nutrient advisory with generative AI

        ML Algorithms

        Decision Tree, XGBoost, Random Forest, Linear Regression

        Random Forest

        ,XGBoost, CatBoost, Support Vector Machine, Logistic Regression

        AI Integration

        No AI chat or generative AI component

        Generative AI module for contextual, natural- language nutrient advisory

        Model Comparison

        Limited comparison

        Extensive multi- model comparison and evaluation

        Dataset Type

        Real-time IoT sensor data (N, P, K, pH, Humidity, Temperature, Rainfall)

        Synthetic multi- regional dataset with soil + seasonal

        + regional parameters

        Input Parameters

        N, P, K, Humidity, pH, Soil Temperature, Average Rainfall

        N, P, K, pH,

        Temperature, Rainfall, Soil type, Season, Region

        Hardware Required

        Arduino, Raspberry Pi, ESP32, DHT11/22, LM35, PIC16F877-A,

        relays, pumps

        No physical hardware; entirely software- based web system

        Interface / Deployment

        IoT embedded system with LCD

        Interactive web application (real-time, browser-based)

        Crop Prediction

        Yes via Decision Tree and XGBoost

        Yes via XGBoost

        ,Random Forest, CatBoost, SVM and Logistic Regression

        Nutrient Advisory

        Limited monitors soil nutrients via sensors

        Full AI + ML advisory; generative AI provides contextual guidance

        AI Chat Assistance

        Not available

        Yes conversational AI for expert-level query responses

        Crop Recommendation

        Basic Recommendation

        Advanced multi- model prediction with probability insights

        Fertilizer Recommendation

        Indirect via sensor monitoring and pump control

        Direct through AI- generated nutrient management advice

        Region-Specific Support

        No generic recommendations

        Yes region and season-aware recommendations (South India focused)

        Connectivity

        Wireless: Wi-Fi, Bluetooth, ZigBee, GSM via WSN

        Web-based; no special connectivity hardware required

        Data Transmission

        Sensor Arduino/RPi ESP32 Cloud

        Web form input ML Model

        Generative AI Web

        output

        Accuracy

        ~8085% (reported for ML models used)

        92.72% (XGBoost),

        91.67% (RF),

        90.56% (CatBoost)

        Scalability

        Limited by physical sensor deployment costs

        Highly scalable via web platform and synthetic dataset expansion

        Energy Consideration

        Battery + solar power suggested

        Not applicable (server-side processing)

        Future Scope

        Mobile app, remote irrigation control, web notifications

        Weather forecasting integration, more crop classes, regional expansion

        Table 1 : Comparative Analysis between Base Paper and Proposed System.

      2. METHODOLOGY

        The methodology proposes a hybrid artificial intelligence framework for crop recommendation and nutrient advisory using integrated machine learning and generative AI, as shown in the figure below. We engineered a structured agricultural data set consisting of soil parameters like nitrogen, phosphorus, potassium, pH, temperature, rainfall data and season and regional features. Preprocessing techniques including encoding, normalization, and stratified traintest splitting were applied to make the model robust. For multi-class crop prediction, ensemble learning models such as Random Forest, XGBoost and CatBoost were employed due to their robustness and lower risk of overfitting. Additionally Logistic Regression and Support Vector Machine were utilized for comparative performance evaluation.To enhance interpretability and user interaction, a generative AI module was integrated to provide contextual nutrient guidance and expert-level advisory responses based on predicted outputs. The complete system was deployed through a web-based interface enabling real-time input, prediction, and logging. This hybrid methodology ensures accurate, scalable, and user-centric agricultural decision support.

        1. Overview of the Hybrid AI Framework

          The hybrid AI framework integrates multiple machine learning models including Random Forest, XGBoost, CatBoost, Support Vector Machine, and Logistic Regression for crop prediction with a generative AI module for contextual nutrient and expert advisory responses. A web-based user interface enables real-time interaction, while a structured logging mechanism records inputs and predictions for monitoring, evaluation, and continuous improvement.

        2. Dataset Design and Synthetic Data Generation

          The data was synthetically created to mimic realistic conditions in an agricultural environment. Structured data was created in the form of crop profiles (CROP_PROFILES), which defined the optimal range for different soil nutrients, pH levels, temperatures, and rainfall levels for different categories of crops. Furthermore, a list called HIGH_DEMAND_CROPS was added to account for region-specific crop cultivation patterns.

          Using these data profiles, 8,100 data samples were created by varying environmental and soil conditions in scientifically reasonable limits. This type of synthetic data creation helped to ensure a well-balanced data distribution and facilitated better model generalization for training multi-class crop prediction algorithms.

        3. Feature Engineering and Input Parameters

          Feature engineering involved selecting agronomically significant parameters influencing crop growth. Key inputs included nitrogen, phosphorus, potassium levels, soil pH, moisture content, soil type, temperature, rainfall, season, and region. These features were encoded and structured to capture environmental variability, enabling accurate multi-class crop prediction and nutrient advisory modeling.

        4. Preprocessing and Encoding Techniques

          Data preprocessing involved handling structured synthetic inputs through normalization and categorical encoding. OrdinalEncoder was applied to transform categorical features such as soil type, season, and region into numerical representations. LabelEncoder was used for encoding crop classes. The dataset was divided using an 8020 traintest split to ensure unbiased evaluation.

        5. Machine Learning Model Development

          The machine learning framework employs multiple classification models for multi-class crop prediction, including Random Forest, XGBoost, and CatBoost as ensemble and boosting techniques. As an ensemble learning method, Random Forest constructs multiple decision trees and aggregates their outputs to enhance prediction accuracy and reduce overfitting. Its ability to handle nonlinear relationships and high- dimensional agricultural data makes it suitable for this application. In addition, boosting-based models such as XGBoost and CatBoost further enhance predictive performance by sequentially learning from previous errors and capturing complex feature interactions.

          For comparative analysis, Logistic Regression was implemented as a baseline classification model, while Support Vector Machine was used to evaluate margin-based classification performance. Baseline models such as Logistic Regression were included to compare performance with advanced ensemble and boosting techniques.

        6. Generative AI Prompt Engineering Strategy

          The generative AI module utilizes structured prompt templates designed for crop recommendation explanation, nutrient advisory, and expert consultation. Prompts dynamically incorporate predicted crop labels, soil parameters, and regional context to generate personalized, agronomically relevant responses. This structured prompt engineering ensures consistency, interpretability, and domain-specific guidance.

        7. Model Training and Validation Strategy

          The dataset was partitioned using an 8020 traintest split to ensure reliable performance assessment. Stratified sampling was applied to maintain balanced crop class distribution across

          training and testing sets. This strategy improves generalization capability and prevents bias in multi-class agricultural prediction tasks.

        8. Deployment Architecture and Web Integration

          The complete system deployment has been carried out using a Streamlit-based web application for offering an interactive user interface for real-time agricultural advisory services. Session state management has been included for maintaining user inputs as well as prediction outputs during user interaction.

          The machine learning model processes the input parameters to obtain crop prediction outputs, which are further passed to the generative AI component through the Gemini API for offering contextual nutrient prediction as well as expert advisory outputs. The CSV-logging mechanism is included for user inputs, prediction outputs, and advisory outputs for performance evaluation of the model.

      3. PROPOSED SYSTEM

        The proposed system integrates ensemble machine learning with generative artificial intelligence to deliver accurate crop prediction and contextual nutrient advisory. The architecture combines data-driven classification, interpretative AI responses, and a web-based deployment framework to ensure practical usability and scalable agricultural decision support. To further enhance accessibility, the system incorporates a Quick Summary module with multilingual support that automatically translates recommendations into regional languages such as Tamil, Telugu, Kannada, and Malayalam based on the users state selection.

        A Text-to-Speech voice assistance feature allows farmers to listen to recommendations in their preferred language, reducing barriers for users with limited literacy or reading difficulties. The system also supports multi-model prediction comparison to enhance reliability and transparency in crop recommendation. This farmer-friendly design makes the system suitable for real- world agricultural deployment across diverse regions of South India.

        Figure1 : Proposed architecture of the crop and fertilizer recommendation module.

        1. Dataset Statistics and Class Distribution

          The experimental dataset consists of 8,100 synthetic samples representing 45 distinct crop categories across 17 regions and 9 seasonal conditions. Class distribution was balanced to prevent model bias and ensure reliable multi-class classification. Regional and seasonal diversity enhanced generalization capability under varied agricultural scenarios.

        2. Quantitative Performance Metrics

          Model evaluation was conducted using accuracy as the primary performance metric. The XGBoost classifier achieved the highest accuracy of 92.72%, followed by Random Forest (91.67%) and CatBoost (90.56%). Support Vector Machine achieved 81.17%, while Logistic Regression achieved 69.81%. These results indicate the superiority of ensemble and boosting techniques over traditional classification approaches.

          Table 2 : Comparative performance analysis of machine learning models

        3. Confusion Matrix and Multi-Class Evaluation

          The confusion matrix analysis revealed high true-positive rates across major crop classes, indicating strong classification consistency. Misclassifications primarily occurred between crops with similar nutrient and seasonal requirements. Overall, the model demonstrated stable performance with minimal cross- class prediction errors in multi-class agricultural scenarios.

        4. Feature Importance and Model Interpretation

          Feature importance analysis from the Random Forest model indicated that season, potassium levels, and nitrogen concentration were the most influential predictors in crop selection. Regional attributes and rainfall also contributed significantly to classification decisions. These findings align with agronomc principles, where nutrient balance and seasonal suitability strongly impact crop productivity. The models interpretability enhances transparency, enabling users to understand how environmental and soil parameters influence prediction outcomes.

        5. Comparative Model Performance Analysis

          Comparative evaluation confirmed that ensemble-based models, particularly Random Forest and XGBoost, significantly outperformed baseline models in multi-class crop prediction. While Random Forest and other boosting techniques effectively captured nonlinear relationships and complex feature interactions, Logistic Regression showed comparatively lower

          performance due to its linear nature. Support Vector Machine demonstrated moderate classification capability, whereas CatBoost and XGBoost achieved higher predictive accuracy by efficiently handling structured agricultural data.

        6. AI Advisory Output Evaluation

          The generative AI module produced context-aware, region- specific nutrient guidance aligned with predicted crops. Responses demonstrated logical consistency, agronomic relevance, and clear interpretability, enhancing user confidence and decision-making support.

        7. System Output Screens and Case Studies

          The system interface enables users to input soil nutrient values, environmental parameters, season, and region through an interactive web form. Upon submission, the machine learning model predicts the most suitable crop, followed by AI-generated nutrient recommendations and expert advisory insights. For example, when nitrogen and potassium levels were moderate with adequate rainfall during a specific season, the system recommended a regionally suitable crop and suggested optimized fertilizer application strategies. Logged outputs confirm real-time functionality, ensuring traceability and performance monitoring. These case studies demonstrate the systems ability to provide accurate, context-sensitive agricultural guidance across diverse farming conditions.

          Figure 2: Crop Recommendation Interface

        8. Discussion on Practical Implications

          The proposed system supports data-driven agricultural decision-making, reduces fertilizer misuse, and enhances crop selection accuracy. By integrating predictive analytics with intelligent advisory responses, it contributes to sustainable farming practices, improved yield optimization, and accessible AI-driven support for farmers in diverse regional contexts.

          Figure 3: Nutrient Advisory Module

          Figure 4: AI-Based Expert Chat Interface

          Figure 5: Machine Learning Crop Prediction Module

          Figure 6 : Workflow of the proposed crop recommendation system.

      4. CONCLUSION

The current research proposes a hybrid intelligent approach to developing an AI-based Smart Crop and Nutrient Advisory System that aims to improve decision-making within agricultural settings. This is achieved through the integration of multiple machine learning models including XGBoost, Random Forest, and CatBoost. Among the evaluated models, XGBoost achieved the highest performance. as well as generative forms of artificial intelligence to provide nutrient guidance.

This approach enables a connection between predictive analytics tools and expert advisory support. The results of the experimental evaluation have shown that the proposed approach has achieved promising results, with the ensemble classifier successfully addressing nonlinear relationships within soil, seasonal, and regional features. The development of an interactive web interface for the system ensures that it is accessible.

The proposed approach has shown that machine learning techniques, as well as generative forms of artificial intelligence, are effective tools within precision agriculture. The proposed system has shown that it has the potential to support sustainable agriculture. The inclusion of multilingual voice-enabled advisory further enhances real-world usability.

FUTURE SCOPE

The system can also be improved by integrating real-time soil sensors and weather forecasting APIs to increase the precision of the predictions in changing environmental conditions. The system can also be improved by integrating satellite images and remote sensors to monitor crops on a large scale.

The system can also be improved by developing mobile application deployment with multilingual support to cater to farmers in different regions. The system can also be improved by collecting data on real-world fields to generalize the model. The system can also be improved by integrating reinforcement learning techniques to optimize precision.

REFERENCE

  1. R. Kamilaris and F. X. Prenafeta-Boldú, Deep learning in agriculture: A survey, Computers and Electronics in Agriculture, vol. 147, pp. 7090, 2018. Elsevier.

  2. S. B. Kotsiantis, Decision trees: A recent overview, Artificial

    Intelligence Review, vol. 39, no. 4, pp. 261283, 2013. Springer.

  3. L. Breiman, Random forests, Machine Learning, vol. 45, no. 1, pp. 5

    32, 2001. Springer.

  4. J. R. Quinlan, Induction of decision trees, Machine Learning, vol. 1,

    no. 1, pp. 81106, 1986.

  5. A. Sharma, A. Jain, P. Gupta, and V. Chowdary, Machine learning applications for precision agriculture: A comprehensive review, IEEE Access, vol. 9, pp. 48434873, 2021. IEEE.

  6. S. Ramesh and R. Vydeki, Application of machine learning in crop yield prediction, International Journal of Computer Applications, vol. 119, no. 6, 2015.

  7. T. Wolf et al., Transformers: State-of-the-art natural language

    processing, in Proceedings of EMNLP, 2020.

  8. T. B. Brown et al., Language models are few-shot learners, in

    Advances in Neural Information Processing Systems (NeurIPS), 2020.

  9. J. Devlin, M. Chang, K. Lee, and K. Toutanova, BERT: Pre-training of deep bidirectional transformers for language understanding, in NAACL-HLT, 2019.

  10. P. Singh, R. Singh, and A. Singh, Crop recommendation system using machine learning, International Journal of Engineering Research & Technology, 2020.

  11. M. Pantazi, D. Moshou, A. Tamouridou, T. Alexandridis, and A. Whetton, Automated leaf disease detection in different crop species through image features analysis and one class classifiers, Computers and Electronics in Agriculture, 2019.

  12. S. S. Dhaliwal and R. Jindal, Soil nutrient management using data- driven approaches, Agricultural Systems, vol. 178, 2020.

  13. K. P. Ferentinos, Deep learning models for plant disease detection and diagnosis, Computers and Electronics in Agriculture, vol. 145, pp. 311318, 2018.

  14. FAO, The State of Food and Agriculture, Food and Agriculture

    Organization of the United Nations, Rome, 2022.

  15. A. K. Mishra, D. Kumar, and R. Singh, Smart agriculture using IoT and machine learning, IEEE Internet of Things Journal, 2020.

  16. C. Zhang and J. M. Kovacs, The application of small unmanned aerial systems for precision agriculture, Precision Agriculture, vol. 13, pp. 693712, 2012. Springer.

  17. S. Goodfellow, Y. Bengio, and A. Courville, Deep Learning. MIT Press, 2016.

  18. S. Russell and P. Norvig, Artificial Intelligence: A Modern Approach, 3rd ed. Pearson, 2010.

  19. J. Schmidhuber, Deep learning in neural networks: An overview,

    Neural Networks, vol. 61, pp. 85117, 201.

  20. R. K. Jain, P. Kumar, and S. Verma, AI-based agricultural advisory systems for sustainable farming, IEEE Access, vol. 10, pp. 112345112359, 2022. IEEE.