Ejemplo n.º 1
0
    def test_offline_changepoint_gauss_univ(self):
        """changepoint.BayesOffline: Gauss, univariate

        This is a regression test against the output of the original
        implementation.
        """
        f = offline.BayesOffline("const", "gauss", engine=self.engine)
        prob, Q, P, Pcp = f.find_changepoints(
            self.data, truncate=-20, full_output=True)
        orig = np.load(os.path.join(data_path, "offline_gauss_univ.npz"))
        np.testing.assert_allclose(Q, orig["Q"])
        np.testing.assert_allclose(P, orig["P"])
        o_pcp = np.hstack([np.full((Pcp.shape[0], 1), -np.inf), orig["Pcp"]])
        np.testing.assert_allclose(Pcp, o_pcp, rtol=1e-6)
Ejemplo n.º 2
0
 def test_engine(self):
     """changepoint.BayesOffline: set numba engine"""
     f = offline.BayesOffline("const", "gauss", engine=self.engine)
     assert hasattr(f.segmentation, "py_func")
Ejemplo n.º 3
0
 def test_find_changepoints_prob_thresh(self):
     """changepoint.BayesOffline.find_changepoints: `prob_threshold`"""
     f = offline.BayesOffline("const", "gauss", engine=self.engine)
     cp = f.find_changepoints(self.data, truncate=-20, prob_threshold=0.2)
     np.testing.assert_array_equal(cp, [30, 69])
Ejemplo n.º 4
0
 def test_engine(self):
     """changepoint.BayesOffline: set python engine"""
     f = offline.BayesOffline("const", "gauss", engine=self.engine)
     self.assertIsInstance(f.segmentation, types.FunctionType)