# Pymc\_Marketing expected\_probability\_alive

**URL:** <https://discourse.pymc.io/t/pymc-marketing-expected-probability-alive/14818>\
**Category:** v5\
**Tags:** development, modeling\
**Created:** [July 22, 2024, 2:07am UTC](https://discourse.pymc.io/t/pymc-marketing-expected-probability-alive/14818 "2024-07-22T02:07:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Radhakrishnan](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rahul_radhakrishnan/32/7400_2.png) [@Rahul\_Radhakrishnan](https://discourse.pymc.io/u/Rahul_Radhakrishnan)\
**Post date:** [July 22, 2024, 2:07am UTC](https://discourse.pymc.io/t/pymc-marketing-expected-probability-alive/14818/1 "2024-07-22T02:07:24Z")

</div>

Hi,

I am trying to build a model with Pymc\_Marketing I created a model with the following config  
model\_config = {  
‘a\_prior’: {‘dist’: ‘HalfNormal’,  
‘kwargs’: {‘sigma’: 100}},  
‘b\_prior’: {‘dist’: ‘HalfNormal’,  
‘kwargs’: {‘sigma’: 100}},  
‘alpha\_prior’: {‘dist’: ‘HalfNormal’,  
‘kwargs’: {‘sigma’: 100}},  
‘r\_prior’: {‘dist’: ‘HalfNormal’,  
‘kwargs’: {‘sigma’: 100}},

}  
sample\_kwargs = {  
“draws”: 2\_000,  
“chains”: 5,  
“target\_accept”: 0.9,  
“random\_seed”: 42,  
}

bgm = clv.BetaGeoModel(  
data = data\_summary\_rfm,  
model\_config = model\_config

)  
bgm.build\_model()  
bgm

bgm.fit(\*\*sample\_kwargs)

My Data is pretty big i have around 500000 unique customers. I am trying to see the probability of alive of customers in the next 90 Days. Even running in batches the kernel is getting killed. Is there a better way to to do the same?

steps = 90  
batch\_size=5000

sdata = data\_summary\_rfm.copy()

future\_alive\_all =

for start in tqdm(range(0, len(sdata), batch\_size)):  
end = start + batch\_size  
batch = sdata.iloc[start:end]

```
for t in progress_bar(range(steps)):
    future_data = batch.copy()
    future_data["T"] = future_data["T"] + t
    future_alive = tt.expected_probability_alive(data=future_data)
    #future_alive_all.append(future_alive)
    batch_result = pd.DataFrame({
    'customer_id': batch['customer_id'].values,
    'Prob_of_alive': future_alive.mean(('chain', 'draw')).values
})

# Append the result to the list
future_alive_all.append(batch_result)

```

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [July 22, 2024, 7:09pm UTC](https://discourse.pymc.io/t/pymc-marketing-expected-probability-alive/14818/2 "2024-07-22T19:09:05Z")

</div>

You will probably want to thin your dataset with the `thin_fit_result`method besides running in batches
