Skip to content

Commit

Permalink
Merge a882f6e into b12ff9b
Browse files Browse the repository at this point in the history
  • Loading branch information
tgsmith61591 committed Feb 12, 2018
2 parents b12ff9b + a882f6e commit c2d2fde
Show file tree
Hide file tree
Showing 26 changed files with 321 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Expand Up @@ -5,4 +5,4 @@ include = */pyramid/*
omit =
*/setup.py
*/__check_build/*
*/_build_utils/*
*/_build_utils/*
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -9,6 +9,9 @@
# Pypi pws
.pypipws

# Coverage
coverage

# OAuth access for automating releases
ACCESS_TOKEN

Expand Down
10 changes: 8 additions & 2 deletions .travis.yml
Expand Up @@ -11,7 +11,8 @@ cache:
- $HOME/.cache/pip
- $HOME/.ccache

before_install: source build_tools/travis/before_install.sh
before_install:
- source build_tools/travis/before_install.sh
env:
global:
- PYMODULE=pyramid
Expand Down Expand Up @@ -93,8 +94,13 @@ matrix:
install: source build_tools/travis/install.sh
before_script: bash build_tools/travis/before_script.sh
script: bash build_tools/travis/test_script.sh

# we set +e to re-instate the error-tolerant state. The problem is Travis is broken on Mac OS
# builds right now due to Issue 6307 (https://github.com/travis-ci/travis-ci/issues/6307)
# and fails at the end of a successful build. This will allow the build to recover even if
# a non-zero status code is encountered. (had `- set +e`)
after_success:
- source build_tools/travis/after_success.sh
- source build_tools/travis/after_success.sh # || echo "shell_session_update failed"
# Build the wheels every time so we can debug
- bash build_tools/travis/build_wheels.sh
- ls dist/
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.md
Expand Up @@ -5,6 +5,7 @@ The following people have been core contributors to `pyramid`'s development:
* [Taylor Smith](https://github.com/tgsmith61591)
* [Gary Foreman](https://github.com/garyForeman)
* [Charles Drotar](https://github.com/charlesdrotar)
* [Steven Hoelscher](https://github.com/shoelsch)

__Please do not email the authors directly with questions or issues.__ Rather, use
the [issues](https://github.com/tgsmith61591/pyramid/issues) page. Furthermore, issues
Expand Down
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
@@ -1,7 +1,7 @@
<!-- Instructions For Filing a Bug: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#filing-bugs -->

#### Description
<!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluate_every > 0-->
<!-- Example: ValueError raised when fitting very high-frequency data -->

#### Steps/Code to Reproduce
<!--
Expand Down
7 changes: 6 additions & 1 deletion appveyor.yml
Expand Up @@ -34,7 +34,12 @@ build_script:
- cmd: C:\Miniconda.exe /S /D=C:\Py
- SET PATH=C:\Py;C:\Py\Scripts;C:\Py\Library\bin;%PATH%
- conda config --set always_yes yes
- conda update conda --quiet
# - conda update conda

# Debugging because Appveyor gives us no stack traces when this stuff breaks.
- ps: echo "Conda version:"
- conda --version
- ps: echo "Python version=$env:PYTHON_VERSION"

# Things we'll need for build/test
- ps: conda create -n testenv --yes python=$env:PYTHON_VERSION numpy scipy cython scikit-learn statsmodels pip nose patsy
Expand Down
57 changes: 57 additions & 0 deletions benchmarks/benchmark_funcs.py
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
#
# Benchmark various approaches to functions to speed things up.
# ... hopefully.

from __future__ import absolute_import

import numpy as np

import time


def _do_time(func, n_iter=10, *args, **kwargs):
times = []
for _ in range(n_iter):
start = time.time()
func(*args, **kwargs)
times.append(time.time() - start)

times = np.asarray(times)
print("Completed %i iterations (avg=%.6f, min=%.6f, max=%.6f)"
% (n_iter, times.mean(), times.min(), times.max()))


def benchmark_is_constant():
"""This benchmarks the "is_constant" function from ``pyramid.arima.utils``.
This was added in 0.6.2.
"""
# WINNER!
def is_const1(x):
"""This is the version in Pyramid 0.6.2.
Parameters
----------
x : np.ndarray
This is the array.
"""
return (x == x[0]).all()

def is_const2(x):
"""This should ostensibly only take O(N) rather than O(2N) like
its predecessor. But we'll see...
Parameters
----------
x : np.ndarray
This is the array.
"""
return np.unique(x).shape[0] == 1

x = np.random.choice(np.arange(10), 1000000, replace=True)
_do_time(is_const1, 25, x)
_do_time(is_const2, 25, x)


if __name__ == '__main__':
benchmark_is_constant()
5 changes: 4 additions & 1 deletion build_tools/travis/after_success.sh
Expand Up @@ -4,10 +4,13 @@

# License: 3-clause BSD

set -e
# 02/10/2018 remove due to Travis build issue 6307
# set -e
set +e # because TRAVIS SUCKS

# push coverage if necessary
if [[ "$COVERAGE" == "true" ]]; then

# Need to run coveralls from a git checkout, so we copy .coverage
# from TEST_DIR where nosetests has been run
cp $TEST_DIR/.coverage $TRAVIS_BUILD_DIR
Expand Down
11 changes: 11 additions & 0 deletions build_tools/travis/before_install.sh
Expand Up @@ -6,4 +6,15 @@ set -e
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
echo "Updating apt-get for Linux build"
sudo apt-get -qq update

# Workaround for https://github.com/travis-ci/travis-ci/issues/6307, which
# caused the following error on MacOS X workers:
#
# Warning, RVM 1.26.0 introduces signed releases and automated check of
# signatures when GPG software found.
# /Users/travis/build.sh: line 109: shell_session_update: command not found
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
echo "Updating Ruby for Mac OS build"
# command curl -sSL https://rvm.io/mpapis.asc | gpg --import -;
# rvm get stable
fi
5 changes: 5 additions & 0 deletions doc/_static/css/gitcontrib.css
Expand Up @@ -32,6 +32,11 @@
margin-top: 10px;
}

img.avatar {
width: 60px;
height: 60px;
}

.contrib-author-wrapper {
position: absolute;
display: block;
Expand Down
5 changes: 3 additions & 2 deletions doc/_static/js/contrib.js
Expand Up @@ -2,7 +2,7 @@ function commaFmt(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

$(document).ready(function() {
function fetchContributors() {
$.getJSON("https://api.github.com/repos/tgsmith61591/pyramid/stats/contributors", function(arr) {
// sort the array based on total count
arr.sort(function(a, b) {
Expand Down Expand Up @@ -54,7 +54,8 @@ $(document).ready(function() {
'</div>' +
'</li>')

// can only do this once the doc is ready
$('#contrib').append(li);
});
});
});
}
6 changes: 6 additions & 0 deletions doc/contributors.rst
Expand Up @@ -11,6 +11,12 @@ Thanks to the following users for their contributions to Pyramid!

<!-- This does all the heavy lifting -->
<script src="_static/js/contrib.js"></script>
<script type="text/javascript">
// actually call the contrib code
$(document).ready(function() {
fetchContributors();
});
</script>

<!-- This is taken from the Github contrib page -->
<ol id="contrib" class="contrib-data capped-cards clearfix"></ol>
36 changes: 18 additions & 18 deletions doc/quickstart.rst
Expand Up @@ -20,26 +20,26 @@ Here is a simple example of Pyramid use:
... error_action='ignore', # don't want to know if an order does not work
... suppress_warnings=True, # don't want convergence warnings
... stepwise=True) # set to stepwise
Fit ARIMA: order=(1, 1, 1) seasonal_order=(0, 1, 1, 12); AIC=3066.811, BIC=3082.663, Fit time=1.731 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(0, 1, 1, 12); AIC=3066.811, BIC=3082.663, Fit time=0.517 seconds
Fit ARIMA: order=(0, 1, 0) seasonal_order=(0, 1, 0, 12); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 1, 0, 12); AIC=3099.735, BIC=3112.417, Fit time=0.434 seconds
Fit ARIMA: order=(0, 1, 1) seasonal_order=(0, 1, 1, 12); AIC=3066.983, BIC=3079.665, Fit time=0.473 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(1, 1, 1, 12); AIC=3067.666, BIC=3086.688, Fit time=2.184 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(0, 1, 0, 12); AIC=3088.109, BIC=3100.791, Fit time=0.344 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(0, 1, 2, 12); AIC=3067.669, BIC=3086.692, Fit time=4.371 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(1, 1, 2, 12); AIC=3068.757, BIC=3090.951, Fit time=4.160 seconds
Fit ARIMA: order=(2, 1, 1) seasonal_order=(0, 1, 1, 12); AIC=3067.485, BIC=3086.508, Fit time=1.204 seconds
Fit ARIMA: order=(1, 1, 0) seasonal_order=(0, 1, 1, 12); AIC=3094.578, BIC=3107.260, Fit time=0.468 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(0, 1, 1, 12); AIC=3066.771, BIC=3085.794, Fit time=1.222 seconds
Fit ARIMA: order=(2, 1, 3) seasonal_order=(0, 1, 1, 12); AIC=3070.642, BIC=3096.006, Fit time=3.495 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(1, 1, 1, 12); AIC=3068.086, BIC=3090.280, Fit time=1.180 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(0, 1, 0, 12); AIC=3090.977, BIC=3106.830, Fit time=0.544 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(0, 1, 2, 12); AIC=3067.766, BIC=3089.959, Fit time=3.303 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(1, 1, 2, 12); AIC=3069.717, BIC=3095.081, Fit time=5.675 seconds
Fit ARIMA: order=(1, 1, 0) seasonal_order=(1, 1, 0, 12); AIC=3099.735, BIC=3112.417, Fit time=0.162 seconds
Fit ARIMA: order=(0, 1, 1) seasonal_order=(0, 1, 1, 12); AIC=3066.983, BIC=3079.665, Fit time=0.164 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(1, 1, 1, 12); AIC=3067.666, BIC=3086.688, Fit time=0.645 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(0, 1, 0, 12); AIC=3088.109, BIC=3100.791, Fit time=0.136 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(0, 1, 2, 12); AIC=3067.669, BIC=3086.692, Fit time=1.512 seconds
Fit ARIMA: order=(1, 1, 1) seasonal_order=(1, 1, 2, 12); AIC=3068.757, BIC=3090.951, Fit time=1.651 seconds
Fit ARIMA: order=(2, 1, 1) seasonal_order=(0, 1, 1, 12); AIC=3067.485, BIC=3086.508, Fit time=0.445 seconds
Fit ARIMA: order=(1, 1, 0) seasonal_order=(0, 1, 1, 12); AIC=3094.578, BIC=3107.260, Fit time=0.174 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(0, 1, 1, 12); AIC=3066.771, BIC=3085.794, Fit time=0.425 seconds
Fit ARIMA: order=(2, 1, 3) seasonal_order=(0, 1, 1, 12); AIC=3070.642, BIC=3096.006, Fit time=0.966 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(1, 1, 1, 12); AIC=3068.086, BIC=3090.280, Fit time=0.411 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(0, 1, 0, 12); AIC=3090.977, BIC=3106.830, Fit time=0.249 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(0, 1, 2, 12); AIC=3067.766, BIC=3089.959, Fit time=1.170 seconds
Fit ARIMA: order=(1, 1, 2) seasonal_order=(1, 1, 2, 12); AIC=3069.717, BIC=3095.081, Fit time=2.000 seconds
Fit ARIMA: order=(0, 1, 2) seasonal_order=(0, 1, 1, 12); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(0, 1, 1, 12); AIC=3068.701, BIC=3090.895, Fit time=1.509 seconds
Fit ARIMA: order=(1, 1, 3) seasonal_order=(0, 1, 1, 12); AIC=3068.842, BIC=3091.036, Fit time=2.329 seconds
Total fit time: 34.636 seconds
Fit ARIMA: order=(2, 1, 2) seasonal_order=(0, 1, 1, 12); AIC=3068.701, BIC=3090.895, Fit time=0.523 seconds
Fit ARIMA: order=(1, 1, 3) seasonal_order=(0, 1, 1, 12); AIC=3068.842, BIC=3091.036, Fit time=0.590 seconds
Total fit time: 11.745 seconds
It's easy to examine your model fit results. Simply use the ``summary`` method:

Expand Down
3 changes: 3 additions & 0 deletions doc/setup.rst
Expand Up @@ -17,3 +17,6 @@ python:
.. code-block:: python
from pyramid.arima import auto_arima
If you encounter an ``ImportError``, try updating numpy and re-installing. Outdated
numpy versions have been observed to break the Pyramid build.
2 changes: 1 addition & 1 deletion pyramid/__init__.py
Expand Up @@ -4,7 +4,7 @@
#
# The pyramid module

__version__ = "0.6.2"
__version__ = "0.6.5"

try:
# this var is injected in the setup build to enable
Expand Down
1 change: 1 addition & 0 deletions pyramid/arima/__init__.py
Expand Up @@ -6,5 +6,6 @@
from .arima import *
from .auto import *
from .utils import *
from .warnings import *

__all__ = [s for s in dir() if not s.startswith("_")]
12 changes: 11 additions & 1 deletion pyramid/arima/approx.py
Expand Up @@ -33,6 +33,10 @@
'mean': np.average
}

# identity function defined once to avoid multiple lambda calls
# littered throughout
_identity = (lambda t: t)


def _regularize(x, y, ties):
"""Regularize the values, make them ordered and remove duplicates.
Expand Down Expand Up @@ -82,8 +86,14 @@ def tie_apply(f, u_val):
return f(vals)

# replace the duplicates in the y array with the "tie" func
func = VALID_TIES.get(ties, lambda t: t)
func = VALID_TIES.get(ties, _identity)

# maybe expensive to vectorize on the fly? Not sure; would need
# to do some benchmarking. However, we need to in order to keep y
# and x in scope...
y = np.vectorize(tie_apply)(func, ux)

# does ux need ordering? hmm..
x = ux

return x, y
Expand Down
10 changes: 6 additions & 4 deletions pyramid/arima/arima.py
Expand Up @@ -215,6 +215,9 @@ def fit(self, y, exogenous=None, **fit_args):
operation. This should not include a constant or trend. Note that
if an ``ARIMA`` is fit on exogenous features, it must be provided
exogenous features for making predictions.
**fit_args : dict or kwargs
Any keyword arguments to pass to the statsmodels ARIMA fit.
"""
y = c1d(check_array(y, ensure_2d=False, force_all_finite=False,
copy=True, dtype=DTYPE)) # type: np.ndarray
Expand Down Expand Up @@ -360,9 +363,8 @@ def predict_in_sample(self, exogenous=None, start=None,

def predict(self, n_periods=10, exogenous=None):
"""Generate predictions (forecasts) ``n_periods`` in the future.
Note that unless ``include_std_err`` or ``include_conf_int`` are True,
only the forecast array will be returned (otherwise, a tuple with the
corresponding elements will be returned).
Note that if ``exogenous`` variables were used in the model fit, they
will be expected for the predict procedure and will fail otherwise.
Parameters
----------
Expand Down Expand Up @@ -423,7 +425,7 @@ def fit_predict(self, y, exogenous=None, n_periods=10, **fit_args):
n_periods : int, optional (default=10)
The number of periods in the future to forecast.
fit_args : dict, optional (default=None)
fit_args : dict or kwargs, optional (default=None)
Any keyword args to pass to the fit method.
"""
self.fit(y, exogenous, **fit_args)
Expand Down

0 comments on commit c2d2fde

Please sign in to comment.