Giter Club home page Giter Club logo

lstm-for-rice-yield-prediction's Introduction

感谢您的阅读!

本项目是参加比赛:https://tianchi.aliyun.com/competition/entrance/231753/introduction 时做的。在 "./data" 里面附有数据。

项目运行环境:Python3.6 + jupyter notebook5.7.8 + Tensorflow2.0.0-beta1

本项目的代码仅一个文件: “code\Rice-9-16.ipynb”, 第4个cell里面有一个布尔类型的全局变量:”is_zao“, 该变量控制程序选择早稻或者晚稻中的一种作为研究对象。

数据处理思路:-------------------------------------------------------------------------------- 1 把‘\’和‘’替换成‘0’,丢弃无关特征:站名ID 2 按15/16/17/18年共4年和81个县ID划分出481个样本 3 在每个样本里截取前360行,用从1到360的索引替换年月日特征 4 把所有日照时长等浮点型的特征和3中添加的索引都归一化 5 风向特征是用字符串表示17种风向(含静风),若使用onehot编码,则4个风向 将会产生417长的向量,一方面计算量太大,另一方面风向特征数量远高于 其它特征可能弱化模型对其它特征的学习能力。本设计按照‘E’方向为0°, 逆时针转动为角度正方向,用每个风向对应的角度的正、余弦值表示风向。 比如‘N’方向:(0,1)。每个风向由一个字符串变两个浮点数。 另外,静风:‘C’和异常值:‘\’与‘’(在1中已经替换成0)用(0,0)表示。 6 对于县ID,如果直接使用1-88的数字表示则不利于学习其与水稻产量之间的关系, 因为产量与1-88这个数字之间并不是线性关系,也不是简单的单调递减或者递增的关系。 这里使用onehot编码的方式处理。

结果: 前5步处理所得特征共17列(含日照、降水、温度等和4个时刻的风向),每个样本里含前360天的记录,故: 单个样本天气特征: (360,17) 单个样本只有一个县ID: (88,) 单个样本对应的早/晚稻产量: (1,)

模型构建思路:---------------------------------------------------------------------------------- 1 定义LSTM模型学习天气特征与产量之间的关系,然后预测水稻产量,记为: pre 2 用Dense模型学习产量与县ID之间的关系,用Sigmoid激活输出,记为: c 3 最后把pre用c进行调节,即最终预测结果: pre * c

模型训练:--------------------------------------------------------------------------------------- 训练时,考虑到18年产量与17年产量相近,与16年产量相关性稍低,与15年产量相关性最低, 故设置15/16/17三年样本的权重为1:2:4。 为了防止过拟合,本设计使用了L2正则化。

最后,code有三个*.ipynb的文件,其中Rice-9-16-Zao.ipynb和Rice-9-16-Wan.ipynb, 分别记录了早稻和晚稻预测模型的建立和训练过程。

联系作者:[email protected]

lstm-for-rice-yield-prediction's People

Contributors

onebugmaker avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.