-
Notifications
You must be signed in to change notification settings - Fork 13
New Estimation interface Implementation #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GWeindel
merged 31 commits into
GWeindel:devel
from
kiante-fernandez:estimation-interface-merge
Aug 6, 2026
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
725e0aa
Fix: Handle conflicting metadata columns in read_mne_data
kiante-fernandez bc44081
Implement parameter estimation utilities and MCMC estimator integration
kiante-fernandez e0d7e81
Enhance MCMCEstimator and EventModel: Add support for multiple starti…
kiante-fernandez 670dd39
Enhance MCMC Estimator with JAX Support and STILL Support Backward Co…
kiante-fernandez 33d8fc4
Merge upstream/devel with estimation interface refactor
kiante-fernandez 4ca187a
Add estimation framework tests
kiante-fernandez 869c15c
Add test for estimation interface integration
kiante-fernandez 9c0c754
Add estimation utility functions and complete test suite
kiante-fernandez 0106d35
Fix production issues in estimation interface
kiante-fernandez 58ffcb9
Remove estimation interface test file
kiante-fernandez a8b3754
Add integration test for estimation interface with TrialData setup
kiante-fernandez 1c4b050
Remove obsolete integration tests for estimation interface and MCMC e…
kiante-fernandez e128257
Enhance EMEstimator to support multiple starting points and refactor …
kiante-fernandez d0f1729
Remove deprecated JAX and MCMC estimator implementations
kiante-fernandez 32bbe5b
Remove MCMC optional dependency from project configuration
kiante-fernandez d93e088
lintting and testing
kiante-fernandez 00ea919
Merge upstream/devel into estimation-interface-merge
kiante-fernandez c7a6eac
Re-extract EM into EMEstimator on top of upstream's implementation
kiante-fernandez dc6bc58
Rewrite estimation interface tests against the current API
kiante-fernandez 01c0dfe
Drop redundant inline comments in estimation interface tests
kiante-fernandez 1937973
Keep only the noqa codes that fire
kiante-fernandez 151b35e
Remove dead weight left by the estimator extraction
kiante-fernandez 59a0fce
Load test data once per module instead of once per test
kiante-fernandez 7b8992c
Only build a process pool when there are starting points to spread
kiante-fernandez 5ea23ed
Give estimators a public likelihood surface with per-trial values
kiante-fernandez 19f0018
Removed leftover
GWeindel 43c2283
Remove event_width
GWeindel 1e5823f
Check the per-trial sum invariant in float64, over distinct trials
kiante-fernandez 7eed4fe
Merge remote-tracking branch 'origin/devel' into pr-244
GWeindel f563816
Merge pull request #1 from GWeindel/pr-244
kiante-fernandez 6d75bd4
Merge remote-tracking branch 'upstream/devel' into estimation-interfa…
kiante-fernandez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,4 @@ docs/build | |
| .coverage | ||
|
|
||
| .jupyter | ||
| .venv/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """Parameter estimation methods for HMP models.""" | ||
|
|
||
| from .base import BaseEstimator, EstimationResult | ||
| from .em import EMEstimator | ||
|
|
||
| __all__ = [ | ||
| "BaseEstimator", | ||
| "EstimationResult", | ||
| "EMEstimator", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| """Base classes for parameter estimation in HMP models.""" | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from dataclasses import dataclass, field | ||
| from typing import Any, Optional | ||
|
|
||
| import numpy as np | ||
|
|
||
| from hmp.patterndata import PatternData | ||
|
|
||
|
|
||
| @dataclass | ||
| class EstimationResult: | ||
| """Results from parameter estimation. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| channel_pars : np.ndarray | ||
| Estimated channel parameters | ||
| time_pars : np.ndarray | ||
| Estimated time distribution parameters | ||
| likelihood : float | ||
| Final log-likelihood value | ||
| converged : bool | ||
| Whether estimation converged | ||
| n_iterations : int | ||
| Number of iterations performed | ||
| diagnostics : dict | ||
| Estimation-specific diagnostic information | ||
| uncertainty : dict, optional | ||
| Parameter uncertainty measures (for Bayesian methods) | ||
| """ | ||
|
|
||
| channel_pars: np.ndarray | ||
| time_pars: np.ndarray | ||
| likelihood: float | ||
| converged: bool | ||
| n_iterations: int | ||
| diagnostics: dict[str, Any] = field(default_factory=dict) | ||
| uncertainty: Optional[dict[str, Any]] = None | ||
|
|
||
|
|
||
| class BaseEstimator(ABC): | ||
| """Abstract base class for parameter estimation methods. | ||
|
|
||
| This class defines the interface that all parameter estimation methods | ||
| must implement to work with HMP models. | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| """Initialize the estimator.""" | ||
| self.fitted = False | ||
|
|
||
| @abstractmethod | ||
| def fit( | ||
| self, | ||
| model, | ||
| pattern_data: PatternData, | ||
| initial_channel_pars: np.ndarray, | ||
| initial_time_pars: np.ndarray, | ||
| groups: np.ndarray = None, | ||
| cpus: int = 1, | ||
| ) -> EstimationResult: | ||
| """Estimate model parameters. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| model : BaseModel | ||
| Model providing the likelihood and the expectation step. | ||
| pattern_data : PatternData | ||
| Preprocessed data cross-correlated with the pattern of the model. | ||
| initial_channel_pars : np.ndarray | ||
| Initial channel parameter values, one per starting point. | ||
| initial_time_pars : np.ndarray | ||
| Initial time distribution parameter values, one per starting point. | ||
| groups : np.ndarray, optional | ||
| Array indicating the groups for grouping modeling. Default is None. | ||
| cpus : int, optional | ||
| Number of cores to use in multiprocessing functions. Default is 1. | ||
|
|
||
| Returns | ||
| ------- | ||
| EstimationResult | ||
| Results of parameter estimation | ||
| """ | ||
| pass | ||
|
|
||
| @property | ||
| def is_fitted(self) -> bool: | ||
| """Whether the estimator has been fitted.""" | ||
| return self.fitted | ||
|
|
||
| def get_method_name(self) -> str: | ||
| """Get the name of the estimation method.""" | ||
| return self.__class__.__name__ | ||
|
|
||
| def supports_uncertainty(self) -> bool: | ||
| """Whether this estimator provides uncertainty estimates.""" | ||
| return False | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.