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)
 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)
 def test_with_pipeline(self):
     model = Pipeline([('PCA',PCA()), ('Poisson',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)
     assert_equal(str(model), '''Pipeline(PCA=PCA(copy=True, n_components=None, whiten=False), PCA__copy=True,
  PCA__n_components=None, PCA__whiten=False, Poisson=PoissonRegressor())''')