I. INTRODUCTION
The agricultural industry significantly contributes to the overall economic advancement, especially in India, which contributes about of GDP and ranks second in the world in agricultural production. Fertilizers play an vital role in maintaining plant growth by supplementing essential nutrients absorbed by plants from the topsoil. Inadequate use of fertilizers can significantly damage crop yields. However, precise fertilization is important, taking into account factors such as rainfall and the specific nutritional needs of the crop.
To solve this issue, machine learning technology provides a potential solution by leveraging data related to crop fertility and rainfall. Providing farmers with comprehensive insights into their crops can lead to substantial benefits. The proposed model utilizes a machine learning algorithm, specifically the random forest regression algorithm with k-fold cross-validation technique. It requires two key inputs from users: the crop type and the location of cultivation.
Once the algorithm is applied, the model generates predictions regarding the optimal quantity of nutrients required for the selected crop, as well as the ideal timing for fertilizer application. To make this resource accessible to a wide range of users, a website has been developed using the Flask Python web framework. This web-based platform ensures compatibility across various devices and allows for easy sharing among farmers and stakeholders, facilitating informed decisions and improved agricultural practices.
II. RELATED WORKS
A thorough examination of available literature reveals a collection of prior studies aimed at addressing the issue of fertilizer usage. For instance, predicting fertilizer usage can help farmers achieve proper yields while minimizing waste by reducing plant toxicity and deficiency to some extent (Krutika Hampannavar et.al., [1]) Fuzzy logic systems that can reduce fertilizer usage, resulting in increased crop productivity (G. Prabakaran et.al., [2].) The study conducted to evaluate fertilizer consumption in Agro Climatic Zones (ACZ) through comprehensive data collection, which included daily field measurements and laboratory analysis spanning a three-year period. The primary objective was to precisely determine the specific fertilizer requirements for individual parcels of land within these zones.
The enhanced fertilizer efficiency alone is insufficient in preventing issues caused by soil compaction (A. Hussein et.al.[10]). The study delved into the agronomic performance and economic viability of cultivating grain sorghum under two different soil conditions: compacted soils, which simulate non-CTF (Controlled Traffic Farming) systems, and non-compacted soils, representing CTF systems.
To establish a quantifiable relationship between N and P for fertilizer usage in terms of agricultural yield, nitrogen need, and nitrate remnant level, (Zujiao Shi et.al. [11]). This is further supported by Yulong Yin et.al. [4], which provides a comprehensive measure for estimating nutrient requirements and the role of soil chemical properties.
Due to the stochastic nature of rainfall patterns and temperature variation, determining crop yield is a challenging task. Various data mining techniques, (Shital Bhojani [3]), can be applied to predict crop yield.
The intensification of rainfall may cause enhance the leaching of nitrogen into groundwater (Laura J.T. Hess et al. [5]), which can have impacts on both the economy and the environment. Implementing no-till management techniques could act as a safeguard by reducing the effects of this intensification, on loss.
A novel metric for soil quality and health (Tony Yang et. al. [7]), which includes soil refinement. Also suggested the creation of policies and strategies that has the potential to guarantee the preservation of fertile soils – a vital aspect for fostering sustainable growth, in ecosystems and promoting the overall welfare of agricultural systems and human society.
The changes in the creation and elements of soil populaces and capabilities resulting from the interaction between long-term treatment and precipitation variations (János Kátai [8]), to determine if preparation history affects soil microorganisms' water-obstruction. The study says the impacts of NPK (nitrogen, phosphorus and potassium) fertilization and variations, in rainfall, affect maize monoculture. The objective is to comprehend how the previously used fertilizers might affect the soil microbes to withstand water stress.
Predicting agricultural yield as a function of rainfall by providing a general summary of how production will be affected by rainfall and how much a given crop can yield (Benny Antony [13]). The suggested method of evaluation, which examines all regression procedures, is superior to other existing methods of evaluation.
A unique method to predict the yield of various crops grown in India (Potnuru Sai Nishant et.al [6]). With the use of simple criteria such as the state, district, and area, the user can forecast crop yields accurately for any year.
A proposed transfer learning approach to create a pre-trained model that can detect patterns in the dataset (Janmejay Pant et.al. [12]). This model is then utilized to predict crop yields with great accuracy.
The use of supervised algorithms, (Akash Manish Lad et.al. [14]) has proven to be an effective way of boosting crop yields while minimizing the human labor, time, and energy spent on various agricultural tasks. Moreover, this technique also offers plant suggestions based on specific soil parameters, which helps in predicting crop sustainability.
Machine learning models have demonstrated significant potential in interpreting and evaluating results related to the long-term usage of fertilizers. These models offer several advantages in the context of optimizing fertilizer application and assessing its impact over time (Saheed Garnaik et.al. [16]).
Development of a decision-based system that uses climatic, crop, and insecticide/pesticide data to predict crop yields (Rubby Aworka et. al. [17]). This method is incredibly useful in creating a comprehensive understanding of crop sustainability and offers valuable insights that can be employed in other long-term experiments.
An integrated solution to Pre-Cultivation activities, which aims to assist small farms in achieving high production at a low cost (Senthil Kumar Swami
Durai et.al.[18]). This study also helps in estimating the total growth expenses and aids in planning for the future. The Pre-Cultivation activities suggested in this paper offer an integrated solution that can significantly improve the efficiency of agriculture.
An innovative solution to soil nutrient classification problems using a rapid learning classification technique called Extreme Learning Machine (ELM) with various activation functions (M.S. Suchitra and Maya L. Pai [19]). This method provides an efficient way of classifying soil nutrients, which is crucial for achieving high crop yields. By utilizing this technique, farmers can develop a comprehensive understanding of the nutrient levels in their soil, which allows them to take necessary measures to improve soil fertility and crop production.
Crop illnesses have a significant impact on the total crop output, according to study. In the Kashmir Valley, a study [15] was conducted using an IoT system to propose an apple disease prediction model using data analysis and machine learning. This article examines the challenges of combining modern technology with traditional agricultural methods.
III. THE PROPOSED MODEL
In the study, a model to predict the crop nutrient requirements has been created using the RF method. The model is implemented as the RF regression with k-fold cross-validation, demonstrating satisfactory accuracy in predicting nutrient requirements. The fundamental approach in this research involves user input, including factors such as place of the crop and type of crop, as essential components of the system.
- The Weather API receives the location and provides specific weather attributes in response. And also receives information such as temperature, humidity and rainfall.
- The user will receive warning message when there's a potential heavy rainfall.
- The best possible time to fertilize using fetched weather data will be predicted.
- The NPK module estimate the required ratio of NPK (Nitrogen, Phosphorus and Potassium) content displayed on the website

Random Forest Algorithm
This research involves the use of a random forest (RF), which consists of decision trees trained using different data subsets and different hyperparameters. The input to the RF model is crop type and location, which will allow us to anticipate the values of N, P, K. The data set is split into training data sets and testing data sets, which Training data is and the remaining for testing. Three random forests with 50 decision trees each for N, P, K and produce a class average as a prediction for all trees.
Input Features
- Crop
- Location: State, City
- Weather Details: From weather API
Output Features
- Label N: Amount of Nitrogen
- Label P: Amount of Phosphorous
- Label K: Amount of Potassium
Data Preparation
The Crop Recommendation Dataset, which is last accessed on November 16th, 2022, has many features which includes features such as N, P, K, temperature, humidity, ph, rainfall and many more. However, not all of these features are relevant for the model being proposed. To address this, the technique of feature selection is used to reduce the dimensionality of the dataset, resulting in seven features that were then evaluated.

Algorithm: The RF Algorithm
Begin:
Step 1: The initial dataset, consisting of 2,200 entries. The dataset is divided into two subsets: a training dataset comprising of the data, equivalent to 1,760 entries, and a test dataset containing the remaining , totaling 240 entries.
Step 2: Utilizing random forest regression, the N, P, and K values undergo analysis with the assistance of 50 decision trees.
Step 3: Within the training dataset, the N Label, P Label, and K Label are trained based on the dependent variable. Specifically, the variable is designated as N for N Label, P for P Label, and K for K Label.
Step 4: For each labels of N, P, K generates 50 decision trees as output during the training process using the training dataset.
End
IV. RESULTS
Eco Fertilizer, has been developed as a website that recommends the appropriate timing and quantity of nutrients required for a selected crop. It is also introduced with a warning system that predicts heavy rainfall.

Fill out the Details
Select Crop
Select State


Fill out the Details rice
Karnataka
Gangavathi
SUBMIT

Fill out the Details race
Karnataka
Gangavathi
SUBMIT


V. CONCLUSION
The purpose of this study is to determine the quantity of nutrients and fertilizer required for effective growth and yield taking into account climatic conditions. Provides weather alerts and notifications. If bad weather, a warning displayed as output.