initialize#

MultiStartRefiningInitializer.initialize(X, families, random_state=None)#

Build a starting mixture from the sample.

The method checks the input, creates the random generator, calls _initialize, checks its result and returns that mixture unchanged. The method must not be overridden; type checkers flag an override.

Параметры:
  • X (ArrayLike) – The sample; a read-only one-dimensional float64 copy of it is passed to the initializer step and used to check the result, so the caller’s array is never modified.

  • families (Sequence[ParametricFamily]) – One family per component of the mixture. A parametrization is chosen and parameters are fixed through family.view(...).

  • random_state (int | numpy.random.Generator | None, optional) – Source of randomness. An integer seed makes the same arguments produce the same mixture independently of previous calls. A generator is used in place and advances, so two calls with the same generator produce different mixtures. None uses fresh entropy.

Результат:

The starting mixture; component j belongs to families[j].

Тип результата:

MixtureModel

Исключение:
  • ValueError – If the input is invalid, or if the initializer step returned a number of components different from the number of families or components not ordered as families. The latter means an error in the initializer implementation.

  • TypeError – If an element of families is not a parametric family.

  • InitializationError – If the log-likelihood of the starting mixture on the sample is not finite. The message is "The log-likelihood of the starting mixture on the sample is {value}.", followed by " {m} of {n} sample points are not covered by any component, for example {examples}." if some points have the log-density -inf, and by " The density of the mixture is undefined at {m} of {n} sample points, for example {examples}." if some points have the log-density NaN or +inf. examples are the values of at most the first three such points, separated by ", ". NumPy warnings while the log-likelihood is computed are suppressed: the error explains the failure. Exceptions raised by _initialize, such as an InitializationError of an unlucky run, pass through unchanged.