资源简介
fbprophet免安装包, 如图为作者将服务器中的fbprophet包直接拷贝到Win10系统中,经测试有效。
有需要的直接百度云下载就可以了,下载后解压到python的包的路径下“site-packages”这个文件夹下面
代码片段和文件信息
# -*- coding: utf-8 -*-
# Copyright (c) 2017-present Facebook Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
from __future__ import absolute_import division print_function
import logging
from copy import deepcopy
from functools import reduce
import numpy as np
import pandas as pd
logger = logging.getLogger(‘fbprophet‘)
def generate_cutoffs(df horizon initial period):
“““Generate cutoff dates
Parameters
----------
df: pd.Dataframe with historical data.
horizon: pd.Timedelta forecast horizon.
initial: pd.Timedelta window of the initial forecast period.
period: pd.Timedelta simulated forecasts are done with this period.
Returns
-------
list of pd.Timestamp
“““
# Last cutoff is ‘latest date in data - horizon‘ date
cutoff = df[‘ds‘].max() - horizon
if cutoff < df[‘ds‘].min():
raise ValueError(‘Less data than horizon.‘)
result = [cutoff]
while result[-1] >= min(df[‘ds‘]) + initial:
cutoff -= period
# If data does not exist in data range (cutoff cutoff + horizon]
if not (((df[‘ds‘] > cutoff) & (df[‘ds‘] <= cutoff + horizon)).any()):
# Next cutoff point is ‘last date before cutoff in data - horizon‘
if cutoff > df[‘ds‘].min():
closest_date = df[df[‘ds‘] <= cutoff].max()[‘ds‘]
cutoff = closest_date - horizon
# else no data left leave cutoff as is it will be dropped.
result.append(cutoff)
result = result[:-1]
if len(result) == 0:
raise ValueError(
‘Less data than horizon after initial window. ‘
‘Make horizon or initial shorter.‘
)
logger.info(‘Making {} forecasts with cutoffs between {} and {}‘.format(
len(result) result[-1] result[0]
))
return reversed(result)
def cross_validation(model horizon period=None initial=None):
“““Cross-Validation for time series.
Computes forecasts from historical cutoff points. Beginning from
(end - horizon) works backwards making cutoffs with a spacing of period
until initial is reached.
When period is equal to the time interval of the data this is the
technique described in https://robjhyndman.com/hyndsight/tscv/ .
Parameters
----------
model: Prophet class object. Fitted Prophet model
horizon: string with pd.Timedelta compatible style e.g. ‘5 days‘
‘3 hours‘ ‘10 seconds‘.
period: string with pd.Timedelta compatible style. Simulated forecast will
be done at every this period. If not provided 0.5 * horizon is used.
initial: string with pd.Timedelta compatible style. The first training
period will begin h
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-08-02 15:06 fbprophet-0.5.dist-info\
文件 4 2019-08-02 15:06 fbprophet-0.5.dist-info\INSTALLER
文件 953 2019-08-02 15:06 fbprophet-0.5.dist-info\me
文件 629 2019-08-02 15:06 fbprophet-0.5.dist-info\PKG-INFO~
文件 2088 2019-08-02 15:06 fbprophet-0.5.dist-info\RECORD
文件 11 2019-08-02 15:06 fbprophet-0.5.dist-info\top_level.txt
文件 93 2019-08-02 15:06 fbprophet-0.5.dist-info\WHEEL
目录 0 2019-08-02 15:06 fbprophet\
文件 369 2019-08-02 15:05 fbprophet\__init__.py
目录 0 2019-08-02 15:06 fbprophet\__pycache__\
文件 222 2019-08-02 15:06 fbprophet\__pycache__\__init__.cpython-35.pyc
文件 12845 2019-08-02 15:06 fbprophet\__pycache__\diagnostics.cpython-35.pyc
文件 48035 2019-08-02 15:06 fbprophet\__pycache__\forecaster.cpython-35.pyc
文件 29347 2019-08-02 15:06 fbprophet\__pycache__\hdays.cpython-35.pyc
文件 1937 2019-08-02 15:06 fbprophet\__pycache__\make_holidays.cpython-35.pyc
文件 624 2019-08-02 15:06 fbprophet\__pycache__\models.cpython-35.pyc
文件 20000 2019-08-02 15:06 fbprophet\__pycache__\plot.cpython-35.pyc
文件 15178 2019-08-02 15:05 fbprophet\diagnostics.py
文件 62216 2019-08-02 15:05 fbprophet\forecaster.py
文件 42219 2019-08-02 15:05 fbprophet\hdays.py
文件 2196 2019-08-02 15:05 fbprophet\make_holidays.py
文件 748 2019-08-02 15:05 fbprophet\models.py
文件 24335 2019-08-02 15:05 fbprophet\plot.py
目录 0 2019-08-02 15:05 fbprophet\stan_model\
文件 25946888 2019-08-02 15:06 fbprophet\stan_model\prophet_model.pkl
目录 0 2019-08-02 15:06 fbprophet\tests\
文件 0 2019-08-02 15:05 fbprophet\tests\__init__.py
目录 0 2019-08-02 15:06 fbprophet\tests\__pycache__\
文件 146 2019-08-02 15:06 fbprophet\tests\__pycache__\__init__.cpython-35.pyc
文件 8466 2019-08-02 15:06 fbprophet\tests\__pycache__\test_diagnostics.cpython-35.pyc
文件 22197 2019-08-02 15:06 fbprophet\tests\__pycache__\test_prophet.cpython-35.pyc
............此处省略4个文件信息
评论
共有 条评论