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

网站建设 福田顶易云外贸软件

网站建设 福田,顶易云外贸软件,我的百度账号,福田网站建设运营费用时间序列预测#xff08;一#xff09;基于Prophet的销售额预测 小O#xff1a;小H#xff0c;有没有什么方法能快速的预测下未来的销售额啊 小H#xff1a;Facebook曾经开源了一款时间序列预测算法fbprophet#xff0c;简单又快速#xff5e; 传统的时间序列算法很多一基于Prophet的销售额预测 小O小H有没有什么方法能快速的预测下未来的销售额啊 小HFacebook曾经开源了一款时间序列预测算法fbprophet简单又快速 传统的时间序列算法很多例如AR、MA、ARIMA等对于非专业人员来说显得很难上手。而Prophet相对来说就友好多了而且预测效果又很不错所以用它来预测时间序列数据再适合不过了。本文主要参考基于facebook的时间序列预测框架prophet的实战应用。 Prophet的安装需要先安装pystan conda install pystan # 终端上安装需要执行procced选择ypip install fbprophet数据探索 import matplotlib.pyplot as plt import pandas as pd import numpy as np import seaborn as sns from fbprophet import Prophet from sklearn.metrics import mean_squared_error from math import sqrt import datetime from xgboost import XGBRegressor from sklearn.metrics import explained_variance_score, mean_absolute_error, \ mean_squared_error, r2_score # 批量导入指标算法from tensorflow.keras.models import Sequential from tensorflow.keras.layers import LSTM from tensorflow.keras.layers import Dense, Dropout from sklearn.preprocessing import MinMaxScaler from keras.wrappers.scikit_learn import KerasRegressor from sklearn.model_selection import GridSearchCV以下数据如果有需要的同学可关注公众号HsuHeinrich回复【数据挖掘-时间序列01】自动获取 # 读取数据 raw_data pd.read_csv(train.csv) raw_data.head()# 转化为日期 raw_data[datetime] raw_data[datetime].apply(pd.to_datetime)# 查看历史销售趋势 plt.figure(figsize (15,8)) sns.lineplot(x datetime, y count, data raw_data, err_styleNone) plt.show()特征工程 # 构造prophet需要的ds/y数据 df_model raw_data[[datetime, count]].rename(columns {datetime: ds,count: y})模型拟合 # 模型拟合 model_fb Prophet(interval_width 0.95).fit(df_model) # 构造预测日期 future_dates model_fb.make_future_dataframe(periods 100, freqH) # 预测结果 forecast model_fb.predict(future_dates)INFO:fbprophet:Disabling yearly seasonality. Run prophet with yearly_seasonalityTrue to override this.# 预测最后几周的日期 forecast[[ds, yhat, yhat_lower, yhat_upper]].tail()结果展示 # 观察预测效果 model_fb.plot(forecast);# 观察趋势因素 model_fb.plot_components(forecast);# 模型评估 MSE metric_df forecast.set_index(ds)[[yhat]].join(df_model.set_index(ds).y).reset_index() metric_df.dropna(inplaceTrue) error mean_squared_error(metric_df.y, metric_df.yhat) print(The MSE is {}. format(error))The MSE is 12492.842870220222添加假期因素 # 定义假期因素 def is_school_holiday_season(ds): date pd.to_datetime(ds)starts datetime.date(date.year, 7, 1)ends datetime.date(date.year, 9, 9)return starts date.to_pydatetime().date() endsdf_model[school_holiday_season] df_model[ds].apply(is_school_holiday_season) df_model[not_school_holiday_season] ~df_model[ds].apply(is_school_holiday_season) model_fb Prophet(interval_width0.95)# 添加假期因素 model_fb.add_seasonality(nameschool_holiday_season, period365, fourier_order3, condition_nameschool_holiday_season) model_fb.add_seasonality(namenot_school_holiday_season, period365, fourier_order3, condition_namenot_school_holiday_season) model_fb.fit(df_model)INFO:fbprophet:Disabling yearly seasonality. Run prophet with yearly_seasonalityTrue to override this.fbprophet.forecaster.Prophet at 0x7ff4e48833d0# 构造日期 future_dates model_fb.make_future_dataframe(periods100, freqH) future_dates[school_holiday_season] future_dates[ds].apply(is_school_holiday_season) future_dates[not_school_holiday_season] ~future_dates[ds].apply(is_school_holiday_season)# 预测 forecast model_fb.predict(future_dates)plt.figure(figsize(10, 5)) model_fb.plot(forecast);Figure size 720x360 with 0 Axes# 观察趋势因素 model_fb.plot_components(forecast); # 模型评估 MSE metric_df forecast.set_index(ds)[[yhat]].join(df_model.set_index(ds).y).reset_index() metric_df.dropna(inplaceTrue) error mean_squared_error(metric_df.y, metric_df.yhat) print(The MSE is {}. format(error))The MSE is 12431.431390456968添加假期因素后预测上没有提升。这里只是介绍如何增加自定义趋势因素而已所以没有提升在预期之内 总结 当你只需要预测数据时只需简单的两列dsy即可整个预测过程简单易上手 共勉
http://www.hkea.cn/news/14288716/

相关文章:

  • 青岛网站建设培训重点专业建设验收网站
  • 网站分辨率seo服务如何收费
  • 免费下载ppt模板的网站有哪些上海网站建设制作微信
  • 小韩网站源码红色网站建设的比较好的高校
  • 网站做的支付宝接口一些有趣的网站
  • 福田企业网站优化排名要看网站是多少
  • 做网站用上面软件写代码比较好中小企业查询官网
  • 南平企业网站建设免费在线咨询软件
  • 百度网站建设公司无锡网站建设 君通科技
  • 中山市路桥建设有限公司网站asp源码-漂亮企业源码大气公司网站模版
  • 网站分站作用网站开发确认书
  • 网站建设专家是干嘛的昆明电商网站建设
  • 修改网站参数用什么工具做网站
  • 东莞商城网站建设哪里比较好wordpress 插件更新
  • 青岛市黄岛区城市建设局网站企业网站建设单位
  • 建设银行门户网站商城网站策划方案
  • 花店网站建设目的网站建设方案的重要性
  • 网站建设与运营的实训总结珠海网站建设 金蝶
  • 自己做的网站被黑了怎么办wordpress更改主题背景
  • 建立网站的目的和功能淄博网站文章优化
  • 做海报找背景图有哪些网站市场营销策划公司排名
  • 深圳网站设计推广崇信县门户网站官网
  • 建个微网站多少钱唐山网站优化
  • 公司长沙建站广州公司注册名字查询
  • 谁用腾讯风铃做网站的珠海附近交友平台软件
  • 用织梦做的公司网站 经常被攻击wordpress 公告插件
  • 行业网站排名查询wordpress调用导航代码
  • 手机怎么制作网站教程视频教程简易手机app制作教程
  • 合肥手机网站建设现在很多网站都是wordpress
  • 哪种网站开发简单传奇免费网站模板下载