• NeuralProphet之一:安装与使用


    NeuralProphet之一:安装与使用

    论文PDF:NeuralProphet: Explainable Forecasting at Scale
    文档地址:https://neuralprophet.com/html/contents.html
    数据地址:https://github.com/ourownstory/neuralprophet-data
    示例地址:https://github.com/ourownstory/neural_prophet/tree/main/tutorials

    1 概述

    NeuralProphet模型集成了Prophet的所有优点,不仅具有不错的可解释性,还有优于Prophet的预测性能。

    • 梯度下降通过使用PyTorch作为后端进行优化。
    • 使用 AR-Net 对时间序列的自相关进行建模
    • 使用分离的前馈神经网络对滞后回归量进行建模。
    • 可配置的FFNN非线性深层。
    • 可调整为特定的预测范围(大于 1)。
    • 自定义损失和指标。

    2 安装

    pip install neuralprophet
    
    • 1

    3 使用

    导入包:

    from neuralprophet import NeuralProphet
    
    • 1

    调用:

    m = NeuralProphet()
    metrics = m.fit(df)
    forecast = m.predict(df)
    
    • 1
    • 2
    • 3

    可视化结果:

    fig_forecast = m.plot(forecast)
    fig_components = m.plot_components(forecast)
    fig_model = m.plot_parameters()
    
    • 1
    • 2
    • 3

    预测:

    m = NeuralProphet().fit(df, freq="D")
    df_future = m.make_future_dataframe(df, periods=30)
    forecast = m.predict(df_future)
    fig_forecast = m.plot(forecast)
    
    • 1
    • 2
    • 3
    • 4

    4 Hyperparameters

    ParameterDefault Value说明备注
    growthlinear
    changepointsNone手动设置改变点
    n_changepoints5控制趋势灵活度
    changepoints_range0.8默认值0.8,表示后20%的训练数据无changepoints
    trend_reg0趋势正则项
    trend_reg_thresholdFalse
    yearly_seasonalityauto默认6
    weekly_seasonalityauto默认 4
    daily_seasonalityauto默认6
    seasonality_modeadditiveadditive,multiplicative
    seasonality_reg0值越大正则约束越大0.1-1或者1-100
    n_forecasts1预测范围,1意味着将来预测一步
    n_lags0定义是否使用AR-Net,n_lags决定AR-Net回看多少步,当n_lags>0时,建议取值大于n_forecasts
    num_hidden_layers0定义FFNNs的隐藏层数,0意味着只有一个隐藏层0,1,2
    d_hiddenNone隐藏层的单元数,如果未指定,默认为n_lags + n_forecastsn_lags 和 n_forecasts 之间
    ar_sparsityNone0完全稀疏,1无正则约束0-1
    learning_rateNone如果未指定,自动调整
    epochsNone如果未指定,根据数据大小设定
    batch_sizeNone
    loss_funcHuber如果未指定,根据数据大小设定Huber, MSE,torch.nn.modules.loss
    optimizerAdamWAdamW,SDG
    train_speedNone
    normalizeautomin-max normalization
    impute_missingTrue惩罚缺失值
    collect_metricsTrue默认计算mae 和 rmse
  • 相关阅读:
    Java IO: 使用 `FileInputStream` 和 `FileOutputStream` 进行文件操作
    golang八股文整理(持续搬运)
    k8s笔记 | StatefulSet 有状态
    线程概念,实现方式以及多线程模型
    跟TED演讲学英文:Entertainment is getting an AI upgrade by Kylan Gibbs
    构建坚固防线:提升网站整体安防水平的有效途径
    【计算机毕业设计】网上商城购物系统
    鲸选小试界,存量时代的新「金矿」
    基于Python实现Midjourney集成到(个人/公司)平台中
    浏览器LocalStorage和SharedWorker跨标签页通信-连载2
  • 原文地址:https://blog.csdn.net/shanglianlm/article/details/126341497