For binary response variables, use the family="bernoulli" argument in bmb.Model.
Bambi supports syntax sugar to specify which event in a categorical response you want to model. For example, if your column g contains "Yes" and "No", you can use g['Yes'] in your formula to model the probability of a "Yes" response. If you use a standard formula like "g ~ x1 + x2", Bambi will automatically pick one of the events to model and notify you which one was selected.
import bambi as bmb
import pandas as pd
import numpy as np
data = pd.DataFrame({
"g": np.random.choice(["Yes", "No"], size=50),
"x1": np.random.normal(size=50),
"x2": np.random.normal(size=50)
})
# Modeling the probability of 'Yes' using Bernoulli family
model = bmb.Model("g['Yes'] ~ x1 + x2", data, family="bernoulli")
fitted = model.fit()