• 大小: 49.67MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-17
  • 语言: Python
  • 标签: prophe  fbprop  pystan  

资源简介

脸书预言家开源项目,prophet python模块 fbprophet和pystan。现在网上的教程基本都不能成功安装。本人侥幸安装成功。把pip包中的两个模块上传。大家下载后可以直接导入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‘
            closest_date = df[df[‘ds‘] <= cutoff].max()[‘ds‘]
            cutoff = closest_date - horizon
        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 here. If not provided 3 * horizon is used.

    Returns
    -------
    A pd.Dataframe with the forecast actual value and cutoff.
    “““
    df = model.history.copy().reset_index(drop=True)
    te =

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-03-20 23:05  prophet-python模块\
     目录           0  2019-03-20 22:59  prophet-python模块\fbprophet\
     文件         359  2019-01-17 09:10  prophet-python模块\fbprophet\__init__.py
     目录           0  2019-03-20 22:59  prophet-python模块\fbprophet\__pycache__\
     文件         198  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\__init__.cpython-36.pyc
     文件        9812  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\diagnostics.cpython-36.pyc
     文件       43954  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\forecaster.cpython-36.pyc
     文件       25745  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\hdays.cpython-36.pyc
     文件        1807  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\make_holidays.cpython-36.pyc
     文件         567  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\models.cpython-36.pyc
     文件       14909  2019-01-17 09:10  prophet-python模块\fbprophet\__pycache__\plot.cpython-36.pyc
     文件       11408  2019-01-17 09:10  prophet-python模块\fbprophet\diagnostics.py
     文件       58760  2019-01-17 09:10  prophet-python模块\fbprophet\forecaster.py
     文件       40874  2019-01-17 09:10  prophet-python模块\fbprophet\hdays.py
     文件        2127  2019-01-17 09:10  prophet-python模块\fbprophet\make_holidays.py
     文件         722  2019-01-17 09:10  prophet-python模块\fbprophet\models.py
     文件       17389  2019-01-17 09:10  prophet-python模块\fbprophet\plot.py
     目录           0  2019-03-20 22:59  prophet-python模块\fbprophet\stan_model\
     文件     1154156  2019-01-17 09:10  prophet-python模块\fbprophet\stan_model\prophet_model.pkl
     目录           0  2019-03-20 22:59  prophet-python模块\fbprophet\tests\
     文件           0  2019-01-17 09:10  prophet-python模块\fbprophet\tests\__init__.py
     目录           0  2019-03-20 22:59  prophet-python模块\fbprophet\tests\__pycache__\
     文件         128  2019-01-17 09:10  prophet-python模块\fbprophet\tests\__pycache__\__init__.cpython-36.pyc
     文件        6271  2019-01-17 09:10  prophet-python模块\fbprophet\tests\__pycache__\test_diagnostics.cpython-36.pyc
     文件       18716  2019-01-17 09:10  prophet-python模块\fbprophet\tests\__pycache__\test_prophet.cpython-36.pyc
     文件        8628  2019-01-17 09:10  prophet-python模块\fbprophet\tests\data.csv
     文件       21518  2019-01-17 09:10  prophet-python模块\fbprophet\tests\data2.csv
     文件        9040  2019-01-17 09:10  prophet-python模块\fbprophet\tests\test_diagnostics.py
     文件       26891  2019-01-17 09:10  prophet-python模块\fbprophet\tests\test_prophet.py
     目录           0  2019-03-20 22:59  prophet-python模块\fbprophet-0.4.post2.dist-info\
     文件           4  2019-01-17 09:10  prophet-python模块\fbprophet-0.4.post2.dist-info\INSTALLER
............此处省略32042个文件信息

评论

共有 条评论

相关资源