def test_to_dict_sample_size(self): model = GaussianKDE(sample_size=10) model.fit(self.constant) params = model.to_dict() assert params['type'] == 'copulas.univariate.gaussian_kde.GaussianKDE' assert len(params['dataset']) == 10
def test_to_dict_constant(self): model = GaussianKDE() model.fit(self.constant) params = model.to_dict() assert params == { 'type': 'copulas.univariate.gaussian_kde.GaussianKDE', 'dataset': [5] * 100 }
def test_to_dict_from_dict(self): model = GaussianKDE() model.fit(self.data) sampled_data = model.sample(50) params = model.to_dict() model2 = GaussianKDE.from_dict(params) pdf = model.probability_density(sampled_data) pdf2 = model2.probability_density(sampled_data) assert np.all(np.isclose(pdf, pdf2, atol=0.01)) cdf = model.cumulative_distribution(sampled_data) cdf2 = model2.cumulative_distribution(sampled_data) assert np.all(np.isclose(cdf, cdf2, atol=0.01))