コード例 #1
0
    def from_dict(cls, copula_dict):
        """Create a new instance from dictionary.

        Args:
            copula_dict: `dict` with the parameters to replicate the copula.
            Like the output of `Multivariate.to_dict`

        Returns:
            Multivariate: Instance of the copula defined on the parameters.
        """

        copula_class = import_object(copula_dict['type'])
        return copula_class.from_dict(copula_dict)
コード例 #2
0
ファイル: gaussian.py プロジェクト: Chrisebell24/Copulas
    def fit(self, X):
        """Compute the distribution for each variable and then its covariance matrix.

        Args:
            X: `numpy.ndarray` or `pandas.DataFrame`. Data to model.

        Returns:
            None
        """
        LOGGER.debug('Fitting Gaussian Copula')
        column_names = self.get_column_names(X)
        distribution_class = import_object(self.distribution)

        for column_name in column_names:
            self.distribs[column_name] = distribution_class()
            column = self.get_column(X, column_name)
            self.distribs[column_name].fit(column)

        self.covariance = self._get_covariance(X)
        self.fitted = True
コード例 #3
0
    def fit(self, X):
        """Compute the distribution for each variable and then its covariance matrix.

        Args:
            X(numpy.ndarray or pandas.DataFrame): Data to model.

        Returns:
            None
        """
        LOGGER.debug('Fitting Gaussian Copula')
        distribution_class = import_object(self.distribution)

        if not isinstance(X, pd.DataFrame):
            X = pd.DataFrame(X)

        for column_name, column in X.items():
            self.distribs[column_name] = distribution_class()
            self.distribs[column_name].fit(column)

        self.covariance = self._get_covariance(X)
        self.fitted = True
コード例 #4
0
ファイル: base.py プロジェクト: merz9b/Copulas
 def from_dict(cls, param_dict):
     """Create new instance from dictionary."""
     distribution_class = import_object(param_dict['type'])
     return distribution_class.from_dict(param_dict)