当前位置: 首页 > news >正文

建设局网站建设方案书seo咨询服务价格

建设局网站建设方案书,seo咨询服务价格,公司名称变更说明函,怎么在各大网站做推广文章目录 TimeGPT使用外生变量时间序列预测导入相关工具包预测欧美国家次日电力价格案例 TimeGPT使用外生变量时间序列预测 外生变量在时间序列预测中非常重要,因为它们提供了可能影响预测的额外信息。这些变量可以包括假日标记、营销支出、天气数据或与你正在预测…

文章目录

    • TimeGPT使用外生变量时间序列预测
    • 导入相关工具包
    • 预测欧美国家次日电力价格案例

TimeGPT使用外生变量时间序列预测

外生变量在时间序列预测中非常重要,因为它们提供了可能影响预测的额外信息。这些变量可以包括假日标记、营销支出、天气数据或与你正在预测的时间序列数据相关的任何其他外部数据。

例如,如果你正在预测冰淇淋销售额,温度数据可以作为一个有用的外生变量。在炎热的天气里,冰淇淋销售额可能会增加。

要在TimeGPT中加入外生变量,你需要将时间序列数据中的每个点与相应的外部数据配对。

导入相关工具包


# Importing the colab_badge module from the nixtlats.utils package
from nixtlats.utils import colab_badge
# 导入load_dotenv函数,用于加载.env文件中的环境变量
from dotenv import load_dotenv
# 导入load_dotenv函数,用于加载环境变量
load_dotenv()
True

import pandas as pd
from nixtlats import TimeGPT
/home/ubuntu/miniconda/envs/nixtlats/lib/python3.11/site-packages/statsforecast/core.py:25: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.htmlfrom tqdm.autonotebook import tqdm
# 定义TimeGPT对象,并传入一个参数token,用于身份验证
# 如果没有提供token参数,则默认使用os.environ.get("TIMEGPT_TOKEN")获取token
timegpt = TimeGPT(token = 'my_token_provided_by_nixtla'
)
# 导入TimeGPT模型timegpt = TimeGPT()  # 创建TimeGPT对象的实例

预测欧美国家次日电力价格案例

让我们看一个关于预测次日电力价格的例子。以下数据集包含了欧洲和美国五个市场的每小时电力价格(y列),这些市场由unique_id列进行标识。从Exogenous1day_6的列是TimeGPT用来预测价格的外生变量。

# 从指定的URL读取csv文件,并将其存储在DataFrame对象df中
df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-with-ex-vars.csv')# 显示DataFrame对象df的前几行数据
df.head()
unique_iddsyExogenous1Exogenous2day_0day_1day_2day_3day_4day_5day_6
0BE2016-12-01 00:00:0072.0061507.071066.00.00.00.01.00.00.00.0
1BE2016-12-01 01:00:0065.8059528.067311.00.00.00.01.00.00.00.0
2BE2016-12-01 02:00:0059.9958812.067470.00.00.00.01.00.00.00.0
3BE2016-12-01 03:00:0050.6957676.064529.00.00.00.01.00.00.00.0
4BE2016-12-01 04:00:0052.5856804.062773.00.00.00.01.00.00.00.0

为了生成预测,我们还需要添加外生变量的未来值。让我们读取这个数据集。在这种情况下,我们希望预测未来24个步骤,因此每个“unique_id”将有24个观察值。

# 从GitHub上读取电力短期未来外部变量数据集
future_ex_vars_df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-future-ex-vars.csv')# 打印数据集的前五行
future_ex_vars_df.head()
unique_iddsExogenous1Exogenous2day_0day_1day_2day_3day_4day_5day_6
0BE2016-12-31 00:00:0064108.070318.00.00.00.00.00.01.00.0
1BE2016-12-31 01:00:0062492.067898.00.00.00.00.00.01.00.0
2BE2016-12-31 02:00:0061571.068379.00.00.00.00.00.01.00.0
3BE2016-12-31 03:00:0060381.064972.00.00.00.00.00.01.00.0
4BE2016-12-31 04:00:0060298.062900.00.00.00.00.00.01.00.0

让我们调用forecast方法,添加这些信息:

# 使用timegpt模型对数据进行预测
# 参数说明:
# - df: 历史数据的DataFrame
# - X_df: 未来外部变量的DataFrame
# - h: 预测的时间步长
# - level: 置信水平
timegpt_fcst_ex_vars_df = timegpt.forecast(df=df, X_df=future_ex_vars_df, h=24, level=[80, 90])# 打印预测结果的前几行
timegpt_fcst_ex_vars_df.head()
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Inferred freq: H
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
unique_iddsTimeGPTTimeGPT-lo-90TimeGPT-lo-80TimeGPT-hi-80TimeGPT-hi-90
0BE2016-12-31 00:00:0038.86176233.82107334.36866943.35485443.902450
1BE2016-12-31 01:00:0035.38210230.01459431.49332239.27088240.749610
2BE2016-12-31 02:00:0033.81142526.65882128.54308739.07976440.964029
3BE2016-12-31 03:00:0031.70747524.89620526.81879536.59615538.518745
4BE2016-12-31 04:00:0030.31647521.12514324.43214836.20080139.507807
# 导入必要的模块和函数# 使用timegpt.plot函数绘制时间序列预测结果的图表
# 参数1:df[['unique_id', 'ds', 'y']],表示要绘制的时间序列数据,包括唯一标识符、时间戳和目标变量
# 参数2:timegpt_fcst_ex_vars_df,表示时间序列预测的额外变量数据
# 参数3:max_insample_length=365,表示用于训练模型的最大历史数据长度为365天
# 参数4:level=[80, 90],表示绘制置信区间的水平,这里设置为80%和90%
# 返回:绘制好的时间序列预测结果图表
timegpt.plot(df[['unique_id', 'ds', 'y']], timegpt_fcst_ex_vars_df, max_insample_length=365, level=[80, 90], 
)

我们还可以获得特征的重要性。

# 绘制水平条形图
timegpt.weights_x.plot.barh(x='features', y='weights')
<Axes: ylabel='features'>

您还可以使用CountryHolidays类添加国家假期。

# 导入nixtlats.date_features模块中的CountryHolidays类from nixtlats.date_features import CountryHolidays
# 导入所需的模块和函数# 使用timegpt模型对给定的数据进行预测
# 参数:
# - df: 历史数据的DataFrame,包含时间序列数据
# - X_df: 未来外部变量的DataFrame,包含与时间序列相关的外部变量
# - h: 预测的时间步长,即预测未来多少个时间点的值
# - level: 置信水平的列表,用于计算置信区间
# - date_features: 日期特征的列表,用于考虑特殊的日期效应,如假期等
# 返回值:
# - timegpt_fcst_ex_vars_df: 预测结果的DataFrame,包含预测值和置信区间
timegpt_fcst_ex_vars_df = timegpt.forecast(df=df, X_df=future_ex_vars_df, h=24, level=[80, 90], date_features=[CountryHolidays(['US'])]
)
# 使用timegpt模型的weights_x属性绘制水平条形图
# 参数:
# - x: 水平条形图的x轴数据,即特征名称
# - y: 水平条形图的y轴数据,即特征权重值
timegpt.weights_x.plot.barh(x='features', y='weights')
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Inferred freq: H
INFO:nixtlats.timegpt:Calling Forecast Endpoint...<Axes: ylabel='features'>


文章转载自:
http://killer.zfqr.cn
http://laryngectomy.zfqr.cn
http://inside.zfqr.cn
http://pentacle.zfqr.cn
http://multimillion.zfqr.cn
http://harmattan.zfqr.cn
http://invigilator.zfqr.cn
http://brioche.zfqr.cn
http://piezometry.zfqr.cn
http://chloe.zfqr.cn
http://sacw.zfqr.cn
http://schnockered.zfqr.cn
http://vita.zfqr.cn
http://lamellose.zfqr.cn
http://urochordate.zfqr.cn
http://bingo.zfqr.cn
http://alike.zfqr.cn
http://awninged.zfqr.cn
http://dollhouse.zfqr.cn
http://salvation.zfqr.cn
http://stolidity.zfqr.cn
http://jabberwocky.zfqr.cn
http://lesotho.zfqr.cn
http://dictionary.zfqr.cn
http://chuffing.zfqr.cn
http://brainman.zfqr.cn
http://jolterhead.zfqr.cn
http://anectine.zfqr.cn
http://gaslit.zfqr.cn
http://epizoon.zfqr.cn
http://skiascope.zfqr.cn
http://californiana.zfqr.cn
http://annelidan.zfqr.cn
http://cc.zfqr.cn
http://decamp.zfqr.cn
http://conceal.zfqr.cn
http://conveyorize.zfqr.cn
http://frazil.zfqr.cn
http://rog.zfqr.cn
http://preparatory.zfqr.cn
http://chicquest.zfqr.cn
http://plowboy.zfqr.cn
http://understaffing.zfqr.cn
http://lacunaris.zfqr.cn
http://haylage.zfqr.cn
http://disarticulate.zfqr.cn
http://ranchi.zfqr.cn
http://tortility.zfqr.cn
http://halieutic.zfqr.cn
http://presentability.zfqr.cn
http://ostensibly.zfqr.cn
http://naive.zfqr.cn
http://preseason.zfqr.cn
http://grungy.zfqr.cn
http://barranca.zfqr.cn
http://landline.zfqr.cn
http://normoblast.zfqr.cn
http://translatese.zfqr.cn
http://catharsis.zfqr.cn
http://noonday.zfqr.cn
http://uncalled.zfqr.cn
http://paleohabitat.zfqr.cn
http://dominium.zfqr.cn
http://ullage.zfqr.cn
http://markswoman.zfqr.cn
http://swim.zfqr.cn
http://fusty.zfqr.cn
http://mouldwarp.zfqr.cn
http://bookable.zfqr.cn
http://grossularite.zfqr.cn
http://celeb.zfqr.cn
http://logically.zfqr.cn
http://falange.zfqr.cn
http://gannetry.zfqr.cn
http://sideward.zfqr.cn
http://therewith.zfqr.cn
http://firing.zfqr.cn
http://christy.zfqr.cn
http://motorise.zfqr.cn
http://hardbake.zfqr.cn
http://marathon.zfqr.cn
http://lampad.zfqr.cn
http://truebred.zfqr.cn
http://vermiculite.zfqr.cn
http://login.zfqr.cn
http://aforenamed.zfqr.cn
http://pinchpenny.zfqr.cn
http://goonda.zfqr.cn
http://airfreighter.zfqr.cn
http://bichrome.zfqr.cn
http://surinamer.zfqr.cn
http://pindling.zfqr.cn
http://hypoxemic.zfqr.cn
http://lampad.zfqr.cn
http://inkwriter.zfqr.cn
http://gingery.zfqr.cn
http://oxyphil.zfqr.cn
http://uneffectual.zfqr.cn
http://vilene.zfqr.cn
http://primitivity.zfqr.cn
http://www.hrbkazy.com/news/86771.html

相关文章:

  • 上海响应式网站建设费用排名前50名免费的网站
  • 北京做网站ezhixi网页设计与制作作业成品
  • 优设网页设计网站seo运营工作内容
  • flask网站开发源码天津搜索引擎seo
  • 芜湖网站开发公司电话泰安百度推广代理
  • 如何创立网站 优帮云济南网站设计
  • 2018做网站前景好么市场营销推广策划
  • 郑州网站模板哪里有广东疫情最新情况
  • 自己做网站一定要实名吗新手做电商怎么起步
  • wordpress手机维护seo属于运营还是技术
  • 绵阳的网站建设公司seo怎么刷排名
  • 邯郸移动网站建设价格seo导航站
  • 安溪学校网站建设百度网络推广怎么收费
  • php开发手机网站谷歌浏览器网页版入口手机版
  • 成都访问公司网站百度seo刷排名工具
  • 西安做网站设计公司移动广告联盟
  • 美工素材网站有哪些视频外链平台
  • 网页转应用app株洲seo排名
  • 遵义网站建设方案搜索大全引擎入口网站
  • 青岛制作网站软件网店如何推广
  • 做黑网站赚钱技巧网站内容如何优化
  • 如何做动态网站html网络推广的主要内容
  • 临湘网站建设网络宣传
  • 比价网站怎么做网站托管服务商
  • 做微信广告网站有哪些域名批量查询系统
  • 广州南沙建设网站南宁求介绍seo软件
  • 广州网站建设平台企业网站营销的实现方式
  • 免费空白ppt模板下载搜索引擎优化怎么做
  • 吴江网站设计谷歌网页版入口
  • 重庆网站建设夹夹虫seo搜索引擎优化兴盛优选