# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class GaussianMixtureParams(BaseModel):
    """
    Parameters for Gaussian Mixture Model clustering.
    """ # noqa: E501
    n_components: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=1, description="Number of mixture components")
    covariance_type: Optional[StrictStr] = Field(default='full', description="Type of covariance parameters ('full', 'tied', 'diag', 'spherical')")
    tol: Optional[Union[StrictFloat, StrictInt]] = Field(default=0.001, description="Convergence threshold")
    reg_covar: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = Field(default=1.0E-6, description="Regularization added to the diagonal of covariance")
    max_iter: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=100, description="Maximum number of EM iterations")
    n_init: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=1, description="Number of initializations to perform")
    init_params: Optional[StrictStr] = Field(default='kmeans', description="Method used to initialize weights, means and covariances ('kmeans' or 'random')")
    weights_init: Optional[List[Any]] = Field(default=None, description="Initial weights")
    means_init: Optional[List[Any]] = Field(default=None, description="Initial means")
    precisions_init: Optional[List[Any]] = Field(default=None, description="Initial precisions")
    random_state: Optional[StrictInt] = Field(default=42, description="Random seed for reproducibility")
    warm_start: Optional[StrictBool] = Field(default=False, description="If True, use the solution of the last fit as initialization")
    verbose: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=0, description="Enable verbose output")
    verbose_interval: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=10, description="Number of iterations between each verbose message")
    __properties: ClassVar[List[str]] = ["n_components", "covariance_type", "tol", "reg_covar", "max_iter", "n_init", "init_params", "weights_init", "means_init", "precisions_init", "random_state", "warm_start", "verbose", "verbose_interval"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of GaussianMixtureParams from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of GaussianMixtureParams from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "n_components": obj.get("n_components") if obj.get("n_components") is not None else 1,
            "covariance_type": obj.get("covariance_type") if obj.get("covariance_type") is not None else 'full',
            "tol": obj.get("tol") if obj.get("tol") is not None else 0.001,
            "reg_covar": obj.get("reg_covar") if obj.get("reg_covar") is not None else 1.0E-6,
            "max_iter": obj.get("max_iter") if obj.get("max_iter") is not None else 100,
            "n_init": obj.get("n_init") if obj.get("n_init") is not None else 1,
            "init_params": obj.get("init_params") if obj.get("init_params") is not None else 'kmeans',
            "weights_init": obj.get("weights_init"),
            "means_init": obj.get("means_init"),
            "precisions_init": obj.get("precisions_init"),
            "random_state": obj.get("random_state") if obj.get("random_state") is not None else 42,
            "warm_start": obj.get("warm_start") if obj.get("warm_start") is not None else False,
            "verbose": obj.get("verbose") if obj.get("verbose") is not None else 0,
            "verbose_interval": obj.get("verbose_interval") if obj.get("verbose_interval") is not None else 10
        })
        return _obj


