Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions rework_pysatl_mpest/initializers/__init__.py
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In examples we use imports from modules, not files inside module. That's why there is __init__.py files

Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,21 @@

initializers provide good starting points for EM algorithm and other optimization
methods, helping to avoid poor local optima and improving convergence.

**Usage Example**

.. code-block:: python

>>> from rework_pysatl_mpest import Exponential
>>> import numpy as np
>>> from sklearn.cluster import KMeans
>>> from rework_pysatl_mpest.initializers import ClusterizeInitializer
>>> from rework_pysatl_mpest.initializers import ClusterMatchStrategy, EstimationStrategy

>>> # Create initializer with KMeans clustering
>>> initializer_cluster = ClusterizeInitializer(
... is_accurate=True,
... is_soft=False,
... clusterizer=KMeans(n_clusters=3)
... )

>>> # Create distribution models to initialize
>>> distributions = [Exponential(loc=0.0, rate=0.1),
>>>Exponential(loc=5.0, rate=0.05), Exponential(loc=10.0, rate=0.01)]

>>> # Generate sample data
>>> X = np.linspace(0.01, 25.0, 300)

>>> # Perform initialization
>>> mixture_model = initializer_cluster.perform(
... X=X,
... dists=distributions,
... cluster_match_strategy=ClusterMatchStrategy.AKAIKE,
... estimation_strategies=[EstimationStrategy.QFUNCTION] * len(distributions)
... )

>>> # The mixture model is now initialized with estimated parameters
>>> print(f"Number of components: {len(mixture_model.components)}")
>>> print(f"Weights: {mixture_model.weights}")
"""

__author__ = "Viktor Khanukaev"
__copyright__ = "Copyright (c) 2025 PySATL project"
__license__ = "SPDX-License-Identifier: MIT"

from ._estimation_strategies.q_function import q_function_strategy, q_function_strategy_exponential
from .cluster_match_strategy import (
match_clusters_for_models_akaike,
match_clusters_for_models_log_likelihood,
)
from .clusterize_initializer import ClusterizeInitializer
from .initializer import Initializer
from .strategies import ClusterMatchStrategy, EstimationStrategy
from .strategies import EstimationStrategy

__all__ = [
"ClusterMatchStrategy",
"ClusterizeInitializer",
"EstimationStrategy",
"Initializer",
"match_clusters_for_models_akaike",
"match_clusters_for_models_log_likelihood",
"q_function_strategy",
"q_function_strategy_exponential",
]
Loading