Skip to content

Commit 64cc60a

Browse files
committed
refactor: change cluster_match_strategy structure, matching methods separated into
greedy, hungarian, permutation methods, also for scoring functions aic and likelihood feat: Enums for matching methods, scoring methods tests: tests that include cluster_match_strategy commented/deleted
1 parent 32a2535 commit 64cc60a

File tree

8 files changed

+622
-1076
lines changed

8 files changed

+622
-1076
lines changed

rework_pysatl_mpest/initializers/__init__.py

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,21 @@
99
1010
initializers provide good starting points for EM algorithm and other optimization
1111
methods, helping to avoid poor local optima and improving convergence.
12-
13-
**Usage Example**
14-
15-
.. code-block:: python
16-
17-
>>> from rework_pysatl_mpest.distributions.exponential import Exponential
18-
>>> from sklearn.cluster import KMeans
19-
>>> from rework_pysatl_mpest.initializers.clusterize_initializer import ClusterizeInitializer
20-
>>> from rework_pysatl_mpest.initializers import ClusterMatchStrategy, EstimationStrategy
21-
>>> from rework_pysatl_mpest.core.mixture import MixtureModel
22-
23-
>>> # Create initializer with KMeans clustering
24-
>>> initializer_cluster = ClusterizeInitializer(
25-
... is_accurate=True,
26-
... is_soft=False,
27-
... clusterizer=KMeans(n_clusters=3)
28-
... )
29-
30-
>>> # Create distribution models to initialize
31-
>>> distributions = [Exponential(loc=0.0, rate=0.1),
32-
>>>Exponential(loc=5.0, rate=0.05), Exponential(loc=10.0, rate=0.01)]
33-
34-
>>> # Generate sample data
35-
>>> mixture = MixtureModel(distributions, [0.3, 0.4, 0.3])
36-
>>> X = mixture.generate(300)
37-
38-
>>> # Perform initialization
39-
>>> mixture_model = initializer_cluster.perform(
40-
... X=X,
41-
... dists=distributions,
42-
... cluster_match_strategy=ClusterMatchStrategy.AKAIKE,
43-
... estimation_strategies=[EstimationStrategy.QFUNCTION] * len(distributions)
44-
... )
45-
46-
>>> # The mixture model is now initialized with estimated parameters
47-
>>> print(f"Number of components: {len(mixture_model.components)}")
48-
>>> print(f"Weights: {mixture_model.weights}")
4912
"""
5013

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

5518
from ._estimation_strategies.q_function import q_function_strategy, q_function_strategy_exponential
56-
from .cluster_match_strategy import (
57-
match_clusters_for_models_akaike,
58-
match_clusters_for_models_log_likelihood,
59-
)
6019
from .clusterize_initializer import ClusterizeInitializer
6120
from .initializer import Initializer
62-
from .strategies import ClusterMatchStrategy, EstimationStrategy
21+
from .strategies import EstimationStrategy
6322

6423
__all__ = [
65-
"ClusterMatchStrategy",
6624
"ClusterizeInitializer",
6725
"EstimationStrategy",
6826
"Initializer",
69-
"match_clusters_for_models_akaike",
70-
"match_clusters_for_models_log_likelihood",
7127
"q_function_strategy",
7228
"q_function_strategy_exponential",
7329
]

0 commit comments

Comments
 (0)