Machine Learning Based Crop Recommendation System For Local Farmers of Pakistan
Machine Learning Based Crop Recommendation System For Local Farmers of Pakistan
Pakistan
Abstract
Farming is one of the most fundamental and generally rehearsed work in Pakistan and it plays an
imperative part in fostering the country. In Pakistan, the most part of the land is used for agriculture
cultivation to meet the desires of nearby people and export want as properly. Therefore, the need of
increasing crop production is the significant challenge for farmers. Crop cultivation anywhere in the
world depends on the climate so called seasons and soil properties, however, the enhancing the
production of crops depend on various factors like mainly on temperature. In order to address the issue
of increasing crop production for Pakistan, a crop recommendation system is proposed in this work.
In this work, idea of ideal harvest prior to planting it, it would be of extraordinary assistance to the
farmers and others required to settle on fitting choices on upgrading the creation of yields for
neighborhood utilization needs and may prompt the capacity and expanded fare choice for business.
Our framework utilized Machine Learning procedures with the end goal that it proposes the
appropriate corps dependent on the temperature. This framework subsequently diminishes the
monetary misfortunes looked by the farmers brought about by establishing the ominous harvests and
furthermore it gives the information on the occasional characterization of yields what harvest is
reasonable for which season. It is concluded that proposed algorithm has an average accuracy of 90%
on the given dataset. The achieved accuracy is more in comparison to existing work.
Agriculture assumes a critical part in the economies of least developed nations like Pakistan
[1]. Farming establishes the biggest offer in the economy of Pakistan [2-3]. Pakistan's farming
commitment to Gross Domestic Product GDP is 26% with yearly development of 2.7% [4-6].
Agriculture gives business freedoms to 44% of the workforce and 62% of the provincial populace rely
on this area for their job [7-8]. Pakistan has a place with one of the world's biggest frameworks to help
Agriculture creation. It is the most important source of foreign exchange revenues, accounting for
around 80% of overall export earnings [9]. Farming is considered as the foundation of Pakistan's
economy, which depends intensely on its significant yields [10]. Harvest creation is reliant upon
topographical variables as soil synthetic, temperature, stickiness and so forth [11]. These factors plays
major role in increasing the crop production. Farmers are unaware from these factors and select the
crop for cultivation based on their experience of growing particular crop again and again. Farmers’
crop selection accuracy is low not cost effective. It is important to practice modern methods of farming
by using technology instead of practicing traditional farming method. To solve this problem, we offer
a framework that will recommend crops dependent on the temperature of the general climate. Farmers
can expand their yield by developing the harvest suggested by the framework.
In this study, a Machine Learning approach is utilized to recommend the best crop, and Python
is used as the programming language because it is generally accepted for experimentation in the
Machine Learning field. Machine Learning is an important tool for data analysis that uses learning
algorithms to iteratively learn from available data [12]. Machine Learning is an area of artificial
intelligence that tries to give computer methods for accumulating, changing, and updating the
knowledge of intelligent systems [12]. The model is trained using linear regression analysis. The output
predictions are then made by this trained system. The proposed system suggests the favorable crop for
cultivation but also provide the seasonal classification of crops to the farmers, as they get maximum
production and profit.
2. Literature Review
There are different studies have been carried out in the past in developing and designing the
crop based predicting system. The each work completed and reported in the past have their own
advantages and disadvantages in developing the system based on particular problem of crop production
enhancement.
3. Research Methodology
The goal of this study is to demonstrate the impact of meteorological variables on agricultural
production in order to improve crop yields, which will help farmers. As shown in Fig. 1, the linear
regression system model is created in Python. Other design steps will be explored in detail in the
following sections.
Statistical data for the study is gathered from a variety of sources, including the agricultural
department, websites, agricultural research institutions, and so on. The data was gathered in the
Nawabshah area. Our information includes the temperate as an attribute, as well as the outcomes of
crops that may be cultivated in that soil type. Dataset consists of few major crops which are mostly
cultivated as wheat, sugarcane, rice and cotton.
B. Data Preprocessing
Data preprocessing is a data mining approach that entails converting raw data into a format that
can be understood. Because the original dataset may have a large number of missing values, all of them
should be eliminated at first. Missing values are represented by a dot in the dataset, and their existence
can degrade the overall value of the data as well as impair performance. As a result, we replace these
numbers with the mean values to fix this problem. The second step is to create the class labels. Because
we're utilizing supervised learning, there should be a class label for each entry in the dataset, which is
produced during the preprocessing phase.
C. Regression Analysis
Regression Analysis is a predictive modelling technique that examines the relationship between
a dependent or target variable and an independent or predictor variable. It covers linear, multiple linear,
and non-linear regression models, among others. Simple linear regression is the most used model.
Polynomial regression is a type of regression method in which the link between the independent
variable x and the dependent variable y is described as an nth degree polynomial in x. polynomial
regression fits a nonlinear relationship between the value of x and the associated conditional mean of
y, denoted by E(y |x). Despite the fact that polynomial regression fits a nonlinear model to the data, as
a statistical estimation problem it is linear in the sense that in the unknown parameters inferred from
the data, the regression function E(y |x) is linear. As a result, polynomial regression is regarded as a
subset of multiple linear regressions. The predicted value of y may be modelled as an nth degree
polynomial in general, producing the generic polynomial regression model given in (1):
𝑦 = 𝑏𝑜 + 𝑏1 𝑥1 + 𝑏2 𝑥2 2 + ⋯ + 𝑏𝑘 𝑏𝑘 𝑘 (1)
D. Trained Model
Prepared model is gotten subsequent to applying the dataset to the Machine Learning
algorithms. Our work gives a crop proposing framework which depends on the Polynomial Regression
algorithm dependent on the temperature of climate are given as an input to the model. The algorithm
will seek for a crop that is the most similar in value to the provided values. The output will be the results
of crops, crop with high result are suitable for the inputted values.
Taking into this account, this algorithm search for the similarities in the whole dataset. The
outcome is determined dependent on the most practically identical or nearest values. Depending on the
amount of records in the dataset, the complete dataset is split into a number of classes or possible
outcomes in this method, as illustrated in Fig.2.
E. Programming Language
In order to address the problem of increasing crop production for Pakistan, the above machine
learning system is proposed for crop recommendation that suggests of favorable crop prior to planting
it, it would be extremely beneficial to farmers and other stakeholders in making informed decisions on
how to increase output. The crop production is highly affected by the environmental and soil conditions.
The production is reduced when cultivated crop has not provided the favorable environmental and soil
conditions. It is necessary to cultivate the favorable crop according to the environmental and soil
parameters to get maximum profit. Based on the trained model discussed in Fig. 2. The analysis of
crops production based on different temperature is attained using the proposed machine learning model
is depicted in Fig. 3. It has been analyzed from the data that the minimum production i.e. 40% of the
cotton will be yield at temperature 12°C and maximum yield of cotton production i.e. more than 90%
will yield at temperature 25-35°C. Based on this information, it has been extracted that for temperature
ranging from 25-35°C will be recommended to the farmer using proposed system.
Cotton Crop
100
90
80
70
production%
60
50
40
30
20
10
0
12 C 14 C 20 C 22 C 25 C 30 C 32 C 35 C 40 C 45 C
Temperature in C
Similarly, the analysis is carried out for wheat crop yield on different temperature is defined
using the proposed machine learning model as shown in Fig. 4. It is shown in Fig. 4 that the maximum
wheat crop production i.e. more than 90% will be achieved at range of temperature from 12°C to 22°C
Wheat Crop
100
90
80
Production in %
70
60
50
40 Wheat
30
20
10
0
12 C 14 C 20 C 22 C 25 C 30 C 32 C 35 C 40 C 45 C
Temperature
Fig. 5 discussed the Sugarcane yield on different temperature. It is shown in Fig. 5 that the
maximum wheat crop production i.e. more than 80% will be achieved at range of temperature from
20°C to 32°C and as the temperature raises the sugarcane production is decreased.
Sugarcane Crop
100
90
80
70
60
Results
50
40 Sugarcane
30
20
10
0
12 C 14 C 20 C 22 C 25 C 30 C 32 C 35 C 40 C 45 C
Temperature
Rice Crop
100
90
80
70
60
Results
50
40 Rice
30
20
10
0
12 C 14 C 20 C 22 C 25 C 30 C 32 C 35 C 40 C 45 C
Temperature
The proposed system provides the solution for selecting the favorable the crop based on
Temperature. The values are given as input to the system and system analyzed the data gives results of
crops as output. The system suggested crop grown efficiently and farmers get the maximum production
and profit. Our system also gives the knowledge of seasonal classification of different crops, that the
crops grow efficiently and healthy in which environment and soil. Our algorithm has an average
accuracy of 90% on the given dataset.
Fig. 7 is the outcome of our proposed algorithm that using our proposed system, the farmers
may get the information that in which month based on temperate the crops can be cultivated so that can
be given maximum production. It can be seen in Fig. 7 that the wheat crop may yield maximum
production in the late winter season possess in Pakistan. The sugarcane may yield the maximum
production in the season of autumn.
Furthermore, Fig. 7 demonstrates that in order to get optimum Cotton output, the month of
spring is most feasible as per season of Pakistan. For the rice production, the season of summer is
appropriate to cultivate in order to achieve the maximum production. In the next, the accuracy of all
crop using proposed algorithm is depicted using Fig. 8.
Figure 8 - Comparison between Predict and Test Values of Major Four Crops
Agriculture assume an indispensable part in endurance for everybody. Farmers confront several
challenges as a result of a variety of uncontrollable factors. As a result, we employ prediction models
to overcome the unpredictability of favorable crop or other agriculture-related problems. To forecast
the favourable crop, the regression model is employed as a prediction tool. Thus, in this research, linear
regression analysis is utilised to create a link between the above-mentioned independent factors and
their impacts on crop output, with the goal of increasing agricultural productivity by utilizing the
model's favourable crop forecast. The dependence of crop production on temperature is also examined
in this paper, and a crop prediction is made based on the results. The crop recommendation system is
capable of providing a lasting solution to the problem encountered by farmers.
There are some aspects of this study that require additional investigation in order to learn more
about crop recommendation prediction using regression analysis. Rainfall, minerals accessible in soil
such as potassium, nitrogen, and phosphorous, rainfall, and crop market value may all be included to
the input parameters, making the model forecast more accurate and lucrative. Other approaches, such
as fuzzy logic and neural networks, might be employed in future studies.
Acknowledgement
The authors would like to thanks the Directorate of Postgraduate Studies and Department of
Electronic Engineering, Quaid-e-Awam University of Engineering, Science and Technology,
Nawabshah, Sindh, Pakistan for their support in conducting this research.
References
Naveen Kumar PR, Manikanta KB, Venkatesh BY, Naveen Kumar R, Amith Mali Patil, “Smart
Agricultural Crop Prediction Using Machine Learning”, Journal of Xi’an University of Architecture &
Technology Volume XII, Issue V, 2020, ISSN No: 1006-7930.