Skip to content
Merged
Show file tree
Hide file tree
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 Jul 15, 2025
bc44081
Implement parameter estimation utilities and MCMC estimator integration
kiante-fernandez Jul 17, 2025
e0d7e81
Enhance MCMCEstimator and EventModel: Add support for multiple starti…
kiante-fernandez Jul 18, 2025
670dd39
Enhance MCMC Estimator with JAX Support and STILL Support Backward Co…
kiante-fernandez Jul 22, 2025
33d8fc4
Merge upstream/devel with estimation interface refactor
kiante-fernandez Aug 17, 2025
4ca187a
Add estimation framework tests
kiante-fernandez Aug 17, 2025
869c15c
Add test for estimation interface integration
kiante-fernandez Aug 17, 2025
9c0c754
Add estimation utility functions and complete test suite
kiante-fernandez Aug 17, 2025
0106d35
Fix production issues in estimation interface
kiante-fernandez Aug 17, 2025
58ffcb9
Remove estimation interface test file
kiante-fernandez Aug 17, 2025
a8b3754
Add integration test for estimation interface with TrialData setup
kiante-fernandez Aug 17, 2025
1c4b050
Remove obsolete integration tests for estimation interface and MCMC e…
kiante-fernandez Aug 17, 2025
e128257
Enhance EMEstimator to support multiple starting points and refactor …
kiante-fernandez Aug 17, 2025
d0f1729
Remove deprecated JAX and MCMC estimator implementations
kiante-fernandez Aug 17, 2025
32bbe5b
Remove MCMC optional dependency from project configuration
kiante-fernandez Aug 17, 2025
d93e088
lintting and testing
kiante-fernandez Aug 17, 2025
00ea919
Merge upstream/devel into estimation-interface-merge
kiante-fernandez Jul 31, 2026
c7a6eac
Re-extract EM into EMEstimator on top of upstream's implementation
kiante-fernandez Jul 31, 2026
dc6bc58
Rewrite estimation interface tests against the current API
kiante-fernandez Jul 31, 2026
01c0dfe
Drop redundant inline comments in estimation interface tests
kiante-fernandez Jul 31, 2026
1937973
Keep only the noqa codes that fire
kiante-fernandez Jul 31, 2026
151b35e
Remove dead weight left by the estimator extraction
kiante-fernandez Aug 1, 2026
59a0fce
Load test data once per module instead of once per test
kiante-fernandez Aug 1, 2026
7b8992c
Only build a process pool when there are starting points to spread
kiante-fernandez Aug 1, 2026
5ea23ed
Give estimators a public likelihood surface with per-trial values
kiante-fernandez Aug 1, 2026
19f0018
Removed leftover
GWeindel Aug 1, 2026
43c2283
Remove event_width
GWeindel Aug 1, 2026
1e5823f
Check the per-trial sum invariant in float64, over distinct trials
kiante-fernandez Aug 1, 2026
7eed4fe
Merge remote-tracking branch 'origin/devel' into pr-244
GWeindel Aug 4, 2026
f563816
Merge pull request #1 from GWeindel/pr-244
kiante-fernandez Aug 5, 2026
6d75bd4
Merge remote-tracking branch 'upstream/devel' into estimation-interfa…
kiante-fernandez Aug 5, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ docs/build
.coverage

.jupyter
.venv/
4 changes: 3 additions & 1 deletion hmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
basedata,
crossvalidation,
distributions,
estimators,
io,
models,
patterndata,
Expand All @@ -22,4 +23,5 @@


__all__ = ["models", "simulations", "utils", "visu", "io", "patterns", "projectors",
"patterndata", "basedata", "distributions" ,"crossvalidation", "__version__"]
"patterndata", "basedata", "distributions" ,"crossvalidation", "estimators",
"__version__"]
1 change: 0 additions & 1 deletion hmp/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,3 @@ def mean_to_scale(self, mean: float) -> float:
The calculated scale parameter.
"""
return mean / self.gamma_func(1 + 1 / self.shape)

10 changes: 10 additions & 0 deletions hmp/estimators/__init__.py
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",
]
99 changes: 99 additions & 0 deletions hmp/estimators/base.py
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

Comment thread
GWeindel marked this conversation as resolved.
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
Loading