From f16e22731f476a23961f4671e1692656ecf44220 Mon Sep 17 00:00:00 2001 From: Mpho Mphego Date: Fri, 21 Dec 2018 01:33:23 +0200 Subject: [PATCH] Update and rename README to README.md and Unicode strings (#766) * Update and rename README to README.md and Unicode strings Updated Readme file and converted from rst to markdown. String contains ascii characters (converted to unicode string) Signed-off-by: Mpho Mphego mpho112@gmail.com * Deprecated import `from __future__ import unicode_literals` removed and ran isort module https://mail.python.org/pipermail/python-dev/2016-December/147009.html Included setuptool-git in the requirement.txt and updated `setup.py` Reasons for this are highlighted here -> https://github.com/msabramo/setuptools-git#usage --- python/README | 46 ------------------------------- python/README.md | 38 +++++++++++++++++++++++++ python/fbprophet/diagnostics.py | 8 ++---- python/fbprophet/forecaster.py | 32 ++++++++------------- python/fbprophet/hdays.py | 17 ++++++------ python/fbprophet/make_holidays.py | 14 +++++----- python/fbprophet/models.py | 7 ++--- python/fbprophet/plot.py | 6 ++-- python/requirements.txt | 1 + python/setup.py | 4 ++- 10 files changed, 77 insertions(+), 96 deletions(-) delete mode 100644 python/README create mode 100644 python/README.md diff --git a/python/README b/python/README deleted file mode 100644 index a3462be..0000000 --- a/python/README +++ /dev/null @@ -1,46 +0,0 @@ -Prophet: Automatic Forecasting Procedure -======================================== - -Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well. - -Prophet is `open source software `_ released by Facebook's `Core Data Science team `_. - -Full documentation and examples available at the homepage: https://facebook.github.io/prophet/ - -Important links ---------------- - -- HTML documentation: https://facebook.github.io/prophet/docs/quick_start.html -- Issue tracker: https://github.com/facebook/prophet/issues -- Source code repository: https://github.com/facebook/prophet -- Implementation of Prophet in R: https://cran.r-project.org/package=prophet - - -Other forecasting packages --------------------------- - -- Rob Hyndman's `forecast package `_ -- `Statsmodels `_ - - -Installation ------------- - -:: - - $ pip install fbprophet - - -Note: Installation requires PyStan, which has its `own installation instructions `_. On Windows, PyStan requires a compiler so you'll need to `follow the instructions`_. The key step is installing a recent `C++ compiler `_. - -Example usage -------------- - -:: - - >>> from fbprophet import Prophet - >>> m = Prophet() - >>> m.fit(df) # df is a pandas.DataFrame with 'y' and 'ds' columns - >>> future = m.make_future_dataframe(periods=365) - >>> m.predict(future) - diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000..19de97f --- /dev/null +++ b/python/README.md @@ -0,0 +1,38 @@ +# Prophet: Automatic Forecasting Procedure + +Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well. + +Prophet is [open source software](https://code.facebook.com/projects/>) released by [Facebook's Core Data Science team ](https://research.fb.com/category/data-science/). + +Full documentation and examples available at the homepage: https://facebook.github.io/prophet/ + +## Important links + +- HTML documentation: https://facebook.github.io/prophet/docs/quick_start.html +- Issue tracker: https://github.com/facebook/prophet/issues +- Source code repository: https://github.com/facebook/prophet +- Implementation of Prophet in R: https://cran.r-project.org/package=prophet + +## Other forecasting packages + +- Rob Hyndman's [forecast package](http://robjhyndman.com/software/forecast/) +- [Statsmodels](http://statsmodels.sourceforge.net/) + +## Installation + +```shell +pip install fbprophet +``` +Note: Installation requires PyStan, which has its [own installation instructions](http://pystan.readthedocs.io/en/latest/installation_beginner.html). +On Windows, PyStan requires a compiler so you'll need to [follow the instructions](http://pystan.readthedocs.io/en/latest/windows.html). + The key step is installing a recent [C++ compiler](http://landinghub.visualstudio.com/visual-cpp-build-tools) + +### Example usage + +```python + >>> from fbprophet import Prophet + >>> m = Prophet() + >>> m.fit(df) # df is a pandas.DataFrame with 'y' and 'ds' columns + >>> future = m.make_future_dataframe(periods=365) + >>> m.predict(future) + ``` diff --git a/python/fbprophet/diagnostics.py b/python/fbprophet/diagnostics.py index 1608fcf..f3d6896 100644 --- a/python/fbprophet/diagnostics.py +++ b/python/fbprophet/diagnostics.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # @@ -5,14 +6,11 @@ # 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 -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function +import logging from copy import deepcopy from functools import reduce -import logging import numpy as np import pandas as pd diff --git a/python/fbprophet/forecaster.py b/python/fbprophet/forecaster.py index 7c7399c..e800f38 100644 --- a/python/fbprophet/forecaster.py +++ b/python/fbprophet/forecaster.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # @@ -5,31 +6,22 @@ # 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 -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function -from collections import defaultdict, OrderedDict -from datetime import timedelta import logging +from collections import OrderedDict, defaultdict +from datetime import timedelta + import numpy as np import pandas as pd import pystan # noqa F401 - from fbprophet.diagnostics import prophet_copy -from fbprophet.models import prophet_stan_model from fbprophet.make_holidays import get_holiday_names, make_holidays_df -from fbprophet.plot import ( - plot, - plot_components, - plot_forecast_component, - seasonality_plot_df, - plot_weekly, - plot_yearly, - plot_seasonality, -) +from fbprophet.models import prophet_stan_model +from fbprophet.plot import (plot, plot_components, plot_forecast_component, + plot_seasonality, plot_weekly, plot_yearly, + seasonality_plot_df) logger = logging.getLogger('fbprophet') logger.addHandler(logging.NullHandler()) @@ -420,14 +412,14 @@ class Prophet(object): def construct_holiday_dataframe(self, dates): """Construct a dataframe of holiday dates. - + Will combine self.holidays with the built-in country holidays corresponding to input dates, if self.country_holidays is set. - + Parameters ---------- dates: pd.Series containing timestamps used for computing seasonality. - + Returns ------- dataframe of holiday dates, in holiday dataframe format used in diff --git a/python/fbprophet/hdays.py b/python/fbprophet/hdays.py index 2ed33ad..11ae456 100644 --- a/python/fbprophet/hdays.py +++ b/python/fbprophet/hdays.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # @@ -5,17 +6,15 @@ # 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 -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function -from holidays import HolidayBase, MONDAY, WEEKEND, rd, easter -from lunardate import LunarDate +import warnings from calendar import Calendar from datetime import date, timedelta -from convertdate.islamic import to_gregorian, from_gregorian -import warnings + +from convertdate.islamic import from_gregorian, to_gregorian +from holidays import MONDAY, WEEKEND, HolidayBase, easter, rd +from lunardate import LunarDate # Official public holidays at a country level @@ -927,7 +926,7 @@ class Turkey(HolidayBase): self[date(year, 5, 1)] = name # Commemoration of Atatürk, Youth and Sports Day - name = "Commemoration of Atatürk, Youth and Sports Day" + name = u"Commemoration of Atatürk, Youth and Sports Day" self[date(year, 5, 19)] = name # Democracy and National Unity Day diff --git a/python/fbprophet/make_holidays.py b/python/fbprophet/make_holidays.py index 9d6c780..870feb6 100644 --- a/python/fbprophet/make_holidays.py +++ b/python/fbprophet/make_holidays.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # @@ -5,16 +6,15 @@ # 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 -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function -import pandas as pd -import numpy as np import warnings -import holidays as hdays_part1 + +import numpy as np +import pandas as pd + import fbprophet.hdays as hdays_part2 +import holidays as hdays_part1 def get_holiday_names(country): diff --git a/python/fbprophet/models.py b/python/fbprophet/models.py index 3cdb6e4..55dca0f 100644 --- a/python/fbprophet/models.py +++ b/python/fbprophet/models.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # @@ -5,12 +6,10 @@ # 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 -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function import pickle + import pkg_resources diff --git a/python/fbprophet/plot.py b/python/fbprophet/plot.py index 358b399..020696d 100644 --- a/python/fbprophet/plot.py +++ b/python/fbprophet/plot.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # @@ -5,10 +6,7 @@ # 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 -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals +from __future__ import absolute_import, division, print_function import logging diff --git a/python/requirements.txt b/python/requirements.txt index cf6a9ce..86aa7ae 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -6,3 +6,4 @@ matplotlib>=2.0.0 lunardate>=0.1.5 convertdate>=2.1.2 holidays>=0.9.5 +setuptools-git>=1.2 \ No newline at end of file diff --git a/python/setup.py b/python/setup.py index 71e8472..4db66c4 100644 --- a/python/setup.py +++ b/python/setup.py @@ -10,6 +10,7 @@ from pkg_resources import ( require, ) from setuptools import setup +# from setuptools import setup, find_packages from setuptools.command.build_py import build_py from setuptools.command.develop import develop from setuptools.command.test import test as test_command @@ -104,12 +105,13 @@ setup( author='Sean J. Taylor , Ben Letham ', author_email='sjt@fb.com', license='BSD', + # packages=find_packages(), packages=['fbprophet', 'fbprophet.tests'], setup_requires=[ ], install_requires=install_requires, zip_safe=False, - include_package_data=True, + # include_package_data=True, # For Python 3, Will enforce that tests are run after a build. use_2to3=True, cmdclass={