Wrapper for GMM
Drop-in replacement for GMM from gmr
Implements:
.from_samples(...)
.sample(...)
.predict(...)
.to_responsibilities(...)
.condition(...)
Carefully replicates gmr behavior, including:
Manual initialization when n_samples < 2
Safe handling of degenerate weights (e.g., nan or negative)
Adds warnings instead of exceptions for better debug experience
This pull request includes several changes across multiple files to improve code readability and consistency. The most important changes involve adding missing imports, reformatting code for better readability, and updating string formatting.
Code Readability Improvements:
-
bamt/networks/base.py: Reformatted import statements and long lines to improve readability. [1] [2] [3] [4] [5] -
bamt/nodes/conditional_mixture_gaussian_node.py: Reformatted long lines and updated thechooseandpredictmethods for better readability. [1] [2] [3] [4]
Consistency Updates:
-
bamt/external/pyitlib/DiscreteRandomVariableUtils.py: Updated string formatting to use double quotes and reformatted long lines for consistency. [1] [2] [3] [4] -
bamt/nodes/conditional_logit_node.py: Reformatted long lines and updated string formatting for consistency.
Minor Additions:
- Added missing author information in test files. [1] [2] [3] [4]
Bug Fixes:
-
bamt/external/pyitlib/DiscreteRandomVariableUtils.py: Fixed assertion statements and improved error handling in_estimate_probabilitiesfunction. [1] [2] [3]
Import Updates:
-
bamt/nodes/conditional_mixture_gaussian_node.py: Replaced import fromgmrtobamt.utils.gmm_wrapperforGMM.
Обновил исходя из PR review, добавил комменты, докстринги и остальное
Разве что надо убрать gmr теперь из requirements и pyproject.toml
@jrzkaminski убирать тогда надо аккуратно -- перенести например в группу тестирования
Removed redundant validation from from_samples() method and cleaned up outdated comments. Confirmed that sklearn.GaussianMixture already handles insufficient data with its internal validation logic (as @Roman223 suggested).
All tests pass Suggest moving gmr removal and behavioral test redesign into the next PR, along with a cleaner initialization approach (as suggested by Roman) using sklearn subclassing or controlled parameter setup.
This will allow us to fully drop dependency on gmr and transition to robust behavioral testing (log-likelihood checks, cluster validation).