예제 #1
0
    def get_params(self, deep=True):
        """Overrides superclass get_params() to allow superclass hyperparameters
          to be returned as well.

          This allows for tuning any parameters from the parent KMeans class
          without having to list each parameter in the KMeansMM __init__() function.
          Taken from https://stackoverflow.com/questions/51430484/how-to-subclass-a-vectorizer-in-scikit-learn-without-repeating-all-parameters-in.

        Parameters
        ----------
        deep : boolean, optional
            If True, will return the parameters for this estimator and
            contained subobjects that are estimators.

        Returns
        -------
        params : mapping of string to any
            Parameter names mapped to their values.

        """

        params = super().get_params(deep)
        cp = copy.copy(self)
        cp.__class__ = KMeans
        params.update(KMeans.get_params(cp, deep))
        return params