def __init__(self, in_features, out_features):
self.linear = PyroModule[nn.Linear](in_features, out_features)
self.linear.weight = PyroSample(dist.Normal(0., 1.).expand([out_features, in_features]).to_event(2))
self.linear.bias = PyroSample(dist.Normal(0., 10.).expand([out_features]).to_event(1))
def forward(self, x, y=None):
sigma = pyro.sample("sigma", dist.Uniform(0., 10.))
mean = self.linear(x).squeeze(-1)
with pyro.plate("data", x.shape):
rate = self.linear(x).squeeze(-1).exp()
obs = pyro.sample("obs", dist.Poisson(rate), obs=y)
Ok that makes sense. I’m trying to apply a bayesian framework to an insurance problem. In the insurance industry, claims frequency is Poisson distributed but the frequency is calculated as #claims/risk (risk = amount ratio of time the policy has been on the books).
So it’s a real number, not an integer. hmmm…i’ll have to think about this. Claims frequency is definitely zero-inflated and takes the shape of a poisson distribution. I’m not sure what else to attribute it to.