Crop Prediction using Machine Learning Approaches

Download Full-Text PDF Cite this Publication

Text Only Version


Crop Prediction using Machine Learning Approaches

Nischitha K

Assistant Professor, Department of E&C Engineering

P.E.S College of Engineering, Mandya India

Dhanush Vishwakarma

Mahendra N

Department of E&C Engineering

P.E.S College of Engineering, Mandya India.


Department of E&C Engineering

P.E.S College of Engineering, Mandya India.

Department of E&C Engineering

P.E.S College of Engineering, Mandya, India

Manjuraju M.R

Department of E&C Engineering

      1. College of Engineering, Mandya, India.

        Abstract As we know the fact that, India is the second largest population country in the world and majority of people in India have agriculture as their occupation. Farmers are growing same crops repeatedly without trying new verity of crops and they are applying fertilizers in random quantity without knowing the deficient content and quantity. So, this is directly affecting on crop yield and also causes the soil acidification and damages the top layer. So, we have designed the system using machine learning algorithms for betterment of farmers. Our system will suggest the best suitable crop for particular land based on content and weather parameters. And also, the system provides information about the required content and quantity of fertilizers, required seeds for cultivation. Hence by utilizing our system farmers can cultivate a new variety of crop, may increase in profit margin and can avoid soil pollution.

        KeywordsMachine Learning,Crop prediction,Decision tree,SVM, Rainfall prediction,Crop recommendation;


          Agriculture is one of the important occupation practiced in India. It is the broadest economic sector and plays a most important role in the overall development of the country. More than 60% of the land in the country is used for agriculture in order to suffice the needs of 1.3 billion people Thus adopting new agriculture technologies is very important. This will be leads the farmers of our country towards profit [1]. Prior crop prediction and yield prediction was performed on the basis of farmers experience on a particular location. They will prefer the prior or neighborhood or more trend crop in the surrounding region only for their land and they dont have enough of knowledge about soil nutrients content such as nitrogen, phosphorus, potassium in the land. Being this as the current situation without the rotation of the crop and apply an inadequate amount of nutrients to soil it leads to reduce in the yield and soil pollution (soil acidification) and damages the top layer. Considering all these problems takes into the account we

          designed the system using a machine learning for betterment of the farmer. Machine learning(ML) is a game changer for agriculture sector. Machine learning is the part of artificial intelligence, has emerged together with bigdata technologies and high-performance computing to create new opportunities for data intensive science in the multi-disciplinary agri- technology domain. In the Agriculture field machine learning for instance is not a mysterious trick or magic, it is a set of well define model that collect specific data and apply specific algorithms to achieve expected results [7].

          The designed system will recommend the most suitable crop for particular land. Based on weather parameter and soil content such as Rainfall, Temperature, Humidity and pH. They are collected from V C Farm Mandya, Government website and weather department. The system takes the required input from the farmers or sensors such as Temperature, Humidity and pH. This all inputs data applies to machine learning predictive algorithms like Support Vector Machine (SVM) [5] and Decision tree [6] to identify the pattern among data and then process it as per input conditions. The system recommends the crop for the farmer and also recommends the amount of nutrients to be add for the predicted crop. The system has some other specification like displaying approximated yield in q/acre, required seed for cultivation in kg/acre and the market price of the crop.


          Ashwani kumar Kushwaha[2] describes crop yield prediction methods and a suggest suitable crop so that it will improve the profit for the farmer and quality of the agriculture sector. In this paper for crop yield prediction they obtain large volume data, its been called as big data (soil and weather data) using Hadoop platform and agro algorithm. Hence based repository data will predict the suitability crop for particular condition and improvement crop quality.

          Girish L [3] describe the crop yield and rain fall prediction using a machine learning method. In this paper they gone through a different machine learning approaches for the prediction of rainfall and crop yield and also mention the efficiency of a different machine learning algorithm like liner regression, SVM, KNN method and decision tree. In that algorithm they conclude that SVM have the highest efficiency for rainfall prediction.

          Rahul katarya [4] describes the different machine learning methods used for accelerating crop yield. In this paper they gone through different artificial intelligence techniques such as machine learning algorithm, big data analysis for precision agriculture. They explain about crop recommender system using KNN, Ensemble-based Models, Neural networks, …etc.


          The Proposed system will predict the most suitable crop for particular land based on soil contents and weather parameters such as Temperature, Humidity, soil PH and Rainfall.

          define the target for a model. After data cleaning the dataset will be split into training and test set by using sklearn library.

            1. Machine Learning Algorithm for Prediction: – Machine learning predictive algorithms has highly optimized estimation has to be likely outcome based on trained data. Predictive analytics is the use of data, statistical algorithms and machine learning techniques to identify the likelihood of future outcomes based on historical data. The goal is to go beyond knowing what has happened to providing a best assessment of what will happen in the future.

              In our system we used supervised machine learning algorithm having subcategories as classification and regression. Classification algorithm will be most suitable for our system.

              • Rainfall prediction: -SVM algorithm.
              • Crop prediction: – Decision tree algorithm.
          1. Rainfall Prediction: The flow chart of rainfall prediction as shown in fig 2



            CLIMATE DATA



            (SVM, Decision Tree Algorithm )


            (Data cleaning, dealing with missing values, train/test split)


            (SVM, Decision Tree Algorithm )


            (Data cleaning, dealing with missing values, train/test split)


            (Combining data from different resources)


            Display Suitable CROP

            Display Required NPK nutrients for crop

            Display Required Seeds in Kg/acre for cultivation

            Provide information about currentmarket price and approximate yield of recommended crop

            Load external dataset


            (dealing with missing values, data cleaning ,train/test split)


            Figure 1. Architecture of the proposed system.

            Predict Rainfall using SVM algorithm

            The Architecture of the proposed system consists of various blocks as shown in the fig (1) as follows

              1. Data Collection: – Data collection is the most efficient method for collecting and measure the data from different resources like govt websites, VC Form Mandya, APMC website …. etc. To get an approximate dataset for the system.

                This dataset must contain the following attributes

                i)Soil PH ii) Temperature iii) Humidity iv) Rainfall v) Crop data vi) NPK values, those parameters will consider for crop prediction. For the annual rainfall prediction, we collect previous year rainfall data.

              2. Data Preprocessing: – After collecting datasets from various resources. Dataset must be preprocessing before training to the model. The data preprocessing can be done by various stages, begins with reading the collected dataset the process continues to data cleaning. In data cleaning the datasets contain some redundant attributes, those attributes are not considering for crop prediction. So, we have to drop unwanted attributes and datasets containing some missing values we need to drop these missing values or fill with unwanted nan values in order to get better accuracy. Then

            Print predicted rainfall for 2020


            Figure 2. Flow chart for rainfall prediction.

            The process starting with a load the external dataset contains previous year rainfall data. Then loaded dataset pre-processing takes place as discussed in Data Pre-processing section. After data pre-processing we train the model by using SVM classifier with Radial basis function(RBF) kernel. Then fitting the classifier into training set. Radial basis function can be written in the mathematical form in equation (1),




            (1, 2) = (||1 2|| ) . ..(1) Where, ||X1-X2|| = Eucliden distance between X1 & X2

            = Gamma

            After fitting and test the model, at last this model will predict the appropriate annual rainfall. The predicted rainfall is the one of the input parameter for the crop prediction system.

          2. Crop Prediction:

          Crop prediction process being with the loading the external crop datasets. Once the dataset read then pre-processing will be done by various stages as discussed in Data Pre-processing section. After the data pre-processing, train the models using Decision tree classifier into training set. For a prediction of the crop, we consider a various factor such as temperature, humidity, soil PH and predicted rainfall. Those are the input parameter for a system that can be entered by manually or taken from the sensors. Predicted rainfall and input parameter values will be appended in a list. The Decision tree algorithm will predict the crop based on list data.

          The overall flow chart of the proposed system is shown in the figure (3).

          The overall output is shown with Graphical user interface as shown in figure (4),


          Read temperature, Humidity, pH Values

          Append all the values in list

          Load External Crop dataset


          (dealing with missing values, data cleaning

          ,train/test split)


          Predict Crop Using Decision Tree Regressor

          Load Rainfall dataset DATA PREPROCESSING

          (dealing with missing values,

          data cleaning ,train/test split)

          Predict Rainfall using SVM NO


          Predict Rainfall for 2020


          Print predicted Rainfall

          Figure 4. Overall output with GUI

          We tested the system for various data set that has been collected from the different farmers for their lands conditions. Land conditions just like the land having different pH, humidity and NPK values. The predicted annual rainfall is constant for year 2020.

          Crop Classification using

          NO Predicted crop index values


          Display Suitable Crop

          Display Required NPK, Required Seed, Yield and Price

          Read NPK Values


          Figure 3. Proposed System Flow chart.

          3.4. Crop Recommendation:

          Based on predicted rainfall, soil contents and weather parameters the system will recommend the most suitable crop for cultivation. This system also provides details about required fertilizers like Nitrogen(N), Phosphorus (P) and potassium(K) in Kg per hectare and display the required seed for a cultivation in Kg per acre for recommended crop.

          This system as contain some other feature such as display the current market price and approximated yield in quintal per acre for recommended crop. Those all details will helps to farmers for choosing the most profitable crop.


          The proposed system recommends the best suitable crop for particular land by considering parameters as annual rainfall, temperature, humidity and soil pH. Among these parameters annual rainfall is predicted by system itself by using previous year data with SVM algorithm and other parameters are have to be entered by the user. In the output section the system displays a suitable crop, required seeds/acre, market price and approximate yield of the recommended crop and also the system takes NPK values in the input section to display the required NPK for the recommended crop.

          Figure 5. Tested output results


Presently our farmers are not effectively using technology and analysis, so there may be a chance of wrong selection of crop for cultivation that will reduce their income. To reduce those type of loses we have developed a farmer friendly system with GUI, that will predict which would be the best suitable crop for particular land and this system will also provide information about required nutrients to add up, required seeds for cultivation, expected yield and market price. So, this makes the farmers to take right decision in selecting the crop for cultivation such that agricultural sector will be developed by innovative idea.


We have to collect all required data by giving GPS locations of a land and by taking access from Rain forecasting system of by the government, we can predict crops by just giving GPS location. Also, we can develop the model to avoid over and under crisis of the food.


  1. Prof. D.S. Zingade ,Omkar Buchade ,Nilesh Mehta ,Shubham Ghodekar ,Chandan Mehta Crop Prediction System using Machine Learning.
  2. Ashwani kumar Kushwaha, Swetabhattachrya crop yield prediction using agro algorithm in hatoop.
  3. Girish L, Gangadhar S, Bharath T R, Balaji K S, Abhishek K T Crop Yield and Rainfall Prediction in Tumakuru District using Machine Learning.
  4. Rahul Katarya, Ashutosh Raturi, Abhinav Mehndiratta, Abhinav Thapper Impact of Machine Learning Techniques in Precision Agriculture.
  5. Pijush Samui, Venkata Ravibabu Mandla, Arun Krishna and Tarun Teja Prediction of Rainfall Using Support Vector Machine and Relevance Vector Machine.
  6. Himani Sharma, Sunil Kumar A Survey on Decision Tree Algorithms of Classification in Data Mining.
  7. Pavan Patil, Virendra Panpatil, Prof. Shrikant Kokate Crop Prediction System using Machine Learning Algorithms.

Leave a Reply

Your email address will not be published. Required fields are marked *