Hi,
I am trying to sample from the posterior resulting of this (Logistic Regression) model specification:
lower = 0.01
upper = 1
with pm.Model() as customer_model:
beta_0 = pm.Uniform('beta_0', lower=lower, upper= upper)
beta_feature_one = pm.Uniform(
'beta_feature_one',
lower = X_train['feature_one'].min(),
upper = X_train['feature_one'].max()
)
beta_feature_two= pm.Uniform(
'beta_feature_two',
lower = X_train['feature_two'].min(),
upper = X_train['feature_two'].max()
)
beta_feature_three = pm.Uniform(
'beta_feature_three',
lower = X_train['feature_three'].min(),
upper = X_train['feature_three'].max(),
)
beta_feature_four = pm.TruncatedNormal(
'beta_feature_four',
mu = 10,
sigma = 44,
lower = 0
)
beta_feature_five = pm.Normal(
'beta_feature_five',
mu = 598,
sigma = 340
)
beta_feature_six = pm.Normal(
'beta_feature_six',
mu = 32180,
sigma = 15687
)
lin_comb = (
beta_0 +
beta_feature_one * X_train['feature_one'] +
beta_feature_two* X_train['feature_two'] +
beta_feature_three * X_train['feature_three'] +
beta_feature_four * X_train['feature_four'] +
beta_feature_five * X_train['feature_five'] +
beta_feature_six * X_train['feature_six']
)
p = pm.Deterministic('p', pm.math.sigmoid(lin_comb))
likelihood = pm.Bernoulli(
'observed_default',
p = p,
observed = y_train
)
trace = pm.sample()
I am unsure about which values to pass to tune
and draws
-params in pm.sample()
so I decided to keep the default values (after passing other values first). Also, I cannot discern any distribution after plotting selected features, so I have decided to assume a uniform distribution for them. Finally, I am aware of the importance of scaling features first, but decided to run this version of the project without scaling.
This is the error message I get Cannot execute code, session has been disposed. Please try restarting the Kernel. The Kernel crashed while executing code in the the current cell or a previous cell.(...)
I have restarted the Kernel and cleared the notebook prior to running it again (but getting the same error message). I am running the model in pymc5
.
What am I missing in this model specification? Could it be that it is not the model itself, but that I need to scale the features first?
Thanks in advance!