0% found this document useful (0 votes)
107 views44 pages

Corrected Main

This document discusses the development of an intelligent crop recommendation system using machine learning algorithms. It begins with an introduction to the importance of agriculture in India and some of the existing challenges. It then reviews several existing approaches that use factors like weather and soil data to predict crop suitability and yield. However, these approaches only consider single parameters rather than combining weather and soil data. The proposed system aims to address this by using multiple parameters to provide crop recommendations. It outlines plans to collect training data, preprocess the data, train models like neural networks and linear regression, and use these to predict the best crops along with fertilizer requirements. The overall goal is to help maximize farmers' profits by recommending the right crops

Uploaded by

Vikram
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)
107 views44 pages

Corrected Main

This document discusses the development of an intelligent crop recommendation system using machine learning algorithms. It begins with an introduction to the importance of agriculture in India and some of the existing challenges. It then reviews several existing approaches that use factors like weather and soil data to predict crop suitability and yield. However, these approaches only consider single parameters rather than combining weather and soil data. The proposed system aims to address this by using multiple parameters to provide crop recommendations. It outlines plans to collect training data, preprocess the data, train models like neural networks and linear regression, and use these to predict the best crops along with fertilizer requirements. The overall goal is to help maximize farmers' profits by recommending the right crops

Uploaded by

Vikram
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
You are on page 1/ 44

CHAPTER 1

PREAMBLE
1.1 INTRODUCTION
As we know since the humans have started practicing or doing agriculture activities
“Agriculture” has become the most important activity for humans. In today’s era or world
agriculture is not only for surviving it’s also play huge part or role in economy of any
country. Agriculture plays vital role in India’s economy and in human future too. In India it
also provides large portion of employment for Indians. As a result, with passage of time the
need for production has been accumulated exponentially. thus, on manufacture in mass
amount individuals are exploitation technology in associate degree extremely wrong method.

With the improvement of the technologies day by day there is creation of hybrid
varieties day by day. In comparison with naturally created crop these hybrid varieties don’t
offer or provide essential contents. Depending more on unnatural techniques may lead to soil
acidification and crust. These types of activities all lead up to environmental pollution. These
types of activities (unnatural activities) are for avoiding or reducing losses. However, once
the farmer or producer get or grasp the correct data on the crop yield, it will help the farmer
in avoiding or reducing the loss.

Around the globe India is the second largest country in terms of population. Many
people are dependent on agriculture, but the sector lacks efficiency and technology especially
in our country. By bridging the gap between traditional agriculture and data science, effective
crop cultivation can be achieved. It is important to have a good production of crops. The crop
yield is directly influenced by the factors such as soil type, composition of soil, seed quality,
lack of technical facilities etc.

Agriculture sector act as backbone of India by providing food security and playing
major role in Indian economy. Due to drastically changes in climatic condition it is affecting
farmers due to poor yield, which also affect them economically. Due to it prediction of crop
is getting difficult for farmers. This project will help the upcoming farmers by giving the
farmer ease in predicting the crop to sow for maximum profit.

In India agriculture plays important role in economic sector and also plays the most
important role in global development. A lot more than 60% of the country's land is used for
agriculture to meet the needs of 1.3 billion people. So, adopting new technologies for
agriculture plays important role. This is going to lead our country's farmers to make a profit.
Crop prediction and fertilizer prediction in most part of part India is done on by the farmers
experience. Most farmers will prefer previous or neighboring crops or most prone to the
surrounding region only because of their land and do not have sufficient information about
the content of soil like phosphorus, potassium, nitrogen.
1
1.2 EXISTING SYSTEM
More and more researchers have begun to identify this problem in Indian agriculture
and are increasingly dedicating their time and efforts to help alleviate the issue. Different
works include the use of Regularized Greedy Forest to determine an appropriate crop
sequence at a given time stamp. Another approach proposes a model that makes use of
historical records of meteorological data as training set. Model is trained to identify weather
conditions that are deterrent for the production of apples. It then efficiently predicts the yield
of apples on the basis of monthly weather patterns. The use of several algorithms like
Artificial Neural Network, K Nearest Neighbors, and Regularized Greedy Forest is
demonstrated in [5] to select a crop based on the prediction yield rate, which, in turn, is
influenced by multiple parameters. Additional features included in the system are pesticide
prediction and online trading based on agricultural commodities.

1.2.1 DRAWBACKS
One shortcoming that we identified in all these notable published works was that the
authors of each paper concentrated on a single 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 best and most accurate prediction.
This is because, a particular soil type may be fit for supporting one type of crop, but if the
weather conditions of the region are not suitable for that crop type, then the yield will suffer.

1.3 PROPOSED SYSTEM


We to eliminate the aforementioned drawbacks, we propose an Intelligent Crop
Recommendation system- which takes into consideration all the appropriate parameters,
including temperature, rainfall, location and soil condition, to predict crop suitability. This
system is fundamentally concerned with performing the primary function of AgroConsultant,
which is, providing crop recommendations to farmers algorithms. We also provide the profit
analysis on crops grown in different states which gives the user an easy and reliable insight to
decide and plan the crops.

2
1.4 PLAN OF IMPLEMENTATION
The steps involved in this system implementation are:

a) Acquisition of Training Dataset: The accuracy of any machine learning algorithm


depends on the number of parameters and the correctness of the training dataset. For
the system, we are using various datasets all downloaded for government website and
kaggle. Datasets include: Cost of cultivation per ha dataset for major crops in each
state.
 Crop dataset
 Modal price of crops
 Fertilizers of crops
 Soil nutrient content dataset
 Rainfall Temperature dataset

b) Data Preprocessing: This step includes replacing the null and 0 values for yield by -1
so that it does not effect the overall prediction. Further we had to encode the data-set so
that it could be fed into the neural network.

c) Training model and crop recommendation: After the preprocessing step we used the
data-set to train different machine learning models like neural network and linear
regression to attain accuracy as high as possible.

1.5 PROBLEM STATEMENT


Most of the Indians have farming as their occupation. Farmers plant the same crop over
and over again without trying new varieties and randomly fertilize without knowing the
amount and content that is missing. Therefore, it directly affects crop yield and acidifies the
soil result in reducing soil fertility.

We are designing the system using machine learning to help farmers in crop and
fertilizer prediction. Right crop will be recommended for a specific soil and also keeping in
mind of climatic boundaries. Also, the system provides information about the required
content and the needed amount of fertilizer, the seeds needed for planting.

With the help of our system farmers can try to grow or cultivate different varieties with
right technique, which will help farmers in maximizing their profit.

3
CHAPTER 2
LITRATURE SURVEY

1) Crop Selection Method to Maximize Crop Yield Rate using Machine Learning
Technique Authors: Rakesh Kumar, M.P. Singh, Prabhat Kumar and J.P. Singh

This paper proposed a method named Crop Selection Method (CSM) to solve crop
selection problem, and maximize net yield rate of crop over season and subsequently
achieves maximum economic growth of the country. The proposed method may improve net
yield rate of crops.

2) AgroConsultant: Intelligent Crop Recommendation System Using Machine Learning


Algorithms Authors: Zeel Doshi, Subhash Nadkarni, Rashi Agrawal, Prof. Neepa Shah

This paper, proposed and implemented an intelligent crop recommendation system,


which can be easily used by farmers all over India. This system would assist the farmers in
making an informed decision about which crop to grow depending on a variety of
environmental and geographical factors. We have also implemented a secondary system,
called Rainfall Predictor, which predicts the rainfall of the next 12 months.

3) Development of Yield Prediction System Based on Real-time Agricultural


meteorological Information Haedong Lee *, Aekyung Moon* * ETRI, 218 Gajeong-ro,
Yuseong-gu, 305-700, Korea

This paper contains about the research and the building of an effective agricultural
yield forecasting system based on real-time monthly weather. It is difficult to predict the
agricultural crop production because of the abnormal weather that happens every year and
rapid regional climate change due to global warming. The development of agricultural yield
forecasting system that leverages real-time weather information is urgently required. In this
research, we cover how to process the number of weather data (monthly, daily) and how to
configure the prediction system. We establish a non-parametric statistical model on the basis
of 33 years of agricultural weather information. According to the implemented model, we
predict final production using the monthly weather information. This paper contains the
results of the simulation.

4
4) Analysis of Soil Behaviour and Prediction of Crop Yield using Data Mining
Approach Monali Paul, Santosh K. Vishwakarma, Ashok Verma Computer science and
Engineering GGITS, Jabalpur
This work presents a system, which uses data mining techniques in order to predict the
category of the analyzed soil datasets. The category, thus predicted will indicate the yielding
of crops. The problem of predicting the crop yield is formalized as a classification rule, where
Naive Bayes and K-Nearest Neighbor methods are used.

5) Crop Recommendation System for Precision Agriculture S.Pudumalar*,


E.Ramanujam*, R.Harine Rajashree, C.Kavya, T.Kiruthika, J.Nisha.

This paper, proposes a recommendation system through an ensemble model with


majority voting technique using Random tree, CHAID, K-Nearest Neighbor and Naive Bayes
as learners to recommend a crop for the site specific parameters with high accuracy and
efficiency.

5
CHAPTER 3
THEORETICAL BACKGROUND
3.1 OVERVIEW ON MACHINE LEARNING
Machine learning is an application of artificial intelligence (AI) that gives systems the
ability to automatically learn and evolve from experience without being specially
programmed by the programmer. The process of learning begins with observations or data,
such as examples, direct experience, or instruction, in order to look for patterns in data and
make better decisions in the future based on the examples that we provide. The main aim of
machine learning is to allow computers to learn automatically and adjust their actions to
improve the accuracy and usefulness of the program, without any human intervention or
assistance. Traditional writing of programs for a computer can be defined as automating the
procedures to be performed on input data in order to create output artifacts. Almost always,
they are linear, procedural and logical. A traditional program is written in a programming
language to some specification, and it has properties like:

• We know or can control the inputs to the program.


• We can specify how the program will achieve its goal.
• We can map out what decisions the program will make and under what conditions it makes
them.
• Since we know the inputs as well as the expected outputs, we can be con dent that the
program will achieve its goal

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:

• The scope of all possible inputs is not known beforehand.

• You cannot specify how to achieve the goal of the program, only what that goal is.

• You cannot map out all the decisions the program will need to make to achieve its goal.

• You can collect only sample input data but not all possible input data for the program.

6
3.1.1 SUPERVISED LEARNING
Supervised learning takes a set of feature/label pairs, called the training set. From this
training set the system creates a generalized model of the relationship between the set of
descriptive features and the target features in the form of a program that contains a set of
rules. The objective is to use the output program produced to predict the label for a
previously unseen, unlabelled input set of features, i.e. to predict the outcome for some new
data. Data with known labels, which have not been included in the training set, are classified
by the generated model and the results are compared to the known labels. This dataset is
called the test set. The accuracy of the predictive model can then be calculated as the
proportion of the correct predictions the model labeled out of the total number of instances in
the test set.

3.1.2 UNSUPERVISED LEARNING


Unsupervised learning takes a dataset of descriptive features without labels as a
training set. In unsupervised learning, the algorithms are left to themselves to discover
interesting structures in the data. The goal now is to create a model that finds some hidden
structure in the dataset, such as natural clusters or associations. Unsupervised learning studies
how systems can infer a function to describe a hidden structure from unlabeled data. The
system does not figure out the right output, but it explores the data and can draw inferences
from datasets to describe hidden structures from unbalanced data. Unsupervised learning can
be used for clustering, which is used to discover any inherent groupings that are already
present in the data. It can also be used for association problems, by creating rules based on
the data and finding relationships or associations between them.

3.2 MACHINE LEARNING TOOLS


There are many different software tools available to build machine learning models and
to apply these models to new, unseen data. There are also a large number of well defined
machine learning algorithms available. These tools typically contain libraries implementing
some of the most popular machine learning algorithms. They can be categorised as follows:

• Pre-built application-based solutions.

• Programming languages which have specialized libraries for machine learning

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:

7
• 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

• Tensorflow: TensorFlow is an end-to-end open source platform for machine learning. It has
a comprehensive, flexible ecosystem of tools, libraries, and community resources that let
researchers pushes the state-of-the-art in ML and developers easily build and deploy ML-
powered applications. TensorFlow was originally developed by researchers and engineers
working on the Google Brain team within Google’s Machine Intelligence Research
organization to conduct machine learning and deep neural networks research. The system is
general enough to be applicable in a wide variety of other domains, as well.

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 hyperparameters 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.

• The IPython notebook, which is an interactive computational environment for Python, in


which a user can combine code execution, rich text, mathematics and plots in a web page.
This functionality allows us to provide the notebooks we used to run our experiments almost
as an audit and in a presentable.
8
3.4 DATASET
For the system, we are using various datasets all downloaded for government website and
Kaggle. Datasets include: Cost of cultivation per ha dataset for major crops in each state

 Crop dataset
 Modal price of crops
 Standard price of crops
 Soil nutrient content dataset
 Rainfall Temperature dataset

A brief description of the datasets:


• Yield Dataset: This dataset contains yield for 16 major crops grown across all the states in
kg per hectare. Yield of 0 indicates that the crop is not cultivated in the respective state.
• Cost of Cultivation dataset: This dataset provides the cost of cultivation for each crop in Rs.
per hectare.
• Modal price of crops: This dataset gives the average market prices for those crops over a
period of two months
• Standard price of crops: This dataset gives the current market price of the crops in Rs per
hectare .
• Soil nutrient content dataset: This dataset has five columns with the attributes in the order-
State, Nitrogen content, Phosophorous content, Potassium content and average ph.
• Rainfall Temperature dataset: This dataset contains crops, max and min rainfall, max and
min temprature, max and min rainfall and ph values.
3.5 DATA PREPROCESSING
This step includes replacing the null and 0 values for yield by -1 so that it does not effect the
overall prediction. Further we had to encode the data-set so that it could be fed into the
neural network.

Train and Test


Data

Figure 3.5.1 Data Preprocessing


9
3.6 MACHINE LEARNING ALGORITHMS
Machine Learning algorithms used in the recommendation system are:

• Linear Regression: Linear regression is a linear approach to modeling the relationship


between a scalar response (or dependent variable) and one or more explanatory variables (or
independent variables). Linear regression is used for finding linear relationship between
target and one or more predictors. It fits a linear model with coefficients w = (w1, ..., wp) to
minimize the residual sum of squares between the observed targets in the dataset, and the
targets predicted by the linear approximation. Linear regression is used for finding linear
relationship between target and one or more predictors.

• Neural Network: Neural networks are a set of algorithms, modeled loosely after the human
brain, that are designed to recognize patterns. They interpret sensory data through a kind of
machine perception, labeling or clustering raw input. The patterns they recognize are
numerical, contained in vectors, into which all real-world data, be it images, sound, text or
time series, must be translated. Neural networks help us cluster and classify. Neural Networks
are themselves general function approximations, which is why they can be applied to almost
any machine learning problem about learning a complex mapping from the input to the output
space.

3.7 TOOLS AND LIBRARIES USED

Python:

Figure 3.7.1 Python

For carrying out this project in the best possible manner, we decided on using Python
Language, which comes with several pre-built libraries (such as pandas, NumPy, SciPy, and
etc.) and is loaded with numerous features for implementing data science and machine
learning techniques which allowed us to design the model in the most efficient manner
possible. For building this project we utilized numerous python libraries for executing
different operations.
10
● Python - Python is a robust programming language with a wide range of capabilities. Its
broad features make working with targeted programs (including meta-programming and
meta- objects) simple. Python takes advantage of power typing as well as the integration
of reference computation and waste management waste collecting. It also supports
advanced word processing (late binding), which binds the way the words change during
the process. Patches to fewer essential sections of C Python that can give a minor
improvement in performance at an obvious price are rejected by Python developers who
try to prevent premature execution. When speed is crucial, the Python program developer
can use mod- written modules in C-languages or PyPy, a timely compiler, to submit time-
sensitive jobs.

Cython is a Python interpreter that transforms Python scripts to C and uses the C-1evel API
to call the Python interpreter directly. Python's creators attempt to make the language as fun
to use as possible. Python's architecture supports Lisp culture in terms of functionality.
Filters, maps, and job reduction, as well as a list comprehension, dictionaries, sets, and
generator expressions, are all included.
Two modules (itertools and fun tools) in the standard library use realistic Haskell and
Standard ML tools.

Why use Python?

We're using Python because it works on a wide range of platforms. Python is a language with
no stages. Python is a as simple as English. Python have many libraries and has a simple
linguistic structure similar to English, whereas Java and C++ have complicated codes. Python
applications contain less line than programs written in other languages. That is why we
choose Python for artificial intelligence, artificial consciousness, and dealing with massive
volumes of data. Python is an article-oriented programming language. Classes, objects,
polymorphism, exemplification, legacy, and reflection are all concepts in Python .

Python has become a staple in data science, allowing data analysts and other professionals to
use the language to conduct complex statistical calculations, create data visualizations, build
machine learning algorithms, manipulate and analyze data, and complete other data-related
tasks.

11
HTML:

Figure 3.7.2 HTML

Introduction to html: it stands for hypertext markup language.

Used by developers to define structure of webpage. Every page on web we see is


written using html. Web browsers read and understand the markup text written in html. Html
instructs the web browser to display content. Content can be anything like text images etc.

The webpage can be divided into multiple small sections and each section has specific
information in it. So when you write an html document you are giving browser set of
instructions on how to display content on web page

Cascading Style Sheets:

Figure 3.7.3 CSS

As we know that html to define the structure of the web page with no styling. To style
the webpage like font, color, size and much more we use CSS or cascading style sheets. With
help of it we can any element of our web page. To define our web page browser reads html
and CSS together.

It is of three types:

 Inline
 Internal
 External

12
JavaScript:

Figure 3.7.4 JavaScript

JavaScript, commonly known as JS, is an open and cross platform interpreted programming
language.

It helps in creating frontend and backend applications using various frameworks. It not only
makes your website good looking but functional too.

Flask Web framework:

Figure 3.7.5 Flask web framework

It is a small framework in python. It has no basis for website summaries, form verification, or
any other categories where third-party libraries provide similar services. However, Flask
supports extensions that can add features to the app as if they were made in Flask itself. There
are object-related map extensions, form verification, download management, various open
authentication technologies and several tools related to the standard framework.

Flask gives the developer a variety of options when designing web applications, by giving
person with means that help them to create or build website but will not force you to rely on
or tell you what the project should look like.

13
NumPy library:

Figure 3.7.6 Numpy

NumPy is a Python program library, which adds support for large, multi-dimensional
collections and matrices, as well as a large collection of mathematical functions developed to
work in these components.

The use of NumPy in Python is basically the same as that of MATLAB as they both translate
and allow customers to create projects faster as long as multiple tasks are focused on clusters
or networks rather than scales. Along with these critical ones, there are several options:

Pandas’ library:

Figure 3.7.7 Pandas

It is a software library in python to decrypt and analyze data. It provides data structures and
functions to manage number tables and time series. Free software released under a three-
phase BSD license. The term is taken from the term "panel data", an econometrics term for
data sets that incorporates visibility into many identical people.

Adding or modifying data engines by a robust community that allows different applications
to be integrated into data sets. High output of a combination of data and a combination.
Hierarchical indexing provides an accurate way of dealing with large-scale data in a small
data structure.

14
Matplotlib:

Figure 3.7.7 Matplotlib

John Hunter and many others built a matplotlib Python library to create graphs, charts, and
high-quality statistics. The library can change very little information about mathematics, and
it is great. Some of the key concepts and activities in matplotlib are:

Picture:

Every image is called an image, and every image is an axis. Drawing can be considered as a
way to draw multiple episodes.

Structure:

Data is the first thing that a graph should be drawn. A keyword dictionary with keys and
values such as x and y values can be declared. Next, scatter (), bar (), and pie () can be used
to create a structure and a host of other functions.

Axis:

Adjustments are possible using the number and axes obtained using the sub-sections (). Uses
a set () function to adjust x-axis and y-axis features.

15
Scikit learn:

Figure 3.7.9 Scikit learn

The best Python Scikit-learn machine library. The sklearn library contains many practical
machine learning tools and mathematical modeling methods, including division, deceleration,
integration and size reduction. Machine learning models used by sklearn. Scikit-Learn
charges for tons of features and should not be used to read data or trick or summarize it.
Some of them are there to help you translate the spread.

Scikit-learn comes with many features. Some of them are here to help us explain the spread:

• Supervised learning algorithms: Consider any professional reading algorithms you may
have studied and may be part of science. Starting with the standard line models, SVM,
decision trees are all in the science toolbox. One of the main reasons for the high level of use
of scientists is the proliferation of machine learning algorithms. I started using scikit, and I
would recommend young people to learn the scikit / machine. I will solve supervised learning
problems.

• Unchecked learning algorithms: There are also a wide variety of machine learning
algorithms ranging from compilation, feature analysis, key component analysis to unchecked
neural networks.

• Contrary verification: a variety of methods are used by sky learn to ensure the accuracy
of the models followed with invisible details.

• Feature removal: Scientific learning to remove images and text elements.

• Datasets for different toys: This was useful when studying science. I have studied SAS
for different educational data sets. It helped them a lot to support when they read the new
library.

16
CHAPTER 4
SYSTEM REQUIREMENTS SPECIFICATION
A software requirements specification (SRS) is a description of a software system to be
developed. It lays out functional and non-functional requirements, and may include a set of
use cases that describe user interactions that the software must provide. In order to fully
understand one’s project, it is very important that they come up with a SRS listing out their
requirements, how are they going to meet it and how will they complete the project. It helps
the team to save upon their time as they are able to comprehend how are going to go about
the project. Doing this also enables the team to find out about the limitations and risks early
on. Requirement is a condition or capability to which the system must conform. Requirement
Management is a systematic approach towards eliciting, organizing and documenting the
requirements of the system clearly along with the applicable attributes. The elusive
difficulties of requirements are not always obvious and can come from any number of
sources.

4.1 FUNCTIONAL REQUIREMENT


Functional Requirement defines a function of a software system and how the system must
behave when presented with specific inputs or conditions. These may include calculations,
data manipulation and processing and other specific functionality. Following are the
functional requirements on the system:

1. All the data must be in the same format as a structured data.

2. The data collected will be vectorized and sent across to the classifier.

4.2 NON FUNCTIONAL REQUIREMENTS


Non functional requirements are the requirements which are not directly concerned with the
specific function delivered by the system. They specify the criteria that can be used to judge
the operation of a system rather than specific behaviors. They may relate to emergent system
properties such as reliability, response time and store occupancy. Non functional
requirements arise through the user needs, because of budget constraints, organizational
policies and the need for interoperability with other software and hardware systems.

17
4.2.1 SYSTEM CONFIGURATION

Hardware System Configuration:

• Processor: 2 gigahertz (GHz) or faster processor or SoC.

• RAM: 6 gigabyte (GB) for 32-bit or 8 GB for 64-bit.

• Hard disk space: =16GB.

Software Configuration:

• Operating System: Windows XP/7/8/8.1/10, Linux and Mac

• Coding Language: Python

• Tools:

1. Pandas

2. Numpy

3. Tensorflow

4. Keras

5. Sickitlearn

18
CHAPTER 5
SYSTEM ANALYSIS
5.1 FEASIBILITY STUDY
Analysis is the process of finding the best solution to the problem. System analysis is
the process by which we learn about the existing problems, define objects and requirements
and evaluates the solutions. It is the way of thinking about the organization and the problem it
involves, a set of technologies that helps in solving these problems. Feasibility study plays an
important role in system analysis which gives the target for design and development.

5.1.1 ECONOMICAL FEASIBILITY


This study is carried out to check the economic impact that the system will have on the
organization. Since the project is Machine learning based, the cost spent in executing this
project would not demand cost for software’s and related products, as most of the products
are open source and free to use. Hence the project would consumed minimal cost and is
economically feasible.

5.1.2 TECHNICAL FEASIBILITY


This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Since machine learning algorithms is based on pure math there is
very less requirement for any professional software. And also most of the tools are open
source. The best part is that we can run this software in any system without any software
requirements which makes them highly portable. Also most of the documentation and
tutorials make easy to learn the technology

5.1.3 SOCIAL FEASIBILITY


The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The main purpose of this
project which is based on crop prediction is to prevent the farmer from incurring losses and
improve productivity. This also ensures that there is no scarcity of food as lack of production
may lead to severe consequences. Thus, this is a noble cause for the sake of the society, a
small step taken to achieve a secure future.

19
5.2 ANALYSIS

5.2.1 PERFORMANCE ANALYSIS


Most of the software we use is open source and free. The models which we use in this
software, learn only once, i.e once they are trained they need not be again fed in for the
training phase. One can directly predict for values, hence time-complexity is very less.
Therefore this model is temporally sound.

5.2.2 TECHNICAL ANALYSIS


As mentioned earlier, the tool used in building this software is open source. Each tool
contains simple methods and the required methods are overridden to tackle the problem.

5.2.3 ECONOMICAL ANALYSIS


The completion of this project can be considered free of cost in its entirety. As the
software used in building the model is free of cost and all the data sets used are being
downloaded from kaggle and Govt. of India website.

20
CHAPTER 6
IMPLEMENTATION
6.1 DATA ANALYSIS
One of the first steps we perform during implementation is an analysis of the data. This
was done by us in an attempt to find the presence of any relationships between the various
attributes present in the dataset.

Acquisition of Training Dataset: The accuracy of any machine learning algorithm


depends on the number of parameters and the correctness of the training dataset. We In this
project analysed mutiple datasets collected from Government wesite -https://data.gov.in/ and
Kaggle and carefully selected the parameters that would give the best results. Many work
done in this field have considered environmental parameters to predict crop sutainability
some have used yield as major factor where as in some works only economic factors are
taken into consideration. We have tried to combine both environmental parameters like
rainfall, temperature, ph, nutrients in soil, soil type, location and economic parameters like
production, and yield to provide accurate and reliable recommendation to the farmer on
which crop will be most suitable for his land.

21
Figure 6.1.2 Crop dataset

Figure 6.1.2 Fertilizer dataset

6.2 DATA PREPROCESSING


After analysing and visualizing the data, the next step is preprocessing. Data
preprocessing is an important step as it helps in cleaning the data and making it suitable for
use in machine learning algorithms. Most of the focus in preprocessing is to remove any
outliers or erroneous data, as well as handling any missing values.

Missing data can be dealt with in two ways. The first method is to simply remove the entire
row which contains the missing or erroneous value. While this an easy to execute method, it
is better to use only on large datasets. Using this method on small datasets can reduce the
dataset size too much, especially if there are a lot of missing values. 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. The steps are illustrated
below.

22
6.3 MACHINE LEARNING MODELS
• LOGISTIC REGRESSION MODEL
Logistic regression is a supervised learning classification algorithm used to predict the
probability of a target variable. The nature of target or dependent variable is dichotomous,
which means there would be only two possible classes.

Figure 6.3.1 Logistic regression Graph

• SUPPORT VECTOR MACHINE (SVM) MODEL


Support Vector Machine is a relatively simple Supervised Machine Learning
Algorithm used for classification and/or regression. It is more preferred for classification but
is sometimes very useful for regression as well. Basically, SVM finds a hyper-plane that
creates a boundary between the types of data. In 2-dimensional space, this hyper-plane is
nothing but a line. In SVM, we plot each data item in the dataset in an N-dimensional space,
where N is the number of features/attributes in the data. Next, find the optimal hyperplane to
separate the data. So, by this, you must have understood that inherently, SVM can only
perform binary classification (i.e., choose between two classes).

Figure 6.3.2 SVM Graph

23
• RANDOM FOREST MODEL
Random Forest has the ability to analyze crop growth related to the current climatic
condition and biophysical change. Random forest algorithm creates decision trees on
different data samples and then predicts the data from each subset and then by voting gives
better solution for the system. Random Forest uses the bagging method to train the data
which increases the accuracy of the result.

• DECISION TREE MODEL


Decision tree is the most powerful and popular tool for classification and prediction. A
Decision tree is a flowchart like tree structure, where each internal node denotes a test on an
attribute, each branch represents an outcome of the test, and each leaf node (terminal node)
holds a class label.

• NAIVE BAYES MODEL


This algorithm thinks that the dataset features are all independent of each other. Larger
the dataset it works better. DAG (directed acyclic graph) is used for classification in this or
naïve bayes algorithm.

Figure 6.3.3 System Implementation

24
CHAPTER 7
RESULTS AND PERFORMANCE ANALYSIS
For the purposes of this project we have used three popular algorithms: Linear regression,
Logistic regression and Neural network. All the algorithms are based on supervised learning.
Our overall system is divided into three modules:

• Crop recommender

• Fertilizer recommender

• Crop disease predictor

RESULTS AND ACCURACY OF IMPLEMENT ALGORITHAM:


• Logistic regression

On applying it on dataset it gives accuracy of 95.22%.

Figure 7.1 Accuracy in logistic regression

25
• Naive Bayes

On applying it on dataset it gives accuracy of 99.09%.

Figure 7.2 Accuracy in gaussian naïve bayes

• Random Forest

On applying it on dataset it gives accuracy of 99.09%.

Figure 7.3 Accuracy in random forest

26
• Decision tree

On applying it on dataset it gives accuracy of 90%.

Figure 7.4 Accuracy in Decision tree

• SVM: (Support vector machine)

On applying it on dataset it gives accuracy of 97.95%.

Figure 7.5 Accuracy in support vector machine

27
• Accuracy Comparison of Algorithms

Figure7.6 Accuracy Comparison of Algorithms

28
CHAPTER 8
CONCLUSION
In this project we try to get best crop and fertilizer recommendation with the help of
machine learning. For the calculation of accuracy many machine learning techniques were
imposed or used. Numerous algorithms were used on datasets to get the best output which
leads to best crop and fertilizer recommendation for particular soil of particular region. This
system will help farmers to visualize crop yields based on that climatic and subsistence
boundaries. Using this farmer can decide whether to plant that crop or to look for another
crop if yield forecasts are incorrect. This tool can help the farmer to make the best decisions
when it comes to growing something harvest. It may also predict the negative effects of the
plant. Currently our farmers use outdated technology or not use effectively, so there can be an
opportunity of the wrong choice of cultivated crops that will reduce the profit by production.
To reduce these types of loss we try to create a farmer-friendly system, which will help in
predicting which crop is best for a specific soil and this project will give the recommendation
about the fertilizer needed by the soil for cultivation, seeds needed for cultivation,
expectations yield and market price. Thus, this enables farmers to make the right choice in
choosing a crop farming so that the agricultural sector can develop with new ideas.

8.1 FUTURE SCOPE


For the upcoming updates in this project we can use deep learning techniques for plant
diseases prediction with the help of images and we can also implement IOT techniques for
getting contents of soil directly from the fields.

Future Work on this can add many options such as:

 Diagnosis and prevention of plant diseases, predicting plant species.

 Current Market Conditions and analysis for information on crop market rates,
production costs, fertilizer.

 Government options for knowing new government programs related to borrowing,


fertilizer, and harvesting.

 The mobile app can be developed to assist farmers with uploading farm photos.

29
APPENDECIES
APPENDIX - I
SAMPLE CODING
# Importing essential libraries and modules

from flask import Flask, render_template, request, Markup

import numpy as np

import pandas as pd

from utils.disease import disease_dic

from utils.fertilizer import fertilizer_dic

import requests

import config

import pickle

import io

import torch

from torchvision import transforms

from PIL import Image

from utils.model import ResNet9

# LOADING THE TRAINED MODELS

# Loading plant disease classification model

disease_classes = ['Apple___Apple_scab',

'Apple___Black_rot',

'Apple___Cedar_apple_rust',

'Apple___healthy',

'Blueberry___healthy',
30
'Cherry_(including_sour)___Powdery_mildew',

'Cherry_(including_sour)___healthy',

'Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot',

'Corn_(maize)___Common_rust_',

'Corn_(maize)___Northern_Leaf_Blight',

'Corn_(maize)___healthy',

'Grape___Black_rot',

'Grape___Esca_(Black_Measles)',

'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',

'Grape___healthy',

'Orange___Haunglongbing_(Citrus_greening)',

'Peach___Bacterial_spot',

'Peach___healthy',

'Pepper,_bell___Bacterial_spot',

'Pepper,_bell___healthy',

'Potato___Early_blight',

'Potato___Late_blight',

'Potato___healthy',

'Raspberry___healthy',

'Soybean___healthy',

'Squash___Powdery_mildew',

'Strawberry___Leaf_scorch',

'Strawberry___healthy',

'Tomato___Bacterial_spot',

'Tomato___Early_blight',

'Tomato___Late_blight',
31
'Tomato___Leaf_Mold',

'Tomato___Septoria_leaf_spot',

'Tomato___Spider_mites Two-spotted_spider_mite',

'Tomato___Target_Spot',

'Tomato___Tomato_Yellow_Leaf_Curl_Virus',

'Tomato___Tomato_mosaic_virus',

'Tomato___healthy']

disease_model_path = 'models/plant_disease_model.pth'

disease_model = ResNet9(3, len(disease_classes))

disease_model.load_state_dict(torch.load(

disease_model_path, map_location=torch.device('cpu')))

disease_model.eval()

# Loading crop recommendation model

crop_recommendation_model_path = 'models/RandomForest.pkl'

crop_recommendation_model = pickle.load(

open(crop_recommendation_model_path, 'rb'))

# Custom functions for calculations

def weather_fetch(city_name):

"""

Fetch and returns the temperature and humidity of a city

:params: city_name

:return: temperature, humidity

"""
32
api_key = config.weather_api_key

base_url = "http://api.openweathermap.org/data/2.5/weather?"

complete_url = base_url + "appid=" + api_key + "&q=" + city_name

response = requests.get(complete_url)

x = response.json()

if x["cod"] != "404":

y = x["main"]

temperature = round((y["temp"] - 273.15), 2)

humidity = y["humidity"]

return temperature, humidity

else:

return None

def predict_image(img, model=disease_model):

"""

Transforms image to tensor and predicts disease label

:params: image

:return: prediction (string)

"""

transform = transforms.Compose([

transforms.Resize(256),

transforms.ToTensor(),
33
])

image = Image.open(io.BytesIO(img))

img_t = transform(image)

img_u = torch.unsqueeze(img_t, 0)

# Get predictions from model

yb = model(img_u)

# Pick index with highest probability

_, preds = torch.max(yb, dim=1)

prediction = disease_classes[preds[0].item()]

# Retrieve the class label

return prediction

# FLASK APP

app = Flask(__name__)

# render home page

@ app.route('/')

def home():

title = '- Home'

return render_template('index.html', title=title)

# render crop recommendation form page

@ app.route('/crop-recommend')

def crop_recommend():
34
title = '- Crop Recommendation'

return render_template('crop.html', title=title)

# render fertilizer recommendation form page

@ app.route('/fertilizer')

def fertilizer_recommendation():

title = '- Fertilizer Suggestion'

return render_template('fertilizer.html', title=title)

# render disease prediction input page

# RENDER PREDICTION PAGES

# render crop recommendation result page

@ app.route('/crop-predict', methods=['POST'])

def crop_prediction():

title = '- Crop Recommendation'

if request.method == 'POST':

N = int(request.form['nitrogen'])

P = int(request.form['phosphorous'])

K = int(request.form['pottasium'])

ph = float(request.form['ph'])

rainfall = float(request.form['rainfall'])

# state = request.form.get("stt")

city = request.form.get("city")

35
if weather_fetch(city) != None:

temperature, humidity = weather_fetch(city)

data = np.array([[N, P, K, temperature, humidity, ph, rainfall]])

my_prediction = crop_recommendation_model.predict(data)

final_prediction = my_prediction[0]

return render_template('crop-result.html', prediction=final_prediction, title=title)

else:

return render_template('try_again.html', title=title)

# render fertilizer recommendation result page

@ app.route('/fertilizer-predict', methods=['POST'])

def fert_recommend():

title = '- Fertilizer Suggestion'

crop_name = str(request.form['cropname'])

N = int(request.form['nitrogen'])

P = int(request.form['phosphorous'])

K = int(request.form['pottasium'])

# ph = float(request.form['ph'])

df = pd.read_csv('Data/fertilizer.csv')

36
nr = df[df['Crop'] == crop_name]['N'].iloc[0]

pr = df[df['Crop'] == crop_name]['P'].iloc[0]

kr = df[df['Crop'] == crop_name]['K'].iloc[0]

n = nr - N

p = pr - P

k = kr - K

temp = {abs(n): "N", abs(p): "P", abs(k): "K"}

max_value = temp[max(temp.keys())]

if max_value == "N":

if n < 0:

key = 'NHigh'

else:

key = "Nlow"

elif max_value == "P":

if p < 0:

key = 'PHigh'

else:

key = "Plow"

else:

if k < 0:

key = 'KHigh'

else:

key = "Klow"

37
response = Markup(str(fertilizer_dic[key]))

return render_template('fertilizer-result.html', recommendation=response, title=title)

# render disease prediction result page

@app.route('/disease-predict', methods=['GET', 'POST'])

def disease_prediction():

title = '- Disease Detection'

if request.method == 'POST':

if 'file' not in request.files:

return redirect(request.url)

file = request.files.get('file')

if not file:

return render_template('disease.html', title=title)

try:

img = file.read()

prediction = predict_image(img)

prediction = Markup(str(disease_dic[prediction]))

return render_template('disease-result.html', prediction=prediction, title=title)

except:

pass

return render_template('disease.html', title=title)

if __name__ == '__main__':

app.run(debug=False)

38
APPENDIX - II
OUTPUT SCREESHOTS

Figure 9.1 Home page

Description: A home page is the main web page of a website


website.. The term may also refer to the
start page shown in a web browser when the application first opens. Usually, the home page
is located at the root
ot of the website's domain or subdomain.

Figure 9.2 About us

Description: The about us page is often a reflection of the purpose and personality of the
business and its owners or top employees

39
Figure 9.3 Our services

Description: Our service is a simple ML and DL based website which recommends the best
crop to grow, fertilizers to use and the diseases caught by your crops
crops.

40
 CROP RECOMMEDATION SYSTEM

Figure 9.4 Crop prediction page

Description: This recommends the be


best crop to plating in your farm. Baased on your input
data.

Figure 9.5 Recommended plant

Description: This is the recomm


mended plant to your farm from our web page analyzed
result.

41
 FERTILIAZER RECOMMEDATION SYSTEM

Figure 9.6 Fertilizer prediction page

Description: This recommends the fertilizer to your crop. Based on your input
i data.

Figure 9.7 Recommended fertilizer

Description: This is the recomm


mended fertilizer to your crop from our web page analyzed
result.

42
 DISEASE PREDICTION

Figure 9.8 Disease prediction page

Description: This is disease predator webpage.

Figure 9.9 Predicted disease

Description: This is the output off your uploaded image.

43
REFERRENCE

[1] Rakesh Kumar, M.P. Singh, Prabhat Kumar and J.P. Singh, “Crop Selection Method to
Maximize Crop Yield Rate using Machine Learning Technique”, International Conference on
Smart Technologies and Management for Computing, Communication, Controls, Energy and
Materials, 2015

[2] Haedong Lee and Aekyung Moon, “Development of Yield Prediction System Based on
Real-time Agricultural Meteorological Information”, 16th International Conference on
Advanced Communication Technology, 2014

+[3] T.R. Lekhaa, “Efficient Crop Yield and Pesticide Prediction for Improving Agricultural
Economy using Data Mining Techniques”, International Journal of Modern Trends in
Engineering and Science (IJMTES), 2016, Volume 03, Issue 10

[4] Jay Gholap, Anurag Ingole, Jayesh Gohil, Shailesh Gargade and Vahida Attar, “Soil Data
Analysis Using Classification Techniques and Soil Attribute Prediction”, International
Journal of Computer Science Issues, Volume 9, Issue 3

[5] Anshal Savla, Parul Dhawan, Himtanaya Bhadada, Nivedita Israni, Alisha Mandholia,
Sanya Bhardwaj (2015), ‘Survey of classification algorithms for formulating yield prediction
accuracy in precision agriculture’, Innovations in Information, Embedded and
Communication systems (ICIIECS).

[6] AgroConsultant: Intelligent Crop Recommendation System Using Machine Learning


Algorithms. Zeel Doshi, Subhash Nadkarni, Rashi Agrawal, Prof. Neepa Shah.

[7] Crop Recommendation System for Precision Agriculture S.Pudumalar*, E.Ramanujam*,


R.Harine Rajashree, C.Kavya, T.Kiruthika, J.Nisha.

[8] Tom M. Mitchell, Machine Learning, India Edition 2013, McGraw Hill Educa- tion.

[9] https://data.gov.in/g

[10] Kagglehttps://www.kaggle.com/notebook

44

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy