def test_exact_ties(self):
     adj_models = self.models_df - 100.0
     adj_models.iloc[:, :2] -= adj_models.iloc[:, :2].mean()
     adj_models.iloc[:, :2] += self.benchmark_df.mean().iloc[0]
     stepm = StepM(self.benchmark_df, adj_models, size=0.10)
     stepm.compute()
     assert_equal(len(stepm.superior_models), self.models.shape[1] - 2)
Esempio n. 2
0
 def test_exact_ties(self):
     adj_models = self.models_df - 100.0
     adj_models.iloc[:, :2] -= adj_models.iloc[:,:2].mean()
     adj_models.iloc[:, :2] += self.benchmark_df.mean().iloc[0]
     stepm = StepM(self.benchmark_df, adj_models, size=0.10)
     stepm.compute()
     assert_equal(len(stepm.superior_models), self.models.shape[1] - 2)
Esempio n. 3
0
    def test_equivalence(self):
        adj_models = self.models - linspace(-2.0, 2.0, self.k)
        stepm = StepM(self.benchmark, adj_models, size=0.20, reps=200)
        stepm.seed(23456)
        stepm.compute()

        adj_models = self.models_df - linspace(-2.0, 2.0, self.k)
        stepm_pandas = StepM(self.benchmark_series, adj_models, size=0.20, reps=200)
        stepm_pandas.seed(23456)
        stepm_pandas.compute()
        stepm_pandas.superior_models
        numeric_locs = np.argwhere(adj_models.columns.isin(stepm_pandas.superior_models)).squeeze()
        numeric_locs.sort()
        assert_equal(np.array(stepm.superior_models), numeric_locs)
Esempio n. 4
0
    def test_str_repr(self):
        stepm = StepM(self.benchmark_series, self.models, size=0.10)
        expected = 'StepM(FWER (size): 0.10, studentization: asymptotic, bootstrap: ' + str(stepm.spa.bootstrap) + ')'
        assert_equal(str(stepm), expected)
        expected = expected[:-1] + ', ID: ' + hex(id(stepm)) + ')'
        assert_equal(stepm.__repr__(), expected)

        expected = ('<strong>StepM</strong>('
                    '<strong>FWER (size)</strong>: 0.10, '
                    '<strong>studentization</strong>: asymptotic, '
                    '<strong>bootstrap</strong>: ' + str(stepm.spa.bootstrap) + ', ' +
                    '<strong>ID</strong>: ' + hex(id(stepm)) + ')')

        assert_equal(stepm._repr_html_(), expected)

        stepm = StepM(self.benchmark_series, self.models, size=0.05, studentize=False)
        expected = 'StepM(FWER (size): 0.05, studentization: none, bootstrap: ' + str(stepm.spa.bootstrap) + ')'
        assert_equal(expected, str(stepm))
 def test_superior_models(self):
     adj_models = self.models - linspace(-0.4, 0.4, self.k)
     stepm = StepM(self.benchmark, adj_models, reps=120)
     stepm.compute()
     superior_models = stepm.superior_models
     spa = SPA(self.benchmark, adj_models, reps=120)
     spa.compute()
     spa.pvalues
     spa.critical_values(0.05)
     spa.better_models(0.05)
     adj_models = self.models_df - linspace(-3.0, 3.0, self.k)
     stepm = StepM(self.benchmark_series, adj_models, reps=120)
     stepm.compute()
     superior_models = stepm.superior_models
Esempio n. 6
0
 def test_superior_models(self):
     adj_models = self.models - linspace(-0.4, 0.4, self.k)
     stepm = StepM(self.benchmark, adj_models, reps=120)
     stepm.compute()
     superior_models = stepm.superior_models
     spa = SPA(self.benchmark, adj_models, reps=120)
     spa.compute()
     spa.pvalues
     spa.critical_values(0.05)
     spa.better_models(0.05)
     adj_models = self.models_df - linspace(-3.0, 3.0, self.k)
     stepm = StepM(self.benchmark_series, adj_models, reps=120)
     stepm.compute()
     superior_models = stepm.superior_models
    def test_str_repr(self):
        stepm = StepM(self.benchmark_series, self.models, size=0.10)
        expected = 'StepM(FWER (size): 0.10, studentization: asymptotic, bootstrap: ' + str(
            stepm.spa.bootstrap) + ')'
        assert_equal(str(stepm), expected)
        expected = expected[:-1] + ', ID: ' + hex(id(stepm)) + ')'
        assert_equal(stepm.__repr__(), expected)

        expected = ('<strong>StepM</strong>('
                    '<strong>FWER (size)</strong>: 0.10, '
                    '<strong>studentization</strong>: asymptotic, '
                    '<strong>bootstrap</strong>: ' + str(stepm.spa.bootstrap) +
                    ', ' + '<strong>ID</strong>: ' + hex(id(stepm)) + ')')

        assert_equal(stepm._repr_html_(), expected)

        stepm = StepM(self.benchmark_series,
                      self.models,
                      size=0.05,
                      studentize=False)
        expected = 'StepM(FWER (size): 0.05, studentization: none, bootstrap: ' + str(
            stepm.spa.bootstrap) + ')'
        assert_equal(expected, str(stepm))
Esempio n. 8
0
 def test_all_superior(self):
     adj_models = self.models - 100.0
     stepm = StepM(self.benchmark, adj_models, size=0.10)
     stepm.compute()
     assert_equal(len(stepm.superior_models), self.models.shape[1])
Esempio n. 9
0
    def test_single_model(self):
        stepm = StepM(self.benchmark, self.models[:,0], size=0.10)
        stepm.compute()

        stepm = StepM(self.benchmark_series, self.models_df.iloc[:,0])
        stepm.compute()
Esempio n. 10
0
 def test_errors(self):
     stepm = StepM(self.benchmark, self.models, size=0.10)
     with pytest.raises(RuntimeError):
         stepm.superior_models
Esempio n. 11
0
 def test_all_superior(self):
     adj_models = self.models - 100.0
     stepm = StepM(self.benchmark, adj_models, size=0.10)
     stepm.compute()
     assert_equal(len(stepm.superior_models), self.models.shape[1])
Esempio n. 12
0
    def test_single_model(self):
        stepm = StepM(self.benchmark, self.models[:, 0], size=0.10)
        stepm.compute()

        stepm = StepM(self.benchmark_series, self.models_df.iloc[:, 0])
        stepm.compute()
Esempio n. 13
0
    def test_equivalence(self):
        adj_models = self.models - linspace(-2.0, 2.0, self.k)
        stepm = StepM(self.benchmark, adj_models, size=0.20, reps=200)
        stepm.seed(23456)
        stepm.compute()

        adj_models = self.models_df - linspace(-2.0, 2.0, self.k)
        stepm_pandas = StepM(self.benchmark_series,
                             adj_models,
                             size=0.20,
                             reps=200)
        stepm_pandas.seed(23456)
        stepm_pandas.compute()
        stepm_pandas.superior_models
        numeric_locs = np.argwhere(
            adj_models.columns.isin(stepm_pandas.superior_models)).squeeze()
        numeric_locs.sort()
        assert_equal(np.array(stepm.superior_models), numeric_locs)