机器学习笔记一-----------------Prophet(时间序列模型)的安装及简单例程

Anaconda下 --- fbprophet库的安装 💛环境:windows10、python3.8 💦平台:jupyter lab 阅读详情
AI摘要

本文详述了在Windows和Linux环境下配置Prophet的时间序列模型,包括创建Python虚拟环境、设置国内镜像源、安装Prophet及其依赖。通过实例展示了Prophet在Python中的使用,如数据预处理、模型训练、预测及结果分析。同时,讨论了Prophet适用于有明显季节性和趋势变化的时间序列数据,并提供了饱和预测和饱和减少的案例。文章还强调了Prophet在处理大规模数据、缺失值和灵活调整季节性等方面的优势。

一,windows下配置Prophet

1,创建python3.7的环境

1)首先在所在系统中安装Anaconda。可以打开命令行输入conda -V检验是否安装以及当前conda的版本。

2)conda list 查看安装了哪些包

3)创建Python虚拟环境。

使用 conda create -n your_env_name python=X.X(2.7、3.6等) anaconda 命令创建python版本为X.X、名字为your_env_name的虚拟环境。your_env_name文件可以在Anaconda安装目录envs文件下找到。

 4) conda create -n Prophet python=3.7

验证是否安装正确,参照下图即可

检查python的版本

python --version

5)需要移除创建的环境的方法

  • 移除环境

   使用命令conda remove -n your_env_name(虚拟环境名称) --all, 即可删除。

  • 删除环境中的某个包。

   使用命令conda remove --name $your_env_name  $package_name 即可。

6)设置国内镜像

如果需要安装很多packages,你会发现conda下载的速度经常很慢,因为Anaconda.org的服务器在国外。所幸的是,清华TUNA镜像源有Anaconda仓库的镜像,我们将其加入conda的配置即可:

1

2

3

4

5

6

# 添加Anaconda的TUNA镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

# TUNA的help中镜像地址加有引号,需要去掉

# 设置搜索时显示通道地址

conda config --set show_channel_urls yes

2, Prophet(时间序列模型)的配置

pip install pystan==2.19.1.1

conda install -c conda-forge fbprophet

 等更新完conda后,再输入:

conda install -c conda-forge fbprophet

运行出现错误,执行下面一句

参考博文:

Windows平台下安装prophet_iwtbs_kevin的博客-CSDN博客_prophet安装

Python机器学习008:安装prophet走过的坑_布衣书生-Python的博客-CSDN博客

安装是否成功测试

import numpy as np
import pandas as pd
from scipy import stats
import statsmodels.api as sm
import matplotlib.pyplot as plt
from fbprophet import Prophet
from fbprophet.diagnostics import cross_validation
from fbprophet.plot import plot_cross_validation_metric
from fbprophet.diagnostics import performance_metrics

导入以

facebook-Prophet时序预测实战(附代码) 关于prophet库的安装参考Windows平台下安装prophet,linux平台下一般没什么问题,直接用pip就可以。本文安装的fbprophet包版本为0.4.0(最新版本) 简介 输入到prophet中的数据要求是Dataframe类型,时间列的标签要命名为 ds ,数据列的标签需要命名为 y (命名一定要是ds,y否则无法通过编译) 引用模块 import pandas as ... 阅读详情

相关推荐

Python安装fbprophet包

最初在notebook中想运行这样一段代码 from fbprophet import Prophet 但是遇到了非常多错误(最后是使用的conda下载的fbprophet 包,不清楚我前面升级的pip到底有没有帮助,可以直接从pystan库开始尝试) 首先,pip版本需要是最新版20.3.1 在线更新pip python -m pip install --upgrade pip 强制升级是,python -m pip install -U --force-reinstall pip 如果是把pip卸载,p

wuyanne的博客 5603

prophet模型预测时间序列

prophet模型预测时间序列 prophet:facebook开源的的一个时间序列预测算法。 原理:基于时间序列分解和机器学习的拟合来做的。 把时间序列 分成不同时间间隔 和 整体趋势的组合。 间隔: 年 季度 月 周 日 介绍一个开源数据库-Quandl 库 注册网站: https://data.nasdaq.com/ 注册完之后,在你的个界面找到API pip install quandl 从quandl库中免费提取出特斯拉 和 通用 股票的数据 import quandl i

weixin_46969441的博客 1万+

时序预测工具库(Prophet)介绍+代码

时序预测工具库(Prophet)一、Prophet 简介二、Prophet 适用场景三、Prophet 算法的输入输出四、Prophet 算法原理六、代码6.1 依赖安装6.2 预测demo6.3 效果图七、参考资料八、官方链接:九、案例链接: 项目地址: https://aistudio.baidu.com/aistudio/projectdetail/525311?channelType=0&channel=0 参考内容: 时间序列模型Prophet使用详细讲解 初识Prophet模型(一)--

SeafyLiang的博客 4万+

时间序列预测算法---Prophet

本文探讨了Prophet算法在时间序列预测中的应用,分析了其优势及适用场景。通过实际数据验证,Prophet在处理季节性、趋势变化等方面表现出色,预测精度高。文章为时间序列预测领域提供了一种高效、实用的方法,对相关研究和实践具有指导意义。

u012121721的博客 1万+

【Python】使用Python+Prophet 实现时间序列分析

创作背景:Prophet是一个由Facebook开发的时间序列分析工具,早期是用来分析网页点击行为规律。在实际工作中,我把它延申应用到分析网约车订单的出行规律中。提示:以下是本篇文章正文内容,下面案例可供参考以上就是今天要讲的内容,本文仅仅简单介绍了python+Prophet 实现用时间序列模型分析出行规律的方法,更多的应用场景还需要大家自己探索和实践。记住:能看懂多少不重要,勇敢的迈出第一步才是最重要的。打工人,加油!

steven521427的博客 1978

【时间序列】Prophet使用

目录1 Prophet 的安装2 快速上手3 预测值的上下限 1 Prophet 的安装 按照官网的指导安装就可以。 一开始我用的是pip install fbprophet,不过提示我Microsoft Visual C++ 14.0 is required。然后我就去安装了Microsoft Visual Studio。安装完成之后,我试了用conda install -c conda-forge fbprophet。然后就安装好了。 我也不知道是不是因为安装了C++,所以conda 安装就很顺利。不

qq_41103204的博客 1853

机器学习笔记五-----------------Prophet(时间序列模型)的保存及调用,微调及总结

可以保存已安装的 Prophet 模型,以便以后加载和使用。 一,模型的保存 在 Python 中,模型使用内置的序列化函数将模型序列化为 json: import json from prophet.serialize import model_to_json, model_from_json with open('serialized_model.json', 'w') as fout: json.dump(model_to_json(m), fout) # Save model

YOULANSHENGMENG的博客 5091

Prophet时间序列天气预测完整项目实战

简介:本项目结合了时间序列分析与Facebook的Prophet库,旨在为学习者提供一个使用Prophet进行天气预测的完整实践平台。项目包含详尽的数据集与源代码,涵盖了时间序列预测模型的学习与应用。时间序列分析能处理具有时间依赖性的数据,并通过Prophet模型分解出趋势、季节性和残差,以提高预测精度。源代码包括数据预处理、模型训练、预测和评估等关键步骤,并特别关注了异常值处理与节假日效应。实践者将通过调整模型参数来优化预测结果,如调整季节性强度或添加自定义模式。

weixin_36012152的博客 902

Python+Vue计算机毕业设计风电场监控系统的设计与实现7bd6i(程序+LW+源码+部署)

Python3.7.7+Django+Mysql5.7+pip list+HBuilderX(Vscode也行)+Vue+Pychram社区版。2. 前端:vue+css+javascript+jQuery+easyUI+highcharts。2.IDE环境:Python和Python 社区版都可以。Django + Vue +Python+Mysql 等等组成,B/S模式等等。该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程。1. 后端:Python、Vue、Django、Mysql。

华信计算机毕设源码程序 344

通过声音识别鸟类

根据野生鸟类的外表来识别它是一回事。仅仅根据声音来识别同一只鸟是另一回事。除非你是一个熟练的观鸟者,通过声音识别鸟类可能相当具有挑战性德国马尔堡大学的一组数学、计算机科学和生物学研究人员设计了一种快速识别鸟类和监测当地生物多样性的方法。他们使用连接到 NVIDIA 的便携式设备拍摄的录音根据研究人员的说法是一个边缘人工智能系统,“基于分布式系统中运行的嵌入式边缘设备,能够对森林中记录的声景进行高效、连续的评估。”要了解更多信息,请参阅。

分享AI前沿科技 1680

STM32 SAES硬件加密协处理器全模式工程实践指南

AES(高级加密标准)是嵌入式系统中最基础且关键的对称密码算法,其硬件加速实现直接影响安全、性能与功耗平衡。Secure AES Coprocessor(SAES)作为STMicroelectronics在STM32U5等高安全MCU中集成的专用密码协处理器,不仅支持标准ECB/CBC/CTR模式,更原生兼容GCM和CCM等认证加密模式,具备抗侧信道、密钥保护与DMA卸载能力。理解其寄存器状态机(CHMOD/MODE/CPHASE)、NPBLB数据对齐机制及GCM四阶段编程范式,是规避Tag校验失败、IV错

weixin_42311427的博客 80

Sinutrain下载安装与开启OPC UA---kalrry

Sinutrain 开启 OPC UA 本教程只适用于版本,其他版本配置目录有所改变建议安装到默认路径,否则后期修改路径时候容易忽略细节本教程提供安装包为官方包,网上有些非官方包安装后容易出现授权问题,比如授权管理器无法启动,官方技术会建议你重装系统,很多时候是因为安装包非官方包在首次安装前,建议重启一遍系统。

kalrry 1万+

2023电赛B题实战解析:基于立创天空星开发板的同轴线缆长度与负载测量系统

本文详细解析了2023年全国大学生电子设计竞赛B题的实战方案,重点介绍了基于立创EDA天空星开发板(STM32F103)的同轴线缆长度与负载测量系统。文章深入剖析了两种核心测量方案,并推荐了更稳定易实现的NE555测电容法,提供了从硬件选型、电路设计到软件编程、参数标定的完整“施工图”,实测精度可达厘米级和皮法级,为电赛复现与高精度测量学习提供了清晰指导。

weixin_36303305的博客 235

GJB设计开发各阶段的文件和记录要求

GJB设计开发各阶段的文件和记录要求

Abel的博客 4063

麻辣香锅病毒分析

Spicy Hot Pot浏览器劫持病毒(麻辣香锅病毒)从2020年初被安全公司监测到,因其病毒模块带有MLXG_KM被安全行业代称麻辣香锅病毒。目前通过各种激活工具传播, 包括暴风激活、小马激活和KMS激活等诸多工具,疑似与下载站进行合作推广此类激活工具。Spicy Hot Pot 是一个浏览器劫持 Rootkit,它会将用户的主页更改为指向恶意软件操作员控制的页面,此外还会将内存转储从机器上传到预定义的服务器,并结合本地更新功能以确保其保持更新。通常浏览器劫持者会通过更改用户主页的恶意可执行文件或注册表

不忘初心,护天下安全! 4797

ESP8266-Arduino网络编程实例-异步TCP客户端

本次实例将使用ESPAsyncTCP库实现一个简单的客户端。

视觉与物联智能 1742

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

上一篇: 线扫相机的行频计算方法
下一篇: 机器学习笔记二-----------------Prophet(时间序列模型)的复杂例程笔记及给jupyter添加多个python版本的kernel的方法
YOULANSHENGMENG
博客等级 码龄16年 3996粉丝 150原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值