示例#1
0
 def test_poisson(self):
     model = PoissonRegressor()
     y = Poisson().fitted(self.eta)
     model.fit(self.X, y)
     y_hat = model.predict(self.X)
     diff = y_hat - y
     rsq = 1 - np.mean(diff**2) / np.mean((y-np.mean(y))**2)
     assert_true(rsq > .9)
示例#2
0
 def test_poisson_exposure(self):
     model = PoissonRegressor()
     exposure = np.random.exponential(scale=10, size=100)
     y = Poisson().fitted(self.eta + np.log(exposure))
     model.fit(self.X, y, exposure=exposure)
     y_hat = model.predict(self.X, exposure=exposure)
     diff = y_hat - y
     rsq = 1 - np.mean(diff**2) / np.mean((y-np.mean(y))**2)
     assert_true(rsq > .9)