Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def fit(self, table_data):
"""Fit the model to the table.
Impute the table data before fit the model.
Args:
table_data (pandas.DataFrame):
Data to be fitted.
"""
table_data = impute(table_data)
self.model = multivariate.GaussianMultivariate(distribution=self.distribution)
self.model.fit(table_data)
in order to set expected parameters for the copula.
Args:
dict:
Copula flatten parameters.
"""
parameters = unflatten_dict(parameters)
parameters.setdefault('fitted', True)
parameters.setdefault('distribution', self.distribution)
parameters = self._unflatten_gaussian_copula(parameters)
for param in parameters['distribs'].values():
param.setdefault('type', self.distribution)
param.setdefault('fitted', True)
self.model = multivariate.GaussianMultivariate.from_dict(parameters)
Add additional keys after unflatte the parameters
in order to set expected parameters for the copula.
Args:
dict:
Copula flatten parameters.
unflatten (bool):
Whether the parameters need to be unflattened or not.
"""
if unflatten:
parameters = unflatten_dict(parameters)
parameters.setdefault('distribution', self._distribution)
parameters = self._unflatten_gaussian_copula(parameters)
self._model = copulas.multivariate.GaussianMultivariate.from_dict(parameters)