使用LSTM進(jìn)行時(shí)間序列預(yù)測(cè)PyTorch版本
前言
時(shí)間序列數(shù)據(jù),顧名思義,是一種隨著時(shí)間改變的數(shù)據(jù)。例如,
24小時(shí)氣溫?cái)?shù)據(jù),
一個(gè)月的產(chǎn)品價(jià)格數(shù)據(jù),
某一公司股票價(jià)格年度數(shù)據(jù)。
。。。。。。
高級(jí)深度學(xué)習(xí)模型,比如長(zhǎng)短期記憶網(wǎng)絡(luò)(LSTM),能夠捕獲到時(shí)間序列數(shù)據(jù)中的變化模式,進(jìn)而能夠預(yù)測(cè)數(shù)據(jù)的未來(lái)趨勢(shì)。本文中,我們將使用pytorch這個(gè)深度學(xué)習(xí)庫(kù),來(lái)實(shí)現(xiàn)利用LSTM算法對(duì)時(shí)間序列數(shù)據(jù)進(jìn)行預(yù)測(cè)。
在開(kāi)始講述之前,我們先導(dǎo)入必要的庫(kù),
import torch import torch.nn as nn import seaborn as sns import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline
數(shù)據(jù)集
我們將使用Seaborn庫(kù)的內(nèi)建數(shù)據(jù)集。讓我們打印一下Seaborn的所有內(nèi)建數(shù)據(jù)庫(kù):
sns.get_dataset_names()
輸出結(jié)果為:
['anagrams', 'anscombe', 'attention', 'brain_networks', 'car_crashes', 'diamonds', 'dots', 'dowjones', 'exercise', 'flights', 'fmri', 'geyser', 'glue', 'healthexp', 'iris', 'mpg', 'penguins', 'planets', 'seaice', 'taxis', 'tips', 'titanic']
鏈接:https://www.dianjilingqu.com/523763.html