def test_implicit_constant(self): x = self.rng.standard_normal((1000, 2)) assert not implicit_constant(x) x[:, 0] = 1.0 assert implicit_constant(x) x = self.rng.standard_normal((1000, 3)) x[:, 0] = x[:, 0] > 0 x[:, 1] = 1 - x[:, 0] assert implicit_constant(x)
def test_implicit_constant(self): x = np.random.standard_normal((1000, 2)) assert_true(not implicit_constant(x)) x[:, 0] = 1.0 assert_true(implicit_constant(x)) x = np.random.standard_normal((1000, 3)) x[:, 0] = x[:, 0] > 0 x[:, 1] = 1 - x[:, 0] assert_true(implicit_constant(x))
def _r2(self, params: NDArray) -> float: y = self._fit_y x = self._fit_regressors constant = False if x is not None and x.shape[1] > 0: constant = self.constant or implicit_constant(x) e = self.resids(params) if constant: y = y - np.mean(y) return 1.0 - e.T.dot(e) / y.dot(y)
def _r2(self, params): y = self._fit_y x = self._fit_regressors constant = False if x is not None and x.shape[1] > 0: constant = self.constant or implicit_constant(x) e = self.resids(params) if constant: y = y - np.mean(y) return 1.0 - e.T.dot(e) / y.dot(y)