• 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
  • 相关阅读:
    群晖docker实现IPV6访问
    数说故事亮相CPG第八届中国消费品数字科技大会
    SpringBoot+自定义注解+AOP高级玩法打造通用开关
    K8S创建CRD yaml示例
    windows上Qt5.15+openssl1.1.1+msvs2022静态编译32位版本的笔记
    百度隐藏“快照”功能:原因未知
    BLE架构与开源协议栈
    GBase 8c 创建和管理Schema (三)
    K3s离线部署
    typora整理markdown笔记
  • 原文地址:https://blog.csdn.net/shanglianlm/article/details/126341497