# Trying to use pm.BinaryMetropolis()

**URL:** <https://discourse.pymc.io/t/trying-to-use-pm-binarymetropolis/10645>\
**Category:** Questions\
**Created:** [October 20, 2022, 3:23pm UTC](https://discourse.pymc.io/t/trying-to-use-pm-binarymetropolis/10645 "2022-10-20T15:23:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsh980210](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jsh980210/32/5630_2.png) [@jsh980210](https://discourse.pymc.io/u/jsh980210)\
**Post date:** [October 20, 2022, 3:23pm UTC](https://discourse.pymc.io/t/trying-to-use-pm-binarymetropolis/10645/1 "2022-10-20T15:23:14Z")

</div>

```
with pm.Model() as logistic_model_pred:
    
    beta_0=pm.Normal('beta_0', 0, 16)
    beta_1=pm.Normal('beta_1', 0, 16)
    beta_2=pm.Normal('beta_2', 0, 16)
    beta_3=pm.Normal('beta_3', 0, 16)
    humidity = pm.Data("humidity", value = X_train['Humidity'], mutable = True)
    light = pm.Data("light", value = X_train['Light'], mutable = True)
    co2 = pm.Data("co2", value = X_train['CO2'], mutable = True)
    label = pm.Data("label", value = y_train, mutable = True)
    observed=pm.Bernoulli("occupancy", pm.math.sigmoid(beta_0 + beta_1 * humidity + beta_2 * light + beta_3 * co2), observed = label)
with logistic_model_pred:
    step = pm.BinaryMetropolis(vars = label)
    trace = pm.sample(step = step)

```

I’m trying to create a logistic regression model, and the ‘label’ is binary. To sample the posterior of coefficients, in this case \beta\_0, \beta\_1, \beta\_2, \beta\_3, I’m trying to use pm.BinaryMetropolis(), but it gives me an error

```
'NoneType' object has no attribute 'endswith'

```

Am I using this step function correctly?

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [October 21, 2022, 8:20am UTC](https://discourse.pymc.io/t/trying-to-use-pm-binarymetropolis/10645/2 "2022-10-21T08:20:45Z")

</div>

> [@jsh980210](#):
>
> ```auto
> with logistic_model_pred:
> step = pm.BinaryMetropolis(vars = label)
> 
> ```

`label` is not a Random Variable so you will not be able to sample it.
