Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #254 from CamDavidsonPilon/pandas-check
Browse files Browse the repository at this point in the history
v0.11.1
  • Loading branch information
CamDavidsonPilon authored Mar 8, 2019
2 parents 91e184e + 74c076b commit 3e93e80
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 54 deletions.
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ python:
- "3.5"
- "3.6"
env:
- export PANDAS_VERSION=0.21.1
- export PANDAS_VERSION=0.22.0
- export PANDAS_VERSION=0.23.4
- export PANDAS_VERSION=0.24.1
# Enable newer 3.7 without globally enabling sudo and dist: xenial for other build jobs
matrix:
Expand All @@ -17,14 +14,11 @@ matrix:
dist: xenial
sudo: true
env: export PANDAS_VERSION=0.24.1
- python: 3.7
dist: xenial
sudo: true
env: export PANDAS_VERSION=0.23.4
before_install:
- ls
install:
- "pip install -r dev_requirements.txt"
- "pip install pandas==$PANDAS_VERSION"
# command to run tests
script:
- py.test --cov lifetimes
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 0.11.1
- bump the Pandas requirements to >= 0.24.0. This should have been done in 0.11.0
- suppress some warnings from autograd.

### 0.11.0
- Move most models (all but Pareto) to autograd for automatic differentiation of their likelihood. This results in faster (at least 3x) and more successful convergence, plus allows for some really exciting extensions (coming soon).
- `GammaGammaFitter`, `BetaGeoFitter`, `ModifiedBetaGeoFitter` and `BetaGeoBetaBinomFitter` have three new attributes: `confidence_interval_`, `variance_matrix_` and `standard_errors_`
Expand Down
19 changes: 14 additions & 5 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

0.11.1
~~~~~~

- bump the Pandas requirements to >= 0.24.0. This should have been done
in 0.11.0
- suppress some warnings from autograd.

.. _section-1:

0.11.0
~~~~~~

Expand All @@ -20,7 +29,7 @@ Changelog
- fixed a bug that was causing ``ParetoNBDFitter`` to generate data
incorrectly.

.. _section-1:
.. _section-2:

0.10.1
~~~~~~
Expand All @@ -38,7 +47,7 @@ Changelog
- Stop support of scipy < 1.0.
- Stop support of < Python 3.5.

.. _section-2:
.. _section-3:

0.10.0
~~~~~~
Expand All @@ -57,7 +66,7 @@ Changelog
used to reduce the size of the data (collapsing subjects with the
same recency, frequency, T).

.. _section-3:
.. _section-4:

0.9.1
~~~~~
Expand All @@ -74,7 +83,7 @@ Changelog
difference in values compared to ``summary_from_transaction_data``.
@DaniGate

.. _section-4:
.. _section-5:

0.9.0
~~~~~
Expand All @@ -86,7 +95,7 @@ Changelog
- Fixed a bug in ``expected_cumulative_transactions`` and
``plot_cumulative_transactions``

.. _section-5:
.. _section-6:

0.8.1
~~~~~
Expand Down
9 changes: 9 additions & 0 deletions docs/Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ print(bgf)
"""
<lifetimes.BetaGeoFitter: fitted with 2357 subjects, a: 0.79, alpha: 4.41, b: 2.43, r: 0.24>
"""

bgf.summary
"""
coef se(coef) lower 95% bound upper 95% bound
r 0.242593 0.012557 0.217981 0.267205
alpha 4.413532 0.378221 3.672218 5.154846
a 0.792886 0.185719 0.428877 1.156895
b 2.425752 0.705345 1.043276 3.808229
"""
```

After fitting, we have lots of nice methods and properties attached to the fitter object, like ``param_`` and ``summary``.
Expand Down
70 changes: 33 additions & 37 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
# sys.path.insert(0, os.path.abspath('.'))

import sphinx_rtd_theme

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Convert package README.md to intro.rst to include in index.rst for docs
try:
import pypandoc
long_description = pypandoc.convert_file('../README.md', 'rst',
outputfile='intro.rst')
except(ImportError):
print('Install pypandoc to convert README.md to intro.rst')

long_description = pypandoc.convert_file("../README.md", "rst", outputfile="intro.rst")
except (ImportError):
print("Install pypandoc to convert README.md to intro.rst")


# -- General configuration ------------------------------------------------
Expand All @@ -44,40 +45,38 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon'
"sphinx.ext.autodoc",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# for parsing markdown files
source_parsers = {
'.md': 'recommonmark.parser.CommonMarkParser',
}
source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'lifetimes'
copyright = '2015, Cameron Davidson-Pilon'
author = 'Cameron Davidson-Pilon'
project = "lifetimes"
copyright = "2015, Cameron Davidson-Pilon"
author = "Cameron Davidson-Pilon"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.11.0'
version = "0.11.1"
# The full version, including alpha/beta/rc tags.
release = version

Expand All @@ -91,10 +90,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Expand All @@ -117,7 +116,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# -- Napoleon settings ----------------------------------------------------
napoleon_google_docstring = True
Expand All @@ -137,7 +136,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'lifetimesdoc'
htmlhelp_basename = "lifetimesdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -146,15 +145,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -163,20 +159,14 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'lifetimes.tex', 'lifetimes Documentation',
'Cameron Davidson-Pilon', 'manual'),
]
latex_documents = [(master_doc, "lifetimes.tex", "lifetimes Documentation", "Cameron Davidson-Pilon", "manual")]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'lifetimes', 'lifetimes Documentation',
[author], 1)
]
man_pages = [(master_doc, "lifetimes", "lifetimes Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -185,7 +175,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'lifetimes', 'lifetimes Documentation',
author, 'lifetimes', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"lifetimes",
"lifetimes Documentation",
author,
"lifetimes",
"One line description of project.",
"Miscellaneous",
)
]
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Quickstart
Saving and loading model
More examples and recipes
lifetimes
Changelog


Expand Down
3 changes: 3 additions & 0 deletions lifetimes/fitters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
"""Base fitter for other classes."""
import warnings

warnings.simplefilter(action="ignore", category=FutureWarning)
import dill
import numpy as np
import pandas as pd
Expand Down
5 changes: 5 additions & 0 deletions lifetimes/fitters/beta_geo_beta_binom_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"""Beta Geo Beta BinomFitter."""
from __future__ import division
from __future__ import print_function
import warnings

warnings.simplefilter(action="ignore", category=FutureWarning)

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -62,6 +65,8 @@ def __init__(self, penalizer_coef=0.0):

@staticmethod
def _loglikelihood(params, x, tx, T):
warnings.simplefilter(action="ignore", category=FutureWarning)

"""Log likelihood for optimizer."""
alpha, beta, gamma, delta = params

Expand Down
3 changes: 3 additions & 0 deletions lifetimes/fitters/beta_geo_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Beta Geo Fitter, also known as BG/NBD model."""
from __future__ import print_function
from __future__ import division
import warnings

import pandas as pd
import autograd.numpy as np
Expand Down Expand Up @@ -146,6 +147,8 @@ def fit(

@staticmethod
def _negative_log_likelihood(log_params, freq, rec, T, weights, penalizer_coef):
warnings.simplefilter(action="ignore", category=FutureWarning)

params = np.exp(log_params)
r, alpha, a, b = params

Expand Down
2 changes: 2 additions & 0 deletions lifetimes/fitters/gamma_gamma_fitter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import division
import warnings

import pandas as pd
from autograd import numpy as np
Expand Down Expand Up @@ -68,6 +69,7 @@ def __init__(self, penalizer_coef=0.0):

@staticmethod
def _negative_log_likelihood(log_params, frequency, avg_monetary_value, weights, penalizer_coef):
warnings.simplefilter(action="ignore", category=FutureWarning)

params = np.exp(log_params)
p, q, v = params
Expand Down
3 changes: 3 additions & 0 deletions lifetimes/fitters/modified_beta_geo_fitter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import division
import warnings

import autograd.numpy as np
from autograd.numpy import log, logaddexp
Expand Down Expand Up @@ -113,6 +114,8 @@ def fit(

@staticmethod
def _negative_log_likelihood(log_params, freq, rec, T, weights, penalizer_coef):
warnings.simplefilter(action="ignore", category=FutureWarning)

params = np.exp(log_params)
r, alpha, a, b = params

Expand Down
4 changes: 4 additions & 0 deletions lifetimes/generate_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
import warnings

warnings.simplefilter(action="ignore", category=FutureWarning)
import numpy as np
from numpy import random
import pandas as pd
Expand Down
2 changes: 0 additions & 2 deletions lifetimes/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
"""Lifetimes utils and helpers."""
from __future__ import division

import numpy as np
import pandas as pd
import dill
Expand All @@ -11,7 +10,6 @@
__all__ = [
"calibration_and_holdout_data",
"summary_data_from_transaction_data",
"_find_first_transactions",
"calculate_alive_path",
"expected_cumulative_transactions",
]
Expand Down
3 changes: 2 additions & 1 deletion lifetimes/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

__version__ = "0.11.0"
__version__ = "0.11.1"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
numpy>1.10.0
scipy>=1.0.0
pandas>=0.21.1
pandas>=0.24.0
dill>=0.2.6
autograd>=1.2.0
Loading

0 comments on commit 3e93e80

Please sign in to comment.