fbprophet安装及使用笔记

先行安装Anaconda以及pycharm

fbprophet安装步骤
安装步骤:
1.创建一个虚拟环境: conda create 虚拟环境名 python=3.6.6(python3.7也可以)
2.激活虚拟环境:activate 虚拟环境名
3.安装MingW-w64编译器类型:conda install libpython m2w64-toolchain -c msys2
4.检查你的虚拟环境路径下\Lib\distutils中是否有distutils.cfg文件,如果没有就手动创建一个
5.conda install numpy cython -c conda-forge
6.conda install matplotlib scipy pandas -c conda-forge
7.conda install pystan -c conda-forge
8.conda install fbprophet -c conda-forge
Anaconda镜像设置步骤
修改用户目录下的 .condarc 文件:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

即可添加 Anaconda Python 免费仓库。Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。
注:.condarc文件地址在C:\Users\windows用户名路径下

pycharm编译器设置
file->settings->project->project intepreter->add->existing environment->
路径为:C:\Users\windows用户名\Anaconda3\envs\虚拟环境名\Tools->python.exe

error
ERROR:fbprophet:Importing plotly failed. Interactive plots will not work.
SOLUTION:conda install plotly

官网案例

import pandas as pd
from fbprophet import Prophet
import matplotlib.pyplot as plt
df = pd.read_csv('example_wp_log_peyton_manning.csv')
df.head()
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=365)
future.tail()
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
fig1 = m.plot(forecast)
plt.show()
fig2 = m.plot_components(forecast)
plt.show()
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值