zoukankan      html  css  js  c++  java
  • 时间序列预测线上充值数据

    1.获取2019-2020年每个月份的充值总额

    USE xchat;

    SELECT month(update_time) as month,sum(amount) FROM charge_record WHERE buss_type=0 and charge_status=2 and charge_prod_id IS NOT NULL AND year(update_time) = 2019 GROUP BY month (update_time)

    UNION

    SELECT month(update_time) as month,sum(amount) FROM charge_record WHERE buss_type=0 and charge_status=2 and charge_prod_id IS NOT NULL AND year(update_time) = 2020 GROUP BY month (update_time);

    运行结果如下:

    2.时间序列预测

    从上图可知2019年2月份数据相对于其余月份较为异常,因此剔除2019年1月份和2月份的数据

    步骤如下:

    1)取消科学计数法

    options(scipen = 200)

    2)存储数据

    3)生成时间序列

    t1=ts(t,start = c(2019,3),frequency = 12)

    含义:从2019年3月开始生成周期=12月的时间序列

    4)自回归建模

    t2=ar(t1)

    0.7739-自相关系数

    sigma^2 estimated-估计值方差

    5)利用predict预测未来半年的充值金额

    predict(t2,n.ahead = 6)

    pred表示预测值;se表示此次预测的标准差

    6)查看自回归模型的预测效果

    ts.plot(t1,predict(t2,n.ahead = 6)$pred,lty=c(1:2))

  • 相关阅读:
    Servlet学习总结,为理解SpringMVC底层做准备
    maven笔记
    初识Hadoop
    java8笔记: sorted()之正序倒序
    git push命令
    git clone新项目后如何拉取其他分支代码到本地
    Spring事务
    线程之间的转化状态
    Centos安装RabbitMq
    .net 中的AES加密解密
  • 原文地址:https://www.cnblogs.com/wanyuan/p/13107359.html
Copyright © 2011-2022 走看看