农作物病害识别_FarmEasy:向农民推荐农作物变得容易

本项目构建了一个智能作物推荐门户,旨在帮助农民根据多个参数(包括播种时间、地区、温度、降雨、土壤pH值和类型)做出明智的种植决策。采用集成学习模型,结合随机森林、高斯朴素贝叶斯、K近邻和决策树算法,提升预测准确性。系统通过Web界面和语音输入功能,使农民能轻松获取作物推荐。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

农作物病害识别

In order to mitigate the agrarian crisis in the current status quo, there is a need for better recommendation systems to alleviate the crisis by helping the farmers to make an informed decision before starting the cultivation of crops.

为了缓解当前的农业危机,需要更好的推荐系统,通过帮助农民在开始种植作物之前做出明智的决定来缓解危机。

项目重点:根据几个参数推荐农民要种植的最佳农作物,并帮助他们在种植前做出明智的决定 (Project Focus: To recommend optimum crops to be cultivated by farmers based on several parameters and help them make an informed decision before cultivation)

The major parameters considered here are:

这里考虑的主要参数是:

1. Crop name

1.作物名称

2. Sowing Time (Month)

2.播种时间(月)

3. Region

3.地区

4. Temperature - Minimum & Maximum

4.温度-最小和最大

5. Rainfall - Minimum & Maximum

5.降雨-最小和最大

6. pH value of the Soil

6.土壤的pH值

7. Soil Type

7.土壤类型

Image for post
Data File Headers
数据文件头

让我们详细讨论步骤 (Let’s discuss the steps in detail)

Step 1: Data Collection

步骤1:资料收集

This was by far the most important and crucial step during the project building.

到目前为止,这是项目构建过程中最重要,最关键的一步。

Since there was no specific dataset available I had to work on building that dataset from scratch and had to choose the parameters accordingly. Additionally, I had several other parameters in mind such as Nitrogen level of Soil, Irrigation Facilities, Crop Rotation Cycle but due to data paucity was not able to take them into account.

由于没有可用的特定数据集,因此我不得不从头开始构建该数据集,并必须相应地选择参数。 另外,我还考虑了其​​他几个参数,例如土壤的氮含量,灌溉设施,作物轮作周期,但由于数据不足,无法将它们考虑在内。

The data obtained was distributed across different files such as:

获得的数据分布在不同的文件中,例如:

  1. Soil Type

    土壤类型

  2. Cash-crops

    现金作物

  3. Flower

  4. Fruit

    水果

  5. Grain

    粮食

  6. Herbs

    草药

  7. Shrubs

    灌木丛

  8. Spices

    香料

  9. Trees

    树木

  10. Vegetables

    蔬菜

  11. Average Rainfall

    平均降雨量

  12. Average Temperature

    平均温度

Step 2: Data Transformation

步骤2:资料转换

The data also had several inconsistencies since it was obtained from several different sources such as :

数据也有一些不一致之处,因为它是从以下几种不同的来源获得的:

  1. Missing Values

    缺失值

The missing values had to be removed from the dataset since they would lead to data inconsistencies and eventually to the wrong prediction.

必须从数据集中删除丢失的值,因为它们会导致数据不一致并最终导致错误的预测。

2. Spelling Aberrations

2. 拼写异常

The spellings were not consistent throughout the files and had to be normalised to a single value to improve the model accuracy.

整个文件中的拼写不一致,必须将其标准化为单个值以提高模型准确性。

3. Redundant Data

3. 冗余数据

The redundant data had to be discarded since they would not add any additional significance to the process.

冗余数据必须被丢弃,因为它们不会给流程增加任何其他意义。

The data was eventually coalesced into one dataset to ease the process of model building and computation.

最终将数据合并为一个数据集,以简化模型构建和计算过程。

Once, the data was collected the data types were checked and changes were made such as changing from String -> Integer where required.

一旦收集到数据,就检查数据类型并进行更改,例如在需要时从String-> Integer进行更改。

Also since a machine learning model works only with numbers, the string values need to be converted into numerical values. For this, I made use of Label Encoder Technique.

另外,由于机器学习模型仅适用于数字,因此需要将字符串值转换为数字值。 为此,我利用了标签编码器技术

“Label Encoder is a tool provided by Scikit Learn which helps one to encode the categorical features/variables into their numeric features. The encoder targets variables between 0 to n_classes-1 where n is the number of distinct labels.”

“标签编码器是Scikit Learn提供的一种工具,它可以帮助人们将分类特征/变量编码为数字特征。 编码器的目标变量在0到 n_classes-1 之间, 其中n是不同标签的数量。”

More can be learnt about Label Encoding by referring to the official Scikit Learn documentation here.

通过参考此处的官方Scikit Learn文档,可以了解有关标签编码的更多信息。

Step 3: Model Building

步骤3:建立模型

The model used here is: Ensemble Learning Model.

这里使用的模型是: 集成学习模型。

Okay first let us understand what ensemble learning is all about!

好吧,首先让我们了解集成学习的全部内容!

According to Wikipedia ensemble learning is stated follows :

根据维基百科的合奏学习陈述如下:

“Ensemble Learning approach uses multiple learning algorithms in statistics and machine learning to achieve greater predictive efficiency than either of the constituent learning algorithms alone might obtain.”

“集成学习方法在统计和机器学习中使用了多种学习算法,以实现比单独的任何一种组成学习算法都可实现的更高的预测效率。”

Here, I have made use of the functionality of Voting Classifier provided by Scikit Learn.

在这里,我利用了Scikit Learn提供的投票分类器的功能。

from sklearn.ensemble import VotingClassifiermodel=VotingClassifier(estimators=[('rf', random_forest),('gnb',gaussian_naive_bayes),('knn',k_nearest_neighbours), ('dt',decision_tree)  ], voting=''hard)

As seen in the above code snippet the model was built using algorithms listed below :

如上面的代码片段所示,该模型是使用以下算法构建的:

Random Forest Algorithm

随机森林算法

Gaussian Naive Bayes Algorithm

高斯朴素贝叶斯算法

K-Nearest Neighbours Algorithm

K最近邻居算法

Decision Tree Algorithm

决策树算法

Voting parameter is set to “hard” here since the model uses predicted class labels for majority rule voting.

由于模型使用预测的类别标签进行多数规则投票,因此此处的投票参数设置为“硬”。

Step 4: Deployment of the model

步骤4:模型的部署

In order to deploy the trained model for the farmers to use off, we would need an application with a simple user interface which the farmers can utilise.

为了部署经过培训的模型供农民使用,我们需要一个带有简单用户界面的应用程序,供农民使用。

Thus, here I made a simple web interface using HTML, CSS & Bootstrap.

因此,在这里,我使用HTML,CSS和Bootstrap创建了一个简单的Web界面。

The next step was to have a database to store the data for which I made use of : MongoDb

下一步是建立一个数据库来存储我使用的数据:MongoDb

Lastly, I wanted to predict the results for the obtained values from the user for which I made use of Flask framework to integrate the backend and the front end. Also,I generated the pickle file for our model to generate the predictions for the input data. Okay, so you would be wondering what is a pickle file? Let’s have a look at it as well.

最后,我想预测从用户那里获得的值的结果,我利用Flask框架为该值集成了后端和前端。 另外,我为模型生成了pickle文件,以生成输入数据的预测。 好的,您可能想知道什么是泡菜文件? 我们也来看看它。

According to the official Python documentation available at docs.python.org :

根据docs.python.org上提供的Python官方文档:

“The pickle module implements binary protocols for serialising and de-serialising a Python object structure. “Pickling” is the process whereby a Python object hierarchy is converted into a byte stream, and “unpickling” is the inverse operation, whereby a byte stream (from a binary file or bytes-like object) is converted back into an object hierarchy.”

pickle模块实现了二进制协议,用于对Python对象结构进行序列化和反序列化。 “ Pickling”是将Python对象层次结构转换为字节流的过程,而“ unpickling”是逆运算,将字节流(来自 二进制文件 类似字节的对象 )转换回对象层次结构的过程。 ”

In simple words, the pickled file converts the trained model into a byte stream and is sent to the website where it is unpickled again where it is used to train the incoming data from the farmers.

简而言之,腌制后的文件将训练后的模型转换为字节流,然后发送到网站,在该网站上再次进行腌制,然后将其用于训练来自农民的传入数据。

网站 (Website)

  • Login Page for the Farmer

    农民登录页面

Login & Sign Up

The farmer needs to enter their details such as :

农民需要输入他们的详细信息,例如:

Name

名称

Email Id

电子邮件ID

Password

密码

  • Services offered

    提供的服务

Image for post

Prediction

预测

Recommendation

建议

Information

信息

  • Predict now & Searching a Crop

    立即预测并搜索作物

Image for post

If the farmer would like to search for more information about a specific crop the “Search Crop Section” would be there to the rescue.

如果农民想搜索有关特定作物的更多信息,则可以在“ 搜索作物部分”进行救援

It helps the farmer with detailed information about the crop for better understanding.

它可以帮助农民获得有关农作物的详细信息,以便更好地理解。

Predict Now Section

现在预测部分

The predict now takes in the following parameters for the farmer:

现在,预测将为农民提供以下参数:

Month

pH Scale

pH值

Region

地区

Soil Type

土壤类型

Additionally, 2 parameters are taken into account from the database itself accordingly to the region mentioned by the farmer

此外,根据农民自己提到的区域,从数据库本身考虑了两个参数

Temperature

温度

Rainfall

雨量

Image for post

After inputting the values, the farmer can click on the “Predict Now” button.

输入值后,农民可以单击“立即预测”按钮。

The optimum Crop Name is displayed to the farmer for cultivation.

最佳作物名称显示给农民进行耕种。

Image for post

实施的其他功能 (Additional Functionalities Implemented)

RSS News Feed

RSS新闻提要

Image for post

Added the RSS functionality for farmers to get informative news for them to read and be updated!

为农民增加了RSS功能,以获取丰富的新闻供他们阅读和更新!

Voice Based Modelling System

基于语音的建模系统

Additionally, I have tried to implement a question-answer system model where I give a voice input as a question and I get an answer back in voice.

此外,我尝试实现一个问答系统模型,在该模型中,我以语音输入作为问题,然后以语音形式获得答案。

The system has been incorporated in the website to ease the process of the farmer for feeding in the application. The farmer just needs to click on the 🎙️ below the input field for talking!

该系统已整合到网站中,以简化农民输入应用程序的过程。 农民只需要单击输入栏下方的🎙️即可聊天!

Concepts and Libraries used here :

这里使用的概念和库:

  • iNLTK (Natural Language Tool Kit)- Taking input in the regional language (Hindi in this case)

    iNLTK(自然语言工具包)-以当地语言输入(在这种情况下为印地语)
  • SpeechRecognition- For receiving speech input from the farmer

    SpeechRecognition-用于接收农民的语音输入
  • gTTS (Google Text to Speech)- Providing farmer the output via voice

    gTTS(Google文本到语音)-通过语音为农民提供输出
  • Scikit Learn- For making use of NLP libraries

    Scikit Learn-用于使用NLP库

结论 (Conclusion)

I have built a portal for the Farmers in collaboration with my colleague Nipun Iyer which would help them to get assistance regarding crop cultivation strategies, primarily for the services of: prediction, recommendation, information of crops.

我与同事Nipun Iyer合作为农民建立了一个门户网站,该门户网站将帮助他们获得有关作物种植策略的帮助,主要用于以下方面的服务:预测,推荐,作物信息。

Thank you for taking the time out and reading this article! 🙂

感谢您抽出宝贵的时间阅读本文! 🙂

If you have got any doubts or would love to discuss more and understand about the project, please reach out to me here, would be happy to chat!

如果您有任何疑问或想讨论更多并了解该项目,请在这里与我联系,我们很乐意聊天!

翻译自: https://towardsdatascience.com/farmeasy-crop-recommendation-portal-for-farmers-48a8809b421c

农作物病害识别

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值