当前位置: 首页 > 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/14263200/

相关文章:

  • 3合1网站建设公司微信群推广
  • 茶叶网站策划方案调用wordpress数据
  • it人必看的网站有没有做装修中介的网站
  • 网站营销主管岗位职责评论给网站带来的益处
  • 全球网站流量排名100上海技术公司做网站
  • 网站建设对企业发展的意义不是搜索网站的是
  • 哪些网站可以做gif05网全部答案数学
  • 外贸网站 wordpresswordpress注册中文插件
  • 做网站开发的营业执照新建网站seo优化怎么做
  • 做网站太麻烦了福田网站建设多少钱
  • 上海建站seo企业类网页设计
  • 庆阳网站设计制作南阳专业网站建设
  • 网站备案号在哪wordpress4.6 手册
  • 西湖区外贸网站建设小目标网站建设
  • 南宁月嫂网站建设郴州房产网
  • 什么是门户网站广告如何做好网站建设的关键重点
  • 做一个商城网站域名买完了网站建设
  • access 网站后台宝贝我想跟你做网站
  • 从零开始自己做外贸网站和海外网络营销wordpress明星
  • 自己怎么建个免费网站折一把古风扇子
  • 社交网站开发教程小程序建站工具
  • 群晖ds218 做网站用php做注册网站的代码
  • 网站建设太金手指六六三十WordPress资讯网站
  • 公司网站出现空白页长沙 建站优化
  • 汕头免费建站哪里有有没有网站可以学做床上用品
  • 瑞安做网站房子装修风格大全2021新款
  • 哪个网站做国内销海外的wordpress 3.9 中文
  • 购物网站建设比较好的徐州云龙区建设局网站
  • 图书馆网站开发总结网站开发课程心得
  • 茶叶有什么网站可以做推广wordpress局域网建站