Skip to content

Feature/intervention#63

Merged
van-dai-vuong merged 6 commits into
mainfrom
feature/intervention
Jan 14, 2026
Merged

Feature/intervention#63
van-dai-vuong merged 6 commits into
mainfrom
feature/intervention

Conversation

@van-dai-vuong

Copy link
Copy Markdown
Collaborator

Description

This PR introduces the intervention feature to model and skf. Users can make interventions in two ways: (1) add interventions (at single or multiple time steps) to mean and variance for a specific hidden state directly, and (2) create an extra hidden state for intervention under Intervention component, then specify the hidden state which will be added the intervention.

Note: at the moment, when using (2), should add one intervention hidden state per intervention event.

Changes Made

model.filter, model.forecast, skf.filter, Data_process

Related Issue(s)

NA.

Checklist

  • I have followed the project's coding conventions and style guidelines.
  • I have updated or added documentation where necessary.
  • I have rebased my branch onto the latest main (or relevant) branch.
  • I have verified that no sensitive data, plots, or files are included.
  • I have run all previous examples successfully, with no errors.
  • I have tested my changes locally using the following commands/tests:

Notes for Reviewers

pytest

Run:

  • python -m examples.intervention_direct for testing model: multiple interventions, directly modify hidden states.
  • python -m examples.intervention_add_state for testing model: a single intervention, add intervention hidden state.
  • python -m examples.skf_intervention_direct for testing skf.
  • python -m examples.skf_intervention_add_statefor testing skf.

@zhanwen-xin zhanwen-xin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All good from my side

@MichelWU99

Copy link
Copy Markdown
Collaborator

Hi,

When I try to launch the example I got a return of a bug :

Traceback (most recent call last):
File "/Users/michelwu/miniconda3/envs/canari/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/michelwu/miniconda3/envs/canari/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/michelwu/new_canari/examples/intervention_add_state.py", line 83, in
(mu_validation_preds, std_validation_preds, states) = model.lstm_train(
File "/Users/michelwu/new_canari/src/canari/model.py", line 1877, in lstm_train
self.smoother()
File "/Users/michelwu/new_canari/src/canari/model.py", line 1807, in smoother
self.lstm_states_history[0] = self.lstm_net.get_lstm_states(
TypeError: Sequential.get_lstm_states() takes 1 positional argument but 2 were given

Is it only from my side ?

@van-dai-vuong

van-dai-vuong commented Jan 12, 2026

Copy link
Copy Markdown
Collaborator Author

Hi,

When I try to launch the example I got a return of a bug :

Traceback (most recent call last): File "/Users/michelwu/miniconda3/envs/canari/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/Users/michelwu/miniconda3/envs/canari/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/Users/michelwu/new_canari/examples/intervention_add_state.py", line 83, in (mu_validation_preds, std_validation_preds, states) = model.lstm_train( File "/Users/michelwu/new_canari/src/canari/model.py", line 1877, in lstm_train self.smoother() File "/Users/michelwu/new_canari/src/canari/model.py", line 1807, in smoother self.lstm_states_history[0] = self.lstm_net.get_lstm_states( TypeError: Sequential.get_lstm_states() takes 1 positional argument but 2 were given

Is it only from my side ?

@MichelWU99 I think you need to uninstall and install pytagi again. Do pip uninstall pytagi, then pip install pytagi. I checked, it runs on the server as well.

@MichelWU99 MichelWU99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All good from my side after uninstalling and installing pytagi

@van-dai-vuong van-dai-vuong merged commit fe7f0cd into main Jan 14, 2026
2 checks passed
@van-dai-vuong van-dai-vuong deleted the feature/intervention branch January 14, 2026 14:49
van-dai-vuong added a commit that referenced this pull request Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants