jdmaturen / shifted_beta_geometric_py Goto Github PK
View Code? Open in Web Editor NEWAn implementation of the shifted-beta-geometric (sBG) model from Fader and Hardie's "How to Project Customer Retention" (2006)
License: Apache License 2.0
An implementation of the shifted-beta-geometric (sBG) model from Fader and Hardie's "How to Project Customer Retention" (2006)
License: Apache License 2.0
In the paper survival is product of of probabilities (see eq 1 in https://faculty.wharton.upenn.edu/wp-content/uploads/2012/04/Fader_hardie_jim_07.pdf):
S(t) = Pi(r_i, i=1:t)
Yet, in the code it is differences : S = 1 - sum(r_i, i=1:t)
def survivor(probabilities, t):
"""Survivor function S"""
s = 1 - probabilities[0]
for x in xrange(1, t + 1):
s = s - probabilities[x]
return s
In the paper, the log likelihood is the sum of cancel rates times log probabilities, plus the end survived rate times final survivor likelihood. Should it therefore not be
def log_likelihood(alpha, beta, data, survivors=None):
if alpha <= 0 or beta <= 0:
return -1000
if survivors is None:
survivors = cancel_rates
probabilities = generate_probabilities(alpha, beta, len(data))
final_survivor_likelihood = survivor(probabilities, len(data) - 1)
return sum([s * np.log(probabilities[t]) for t, s in enumerate(data)]) + survivors[-1] * np.log(final_survivor_likelihood)
After installing
pip install git+https://github.com/jdmaturen/shifted_beta_geometric_py
python -c "from shifted_beta_geometric import fit"
Traceback (most recent call last):
File "", line 1, in
File "/Users/x/anaconda3/lib/python3.6/site-packages/shifted_beta_geometric/init.py", line 1, in
from sbg import derl
ModuleNotFoundError: No module named 'sbg'
probably because of wrong import namespace.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.