資源簡(jiǎn)介
臉書預(yù)言家開源項(xiàng)目,prophet python模塊 fbprophet和pystan。現(xiàn)在網(wǎng)上的教程基本都不能成功安裝。本人僥幸安裝成功。把pip包中的兩個(gè)模塊上傳。大家下載后可以直接導(dǎo)入python安裝目錄下的模塊目錄site-packages下即可使用兩個(gè)模塊。預(yù)言者神器預(yù)測(cè)很給力
代碼片段和文件信息
#?-*-?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?????????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?=
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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個(gè)文件信息
評(píng)論
共有 條評(píng)論