Skip to content

Feature/ensembling - #5

Merged
hrzn merged 7 commits into
masterfrom
feature/ensembling
Mar 15, 2019
Merged

Feature/ensembling#5
hrzn merged 7 commits into
masterfrom
feature/ensembling

Conversation

@hrzn

@hrzn hrzn commented Mar 14, 2019

Copy link
Copy Markdown
Contributor

The novelties:

  • Unit tests for TimeSeries class
  • Base class RegressiveModel
  • An implementation of this: StandardRegressiveModel, which allows ensembling. By default it uses linear regression to predict one time series from others, but it can use any scikit-learn regression model.

Screenshot 2019-03-12 at 16 32 14

@hrzn
hrzn requested review from Digma, kstyrc and weronikadranka March 14, 2019 08:29

@kstyrc kstyrc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks great! GJ @hrzn !


m = ARIMA(series.values(),
order=(self.p, self.d, self.q)) if self.d > 0 else ARMA(values, order=(self.p, self.q))
self.model = m.fit(disp=0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

statsmodels.tsa.arima_model.ARIMA.fit() returns the model results, whereas our implementation of Arima.fit() doesn't return anything. Shouldn't we return self? Example code that could be interesting:

arima = Arima()
series_pred = arima.fit(series_train).predict(n_test)

Or (in the future)

arima = Arima()
arima.fit(series_train).save('my_fancy_model.ml')

Side note, in sklearn, fit() methods also return self, and in Keras, fit() return a History() object, which contains results, which is similar to statsmodels.tsa.arima_model.ARIMA.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll try to add this at some point soon :)

@hrzn
hrzn merged commit 66f4bb5 into master Mar 15, 2019
@endrjuskr
endrjuskr deleted the feature/ensembling branch May 5, 2020 15:18
mkos added a commit that referenced this pull request Sep 28, 2021
daidahao added a commit to daidahao/darts that referenced this pull request Mar 27, 2026
Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>
dennisbader added a commit that referenced this pull request Jun 19, 2026
* Fix a bug in `_test_stationarity`

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix a bug in `SequentialTorchInferenceDataset`

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Init torch explainer

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add notebooks for exploration

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Use KernelExplainer instead of Deep

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add todo note

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Collate `np.ndarray` directly & feature names

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `summary_plot`

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `force_plot_from_ts`

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Validate `__getitem__` index

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Apply inference encodings for foreground series

This ensure that the last possible index is always explained when
`add_encoders` is used.

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Move device for batch processing

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add exact explainer

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add TCN handling

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Speed up and set module to eval mode

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Misc

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix a RNN test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Handle RNN module

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix a SHAP test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix feature names

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add static cov support

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix typos

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Remove static cov todo

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add prob support

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update doc dependencies

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update sklearn notebook

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix a typo

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Rename to SKLearnExplainer

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Rename #2

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Rename #3

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Remove model attr

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix capitailisation

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Cap #2

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update SKLearn explainer doc

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Cap #3

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update SK force plot and summary plot

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update force plot name

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update torch force and summary plots

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update SK doc

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update SK header

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update SK force plot docstring

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add static cov convention

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Remove RNN docstring errors

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Torch explainer doc header

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update header doc

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add torch explainer docstring

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `explain()` docstring

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `summary_plot()` and `force_plot()` docstring

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `explain_single()` to torch explainer

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix bugs for shap object

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update result classes docstring

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update result header

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `explain_single` docstring

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add `explain_single()` to sklearn explainer

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update doc header and add note

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add creation test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add chronos2 to tests

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add comments

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add explain test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Expand explain test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Reduce test time

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add explain without foreground test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add explain with shap methods test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add explain probabilistic test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_explain_multiple_series

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add explain single test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add explain single without background test

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test explain single shape methods

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_explain_single_probabilistic_model

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_summary_plot

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_force_plot

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_waterfall_plot

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve code coverage of torch explainer

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve code coverage

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve tests

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_explain_single

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve code cov.

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve code cov.

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve code coverage

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve code cov.

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Improve #5

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add test_explain_univariate for torch

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Bugfix: trim series when future cov too short

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Bugfix: too short future covs. when training

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add notebook draft

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix a notebook bug

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Revert "Update doc dependencies"

This reverts commit c2899635ba90c1e9270d6e969e4d35304d5d0e85.

* Update Makefile for faster compilation

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Complete global explanation

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add Local Explainability

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add force plot

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Complete local explanability

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add pytorch model to notebook

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update header

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add labels to info and warning

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Supress warnings

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update docs and remove `raise_if`

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix typos

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Complete notebook

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Remove unused files

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Change default to permutation

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add reference to notebook

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update PR note

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Rename to 29- notebook

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add notebook links

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update tests

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Pass along optional kwargs to SHAP

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update `plot_kwargs` in tests

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Relax base value threshold in tests

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Add API reference

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update changelog

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update PR note

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update #2

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix typos

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Lint

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Update CHANGELOG

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix nb name typos

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* Fix Partition explainer typo

Co-authored-by: Zhihao Dai <zhihao.dai@eng.ox.ac.uk>

* update docs

* some updates

* rename explainability notebook

* further updates

* revert shap renaming

* generalize shap explainers

* refactor explain single series

* refactor explain

* renove old explainers

* fix some issues

* centralize torch and sklearn logic in single ShapExplainer

* centralize torch and sklearn logic in single ShapExplainer

* centralize torch and sklearn logic in single ShapExplainer

* make torch explainer use hist fc utils

* update notebook

* update changelog

* update docs for explainability result

* fix issues in explanations

* refactor explain single

* further improvements

* improve naming of shap adapters

* compute lagged feature names with dedicated function

* finalize torch shap adapter

* finish example notebook

* support quantile regression for sklearn models

* update changelog

* improve code coverage

* finalize docs

* update changelog

* update notebook

---------

Co-authored-by: dennisbader <dennis.bader@gmx.ch>
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.

3 participants