Agricultural Crop Management System
Agricultural Crop Management System
Agricultural Crop Management System
SYSTEM
BACHELOR OF TECHNOLOGY
In
Computer Science & Engineering
by
SURAJ YADAV
Roll No. 2101870109011
AMITA JAISWAL
Roll No. 2101870109001
RAJEEV PRAJAPTI
Roll No. 2001870100090
To the
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
MAY, 2024
CERTIFICATE
This is to certify that the project report entitles
is a bonafide student of this institute and the work has been carried out by him/her under
the supervision of Mrs. Preeti Singh and it is approved for the partial fulfillment of the
requirement of Dr. Abdul Kalam Technical University for the award of the degree of
Bachelor of Engineering (Computer Engineering).
Place: Raebareli
Date:
DECLARATION
Signature:
Name:
Signature:
Name:
Signature:
Name:
Agriculture is a major source of income and employment in India. The most prevalent
problem faced by Indian farmers is that they do not select the appropriate crop for their
land and do not use the appropriate fertilizer. They will experience a significant drop in
production as a result of this. Precision agriculture has been used to solve the farmers'
difficulty. Precision agriculture is a modern farming strategy that employs research data on
soil properties, soil types, and crop yield statistics to recommend the best crop to farmers
as well as fertilizer recommendations based on site-specific features. This decreases the
number of times a crop is chosen incorrectly and increases productivity. In this paper, this
problem is solved by proposing a recommendation system through ML models with
majority voting technique using Random Forest, Naive Bayes, Support Vector Machine
(SVM), Logistic Regression and Random Forest, as learners to recommend a crop for the
site-specific parameters with high accuracy and efficiency. In Addition to that we are
performing real time testing using IOT system. The fertilizer recommendation system is
purely python logic based. In this we compare the data (optimum nutrients for growing the
crop) with the user’s entered data. Then nutrient having maximum difference is made as
HIGH or LOW and according to that suggestions will be fetched.
It gives us a great sense of pleasure to present the report of the B.Tech Project undertaken
during B.Tech. Final Year. We owe special debt of gratitude to our project guide
Dr./Mr./Mrs./Ms. Preeti Singh, Department of Computer Science & Engineering, Feroze
Gandhi Institute of Engineering & Technology, Raebareli for his/her constant support and
guidance throughout the course of our work. His/her sincerity, thoroughness and
perseverance have been a constant source of inspiration for us. It is only his cognizant
efforts that our endeavors have seen light of the day.
We also take the opportunity to acknowledge the contribution of Dr. Shruti Tripathi,
Head, Department Computer Science & Engineering, Feroze Gandhi Institute of
Engineering & Technology, Raebareli for her full support and assistance during the
development of the project.
We also do not like to miss the opportunity to acknowledge the contribution of all faculty
members of the department for their kind assistance and cooperation during the
development of our project. Last but not the least, we acknowledge our friends for their
contribution in the completion of the project.
Date:
Place:
(Signature of Student)
Declaration
Abstract
Acknowledgment 1
Table of Contents 2
List of Figures 4
1. Introduction 5
1.1Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . ………. 5
1.2 Existing System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Proposed System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Plan of Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 Problem Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.6 Objective of the Project . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2. Literature Survey 9
3. Theoretical Background 11
3.1 Overview on Machine Learning . . . . . . . . . . . . . . . . . . . . . 11
3.2 Machine Learning Tools . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Scikit-learn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5 Data Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5. System Analysis 21
5.1 Feasibility Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.2 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6. System Design 23
6.1 Analysis Model/Model Phases . . . . . . . . . . . . . . . . . . 23
6.2 Advantages of Waterfall Model . . . . . . . . . . . . . . . . . . . . 24
6.3 System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.4 Sequence diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.5 Data flow diagrams ……………………………………… 26
6.6 UML diagrams…………………………………………… 28
7. Implementation 29
7.1 Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.2 Data Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.3 Machine Learning Models . . . . . . . . . . . . . . . . . . . . . . . . . 32
8. Testing 36
8.1 Testing Methodologies . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.2 Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.3 System Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.4 Quality Assurance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.5 Functional Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
9. Results 38
9.1 Algorithms and accuracies . . . . . . . . . . . . . . . . . . . . . . . 38
9.2 Result Screenshots ………………………………… 40
9.3 Advantages ………………………………………… 44
9.4 Limitations………………………………………… 44
10. Conclusion 45
11. References 46
1. INTRODUCTION
A farmer’s decision about which crop to grow is generally clouded by his intuition and
other irrelevant factors like making instant profits, lack of awareness about market
demand, overestimating a soil’s potential to support a particular crop, and so on. A very
misguided decision on the part of the farmer could place a significant strain on his family’s
financial condition. Perhaps this could be one of the many reasons contributing to the
countless suicide cases of farmers that we hear from media daily. In a country like India,
where agriculture and related sector contribute to approximately 20.4 per cent of its Gross
Value Added (GVA), such an erroneous judgment would have negative implications on not
just the farmer’s family, but the entire economy of a region. For this reason, we have
identified a farmer’s dilemma about which crop to grow during a particular season, as a
very grave one.
The need of the hour is to design a system that could provide predictive insights to the
Indian farmers, thereby helping them make an informed decision about which crop to
grow. With this in mind, we propose a system, an intelligent system that would consider
environmental parameters (temperature, rainfall, geographical location in terms of state)
and soil characteristics (N, P, K, pH value, soil type and nutrients concentration) before
recommending the most suitable crop to the user. In addition to that a fertilizer suggestion
is also made which is based on the optimum nutrients of the crops grown.
1.1 Motivation
Agriculture is that the backbone for developing countries like India as quite 70% of
population depends on agriculture. Agriculture in India plays a predominant role in
economy and employment. The common problem existing among the Indian farmers are
they do not choose the proper crop supported their soil requirements and which fertilizer to
be used for his or her crop. thanks to this they face a heavy setback in productivity. This
problem of the farmers has been addressed through precision agriculture.
More and more researchers have begun to spot this problem in Indian agriculture and are
increasingly dedicating their time and efforts to assist alleviate the difficulty. Different
works include the employment of Regularized Greedy Forest to see an appropriate crop
sequence at a given time stamp. Another approach proposes a model that creates use of
historical records of meteorological data as training set. Model is trained to spot climate
that are deterrent for the assembly of apples. It then efficiently predicts the yield of apples
on the idea of monthly weather patterns. The use of several algorithms like Artificial
Neural Network, K Nearest Neighbours, and Regularized Greedy Forest is demonstrated in
[5] to pick out a crop supported the pre-diction yield rate, which, in turn, is influenced by
multiple parameters. Additional features included within the system are pesticide
prediction and online trading supported agricultural commodities.
One shortcoming that we identified all told these notable published works was that the
authors of every paper focused on one parameter (either weather or soil) for predicting the
suitability of crop growth. However, in our opinion, both these factors should be taken
together into consideration concomitantly for the most effective and most accurate
prediction.
This is often because, a specific soil type could also be it for supporting one variety of
crop, but if the climatic conditions of the region don't seem to be suitable for that crop
type, then the yield will suffer.
Datasets include:-
Yield dataset, Fertilizer dataset, Soil nutrient content dataset, Rainfall, Temperature dataset
d). Model Evaluation and Saving Model: All the ML models which are trained would be
evaluated by comparing their performance (Evaluations Metrics) and Final efficient model
is saved using pickle library.
In India, agriculture is one of the most important professions. Many of the people do
agriculture but are unable to determine which types of crops are more suitable to their soil.
Means there are variety of crops which are only suitable for wet soil, some requires
medium humidity in the soil to grow but this knowledge is less known to farmers as well
as newbies who develop some interest in farming. As of now there are very less resources
as well as software’s which will help them to improve quality. Such type of software is
Precision agriculture using machine learning and IoT.
2. LITERATURE SURVEY
Low-cost IOT + ML design for smart farming with multiple application paper authors Fahad
Kamraan Syed, Agniswar Paul, Ajay Kumar, Jaideep Cherukuri in paper [1] proposed system for
water management systems and improve current irrigation methods. An IoT and MLbased farming
system always keeps farmers aware of the upcoming weather possibilities and gives them the best
suggestions about irrigation methods and crops thereby helping in better
yield.
In paper [2] author’s proposed a smart system that can assist farmers in crop management by
considering sensed parameters (temperature, humidity) and other parameters (soil type,
location of farm, rainfall) that predicts the most suitable crop to grow in that environment.
Reference Paper [3] determines real time sampling of soil properties using MODIFIED
SUPPORT VECTOR REGRESSION, a popular machine learning algorithm and four
modules. The Modules include Sensor interfaced to IoT device, Agri cloud, Analyzing the
real time sensor data and Agri user interface (AUI). The first module is portable IoT device
(NodeMCU) with soil moisture sensor and pH sensor, environmental sensors. Agri cloud
module consists of storage. Analysing the real time data module is processing of types of
crops and small plants suggested using modified support vector machine algorithm. Agri-user
interface is a basic web interface. Thus, with the help of soil properties farmer will be able to get
types of crops and small plants is grown in farmland with help of Modified support vector machine
algorithm.
In paper [4] author’s proposed new technologies include the use of Internet of Things (IOT) and
Machine Learning. The real time data from the field area can be collected using IOT system. The
collected data from the field area is fed to the trained model. The trained model then makes the
predictions using the data. The result produced by the model greatly helps is sowing the suitable
crops in the particular field area.
In Reference paper [5] determines a model is proposed for predicting the soil type and
suggest a suitable crop that can be cultivated in that soil. The model has been tested using
various machine learning algorithms such as KNN, SVM and logistic regression. The
accuracy of the present model is maximum than the existing models.
Aruul Mozhi Varman S proposed an IOT and deep learning based smart agriculture systems. This
system monitors and collects the soil parameters from the field with the help of a wireless sensor
network. The collected data is then uploaded in the cloud. Finally, the
systems suggest best irrigation practices to the farmers by predicting the crop to be sown for next
crop rotation. This information will be sent as an SMS to the farmers. The parameters include soil
temperature, atmospheric temperature, and humidity [6]. This system suggests further improving
the effectiveness by predicting the suitable time for applying pesticides, fertilizer, and manures.
In paper [7] proposed a system would assist the farmers in making an informed decision
about which crop to grow depending on a variety of environmental and geographical factors. The
ML and IoT based suggestions will significantly educate the farmer and help them minimize costs
and make strategic decisions by replacing intuition and passed-down
knowledge with far more reliable data-driven ML models. This allows for a scalable, reliable
solution to an important problem affecting hundreds of millions of people
CHAPTER 3
Theoretical Background
Traditional programming works on the premise that, as long as we can define what a
program needs to do, we are confident we can define how a program can achieve that
goal. This is not always the case as sometimes, however, there are problems that you can
represent in a computer that you cannot write a traditional program to solve.
Such problems resist a procedural and logical solution. They have properties such as:
problems automatically, faster and more accurately than a manually specified solution, and at
a larger scale. Over the past few decades, many machine learning algorithms have been
developed by researchers, and new ones continue to emerge and old ones modified.
Using programming languages to develop and implement models is more flexible and
gave us better control of the parameters to the algorithms. It also allows us to have a
better understanding of the output models produced. Some of the popular programming
languages used in the field of machine learning are:
Python: Python is an extremely popular choice in the field of machine learning and AI
development. Its short and simple syntax make it extremely easy to learn
3.3 SciKit-learn
SciKit learn is an open source machine learning library built for python. Since its release in
2007, Scikit-learn has become one of the most popular open source machine learning
libraries. Scikit-learn (also called sklearn) provides algorithms for many machine learning
tasks including classification, regression, dimensionality reduction and clustering. The
documentation for scikit-learn is comprehensive, popular and well maintained. Sklearn is
built on mature Python Libraries such as NumPy, SciPy, and matplotlib. While languages
such as R and MATLAB are extremely popular and useful for machine learning, we decided
to choose Python along with its SciKit-learn libraries as our programming language of
choice.
The reasons for this are:
We already have some familiarity and exposure to Python, and thus have a smaller
learning curve.
Both Python and Scikit-learn have excellent documentation and tutorials available
online
The number of classic machine learning algorithms that come with Scikit-learn, and
the consistent patterns for using the different models i.e., each model can be used with
the same basic commands for setting up the data, training the model and using the
model for prediction. This makes it easier to try a range of machine learning
algorithms on the same data.
The machine learning algorithms included with sklearn have modifiable parameters
known as hyper parameters that effect the performance of the model. These usually
have sensible default values, so that we can run them without needing a detailed
knowledge or understanding of their semantics.
3.4 Dataset
For the system, we are using various datasets all downloaded for government website and
kaggle.
Datasets include:-
Yield dataset
Fertilizer dataset
Soil nutrient content dataset
Rainfall Temperature dataset
4.1 Introduction
This Software Requirements Specification provides a complete description of all the
Functions and constraints of the “Precision agriculture using machine learning & IOT”. The
document, describes the issue related to the agriculture system and what actions are needed to
perform to grow which type of crop should be grown in your soil and your environment to
get better crop production.
The basic idea of this project comes from the farmers who don’t know which type of
crop will be better for their soil according to nutrition and other environment conditions. In
India, agriculture is one of the most important professions. Many of the people do agriculture
but are unable to determine which types of crops are more suitable to their soil. Means there
are variety of crops which are only suitable for wet soil, some requires medium humidity in
the soil to grow but this knowledge is less known to farmers as well as newbies who develop
some interest in farming.
Usability:
System should be interactive and easy to understand.
Maintainability:
System should be easy to maintain.
Robustness:
Single application failure will not affect the system. System should be fault tolerant.
System should reliable enough to sustain in any condition. It should give Perfect results.
System Analysis
5.2 Analysis
5.2.1 Performance Analysis
Most of the software we use is open source and free. The models whichwe use in this
software, learn only once ,i.e once they are trained theyneed not be again fed in for the
training phase. One can directly predictfor values, hence time-complexity is very less.
Therefore, this model istemporally sound.
CHAPTER 6
System Design
Requirement Analysis:
This phase is concerned about collection of requirement of the system. This process
involves generating document and requirement review.
System Design:
Keeping the requirements in mind the system specifications are translated in to a
software representation. In this phase the designer emphasizes on:- algorithm, data structure,
software architecture etc.
Coding:
In this phase programmer starts his coding in order to give a full sketch of product. In
other words system specifications are only converted in to machine.
Implementation:
The implementation phase involves the actual coding or programming of the software.
The output of this phase is typically the library, executable, user manuals and additional
software documentation.
Testing:
In this phase all programs (models) are integrated and tested to ensure that the
complete system meets the software requirements. The testing is concerned with verification
and validation
Maintenance:
The maintenance phase is the longest phase in which the software is updated to fulfill
the changing customer needs, adapt to accommodate changes in the external environment,
correct errors and oversights previously undetected in the testing phase, enhance the
efficiency of the software .
Fig-1 Waterfall Model
6.2. Advantages of Waterfall model
_ Clear project objective
_ Stable project requirements
_ Progress of system is measurable.
_ Logic of software development is clearly understood.
_ Better resource allocation.
A system architecture is a conceptual model using which we can define the structure and
behaviour of that system. It is a formal representation of a system. Depending on the context,
system architecture can be used to refer to either a model to describe the system or a method
used to build the system. Building a proper system architecture helps in analysis of the
project, especially in the early stages. Figure 6.3 depicts the system architecture and is
explained in the following section.
Training Researching
Models models
Predicted
output
Fig-5 DFD Level-1
CHAPTER 7
Implementation
Acquisition of Training Dataset: The accuracy of any machine learning algorithm depends on the
number of parameters and the correctness of the training dataset.
This can severely affect the accuracy of the result. Since ours is a relatively small dataset, we
will not be using this method. The dataset that we used had values that were in string format
so we had to transform and encode the into integer valued so as to pass as an input to the
neural network. First we converted the data into pandas categorical data and then generated
codes for crops and states respectively we than appended these and created separated
datasets.
import pandas as pd
# Reading the data
crop_data_path = '../Data-raw/cpdata.csv'
fertilizer_data_path = '../Data-raw/Fertilizer.csv'
crop = pd.read_csv(crop_data_path)
fert = pd.read_csv(fertilizer_data_path)
# Function for lowering the cases
defchange_case(i):
i = i.replace(" ", "")
i = i.lower()
return i
fert['Crop'] = fert['Crop'].apply(change_case)
crop['label'] = crop['label'].apply(change_case)
crop_names = crop['label'].unique()
print(crop_names)
crop_names_from_fert = fert['Crop'].unique()
print(crop_names_from_fert)
for i in crop_names_from_fert:
print(crop[crop['label'] == i])
extract_labels = []
for i in crop_names_from_fert:
if i in crop_names:
import pandas as pd
# Reading the data
crop_data_path = '../Data-raw/cpdata.csv'
fertilizer_data_path = '../Data-raw/Fertilizer.csv'
crop = pd.read_csv(crop_data_path)
fert = pd.read_csv(fertilizer_data_path)
# Function for lowering the cases
defchange_case(i):
i = i.replace(" ", "")
i = i.lower()
return i
fert['Crop'] = fert['Crop'].apply(change_case)
crop['label'] = crop['label'].apply(change_case)
crop_names = crop['label'].unique()
print(crop_names)
crop_names_from_fert = fert['Crop'].unique()
print(crop_names_from_fert)
for i in crop_names_from_fert:
print(crop[crop['label'] == i])
extract_labels = []
for i in crop_names_from_fert:
if i in crop_names:
extract_labels.append(i)
# using extract labesl on crop to get all the data related to those labels
new_crop = pd.DataFrame(columns = crop.columns)
new_fert = pd.DataFrame(columns = fert.columns)
for label in extract_labels:
new_crop = new_crop.append(crop[crop['label'] == label])
for label in extract_labels:
new_fert = new_fert.append(fert[fert['Crop'] == label].iloc[0])
print(new_crop)
print(new_fert)
new_crop.to_csv('../Data-raw/MergeFileCrop.csv')
new_fert.to_csv('../Data-raw/FertilizerData.csv')
To separate the two classes of data points, there are many possible hyperplanes that could be
chosen. Our objective is to find a plane that has the maximum margin, i.e the maximum
distance between data points of both classes. Maximizing the margin distance provides some
reinforcement so that future data points can be classified with more confidence.
Logistic Regression is a Machine Learning algorithm which is used for the classification
problems, it is a predictive analysis algorithm and based on the concept of probability.
Testing
8.1 Testing Methodologies
The program comprises of several algorithms which are tested individually for the accuracy.
we check for the correctness of the program as a whole and how it performs.
Usability Testing - Usability Testing mainly focuses on the users ease to use the
application, exibility in handling controls and ability of the system to meet its
objectives.
Load Testing - Load Testing is necessary to know that a software solution will perform
under real-life loads.
Regression Testing- - Regression Testing involves testing done to make sure none of
the changes made over the course of the development process have caused new bugs.
Recovery Testing - Recovery testing is done to demonstrate a software solution is
reliable, trustworthy and can successfully recoup from possible crashes.
Migration Testing - Migration testing is done to ensure that the software can be moved
from older system infrastructures to current system infrastructures without any issues.
Results
For the purposes of this project we have used four popular algorithms:
Decision Trees, Logistic regression, Support Vector Machine and Random Forest. All the
algorithms are based on supervised learning. Our overall system is divided
into two modules:
Crop recommender
Fertilizer Recommender/Suggestion
Fertilizer Recommender/Suggestion
The fertilizer recommendation system is purely python logic based. In this we compare the
data (optimum nutrients for growing the crop) with the user’s entered data. Then nutrient
having maximum difference is made as HIGH or LOW and according to that suggestions will
be fetched.
9.2 Results with Screenshots
Home Page
2. Yield Prediction
3. Rainfall Prediction
Crop Recommendation & Result Page
1. Crop Recommendation
2. Fertilizer Recommendation
9.3 Advantages
Improve farm management efficiency by adjusting field/crop treatments
Ensure profitability, sustainability and protection of the environment
To use new technologies to increase crop yields and profitability while lowering the
levels of traditional inputs needed to grow crops
Optimize efforts and resources, reduce consumption and waste, and boost land
productivity
It will reduce excessive chemical usage in crop production.
9.4 Limitations
Extremely demanding work particularly collecting and then analyzing the data.
Accuracy depends upon input dataset
Most of the farmer not aware of such program like precision agriculture using machine
learning farmer don’t know the technology
Complexity grows with data.
CHAPTER 10
Conclusion
All This system helps the farmer to choose the right crop by providing insights that ordinary
farmers don't keep track of thereby decreasing the chances of crop failure and increasing
productivity.
It also prevents them from incurring losses. The system can be extended to the web and can be
accessed by millions of farmers across the country. We could achieve an accuracy of 90 percent
from the Decision Trees, an accuracy of 70.6 percent from the Support Vector Machine, an
accuracy of 94.30 percent from the Logistic Regression and an accuracy of 99.09 percent from the
Random Forest model.
Further development is to integrate the crop recommendation system with another subsystem, yield
predictor that would also provide the farmer an estimate of production if he plants the
recommended crop.
.
References
[1] 2019, 10th International Conference on Computing, Communication and Networking
Technologies, “Low-cost IOT+ML design for smart farming with multiple applications”,
Fahad Kamraan Syed, Agniswar Paul, Ajay Kumar, Jaideep Cherukuri.
[2] 2019 IEEE “ Smart Management of Crop Cultivation using IoT and Machine Learning”
Archana Gupta, Dharmil Nagda, Pratiksha Nikhare, Atharva Sandbhor
[3] Radhika, Narendiran, “Kind of Crops and Small Plants Prediction using IoT with
Machine Learning,” International Journal of Computer & Mathematical Sciences, 2018.
[5] “Classification of Soil and Crop Suggestion using Machine Learning Techniques”, A.
Mythili , IEEE 2019.
[6] Mehta, P., Shah, H., Kori, V., Vikani, V., Shukla, S., & Shenoy, M.,2018. “Survey of
unsupervised machine learning algorithms on precision agricultural data”, IEEE
[7] “IOT based Crop Recommendation, Crop Disease Prediction and Its Solution” Rani
Holambe, Pooja Patil, Padmaja Pawar, Saurabh Salunkhe , Mr. Hrushikesh Joshi, 2019
IRJET
[8] Tom M. Mitchell, Machine Learning, India Edition 2013, McGrawHill Education.
[9] https://data.gov.in/