Comments (3)
For posterity: I have experienced the exact same problem, with a and b converging to values of 1e-6 and smaller. Fortunately I was able to stabilize the algorithm by setting initial values of 0.5 for each. My intuition is that very small initial values can trigger this problem, and maybe it would be sensible to set the random initialization to be 1.0 + uniform(0.05)
rather than normal(mu=1.0, std=0.05)
as I believe it is now.
from lifetimes.
Hi Marco,
I wasn't able to reproduce your findings. I ran a modified script to generate/fit a bunch of times:
import matplotlib.pylab as plt
import pandas as pd
import lifetimes.generate_data as gen
from lifetimes import estimation
T = 40
r = 0.24
alpha = 4.41
a = 0.8
b = 2.43
fitter = estimation.ModifiedBetaGeoFitter()
params = []
for _ in range(500):
data = gen.modified_beta_geometric_nbd_model(T, r, alpha, a, b, size=1000)
fitter.fit(data['frequency'],data['recency'],data['T'])
params.append(fitter._unload_params('r','alpha','a','b'))
df = pd.DataFrame(params, columns=['r','alpha','a','b'])
fig, axes = plt.subplots(nrows=2, ncols=2)
df.hist('r', bins=100, range=(0,1), ax=axes[0,0])
df.hist('alpha', bins=100, range=(2,7), ax=axes[0,1])
df.hist('a', bins=100, range=(0.2,4), ax=axes[1,0])
df.hist('b', bins=100, range=(0,10), ax=axes[1,1])
which produced the following distributions:
I should note that I've clipped some outliers where sometimes the fitting failed and produced a
and b
params in the 10^6 range, but that happened something like 2 times in 500 trials.
I'm not sure why you're seeing so many fitted parameters close to zero...
from lifetimes.
Great script @rhydomako. I tried this too on my system (using 0.2.2.1). Output below:
I also get sometimes wild values for (a,b) (not shown here), but by adding a small penalizer_coef=0.01
, the results are more sensible (below)
The max value of a
in this simulation was 34.50
from lifetimes.
Related Issues (20)
- Wrong monetary_value HOT 3
- Question - Why average Monetary value and not Total meontary value?
- Wrong holdout monetary value HOT 1
- Implementing a bathtub-like hazard-rate AFT model
- ValueError: Some values in recency vector are larger than T vector when data has no issue. HOT 6
- Not Implemented - TypeError: unsupported operand type(s) for +: 'int' and 'str' HOT 4
- How to interpret expected purchase orders in future HOT 3
- Quantitative Metrics to assess model performance HOT 5
- Documentation flow incorrect? HOT 1
- Cross Validation Setup HOT 1
- Unreachable code after fitting betageofitter model HOT 2
- NaN predictions for customers with 0 frequency and 0 recency HOT 1
- Error when running plot_history_alive HOT 3
- data simulated vs holdout purchases HOT 8
- Runtime Warning HOT 3
- How to get conditional probability alive for the next few periods? HOT 1
- SQL statement to transform transactional data into RFM data HOT 1
- Recency Definition HOT 1
- model validation and performance measurement with unseen data HOT 3
- parameters in ModifiedBetaGeoFitter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lifetimes.