simdec 1.0.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,9 @@ __pycache__
7
7
  .cache/*
8
8
  **/.ipynb_checkpoints
9
9
 
10
+ # Env variables with direnv
11
+ .envrc
12
+
10
13
  # OS generated files
11
14
  .DS_Store*
12
15
 
@@ -29,4 +32,6 @@ htmlcov/*
29
32
  build/*
30
33
  dist/*
31
34
  sdist/*
32
- docs/_build
35
+ docs/html
36
+ docs/jupyter_execute
37
+ app.html
@@ -161,3 +161,39 @@ a release:
161
161
  5. Check that release has been deployed to PyPI
162
162
  6. Check documentation is built and deployed to readthedocs
163
163
  7. Check that auto-generated PR is auto-merged on the conda-forge feedstock repo
164
+
165
+ ## Dashboard
166
+ A live dashboard is available at:
167
+
168
+ https://simdec.io
169
+
170
+ The DNS records are available on CPanel and the rest is hosted on Google Cloud
171
+ Platform.
172
+
173
+ Developing locally requires the installation of GCP CLI and Docker engine.
174
+
175
+ A few helper commands are provided in the Makefile.
176
+
177
+ ### Local use
178
+
179
+ The dashboard can be run locally using:
180
+
181
+ make serve-dev
182
+
183
+ If you want to test OAuth, you need to export the following env variables:
184
+
185
+ export PANEL_OAUTH_REDIRECT_URI=http://localhost:5006/app
186
+ export PANEL_OAUTH_KEY=[VALUE IN GCP Secret Manager]
187
+ export PANEL_OAUTH_SECRET=[VALUE IN GCP Secret Manager]
188
+ export PANEL_OAUTH_ENCRYPTION=[VALUE IN GCP Secret Manager]
189
+
190
+ Use the CLI tool `direnv` for convenience. Then you can serve with
191
+ OAuth support:
192
+
193
+ make serve-oauth
194
+
195
+ ### Deployment
196
+
197
+ New version can either be deployed from the CI with `cloudbuild` or locally:
198
+
199
+ make production
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: simdec
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: Sensitivity analysis using simulation decomposition
5
5
  Project-URL: homepage, https://www.simdec.fi/
6
6
  Project-URL: documentation, https://simdec.readthedocs.io
@@ -16,22 +16,32 @@ Classifier: License :: OSI Approved :: BSD License
16
16
  Classifier: Operating System :: OS Independent
17
17
  Classifier: Programming Language :: Python
18
18
  Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.9
20
19
  Classifier: Programming Language :: Python :: 3.10
21
20
  Classifier: Programming Language :: Python :: 3.11
22
- Requires-Python: >=3.9
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.10
23
23
  Requires-Dist: numpy
24
24
  Requires-Dist: pandas
25
- Requires-Dist: panel
26
25
  Requires-Dist: salib
27
26
  Requires-Dist: seaborn
28
- Requires-Dist: typer[all]
27
+ Provides-Extra: dashboard
28
+ Requires-Dist: cryptography; extra == 'dashboard'
29
+ Requires-Dist: panel>=1.3.8; extra == 'dashboard'
29
30
  Provides-Extra: dev
31
+ Requires-Dist: accessible-pygments; extra == 'dev'
32
+ Requires-Dist: cryptography; extra == 'dev'
30
33
  Requires-Dist: hatch; extra == 'dev'
34
+ Requires-Dist: myst-nb; extra == 'dev'
35
+ Requires-Dist: numpydoc; extra == 'dev'
36
+ Requires-Dist: panel>=1.3.8; extra == 'dev'
31
37
  Requires-Dist: pre-commit; extra == 'dev'
32
- Requires-Dist: simdec[doc,test]; extra == 'dev'
38
+ Requires-Dist: pydata-sphinx-theme; extra == 'dev'
39
+ Requires-Dist: pytest; extra == 'dev'
40
+ Requires-Dist: pytest-cov; extra == 'dev'
41
+ Requires-Dist: sphinx; extra == 'dev'
33
42
  Provides-Extra: doc
34
43
  Requires-Dist: accessible-pygments; extra == 'doc'
44
+ Requires-Dist: myst-nb; extra == 'doc'
35
45
  Requires-Dist: numpydoc; extra == 'doc'
36
46
  Requires-Dist: pydata-sphinx-theme; extra == 'doc'
37
47
  Requires-Dist: sphinx; extra == 'doc'
@@ -56,7 +66,7 @@ When public
56
66
  analysis method, which is based on Monte Carlo simulation. SimDec consists of
57
67
  three major parts:
58
68
 
59
- 1. computing significance indices,
69
+ 1. computing sensitivity indices,
60
70
  2. creating multi-variable scenarios and mapping the output values to them, and
61
71
  3. visualizing the scenarios on the output distribution by color-coding its segments.
62
72
 
@@ -64,7 +74,15 @@ SimDec reveals the nature of causalities and interaction effects in the model.
64
74
  See our [publications](https://www.simdec.fi/publications) and join our
65
75
  [discord community](https://discord.gg/54SFcNsZS4).
66
76
 
67
- ...
77
+ ## Python API
78
+ The library is distributed on PyPi and can be installed with:
79
+
80
+ pip install simdec
81
+
82
+ ## Dashboard
83
+ A live dashboard is available at:
84
+
85
+ https://simdec.io
68
86
 
69
87
  ## Citations
70
88
 
@@ -76,13 +94,6 @@ Foundation, and Finnish Foundation for Economic Education.
76
94
  If you use SimDec in your research we would appreciate a citation to the
77
95
  following publications:
78
96
 
79
- - Kozlova, M., & Yeomans, J. S. (2022). Monte Carlo Enhancement via Simulation
80
- Decomposition: A “Must-Have” Inclusion for Many Disciplines. _INFORMS
81
- Transactions on Education, 22_(3), 147-159. DOI:10.1287/ited.2019.0240.
82
- - Kozlova, M., Moss, R. J., Yeomans, J. S., & Caers, J. (forthcoming).
83
- Uncovering Heterogeneous Effects in Computational Models for Sustainable
84
- Decision-making. _Environmental Modelling & Software_.
85
- - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (forthcoming).
86
- SimDec algorithm. In M. Kozlova & J. S. Yeomans (Eds.), _Sensitivity Analysis
87
- for Business, Technology, and Policymaking Made Easy with Simulation
88
- Decomposition_. Routledge.
97
+ - Kozlova, M., & Yeomans, J. S. (2022). Monte Carlo Enhancement via Simulation Decomposition: A “Must-Have” Inclusion for Many Disciplines. _INFORMS Transactions on Education, 22_(3), 147-159. [Available here](https://pubsonline.informs.org/doi/10.1287/ited.2019.0240).
98
+ - Kozlova, M., Moss, R. J., Yeomans, J. S., & Caers, J. (2024). Uncovering Heterogeneous Effects in Computational Models for Sustainable Decision-making. _Environmental Modelling & Software_, 171, 105898. [https://doi.org/10.1016/j.envsoft.2023.105898](https://doi.org/10.1016/j.envsoft.2023.105898)
99
+ - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (forthcoming). SimDec algorithm and guidelines for its usage and interpretation. In M. Kozlova & J. S. Yeomans (Eds.), _Sensitivity Analysis for Business, Technology, and Policymaking. Made Easy with Simulation Decomposition_. Routledge.
@@ -14,7 +14,7 @@ When public
14
14
  analysis method, which is based on Monte Carlo simulation. SimDec consists of
15
15
  three major parts:
16
16
 
17
- 1. computing significance indices,
17
+ 1. computing sensitivity indices,
18
18
  2. creating multi-variable scenarios and mapping the output values to them, and
19
19
  3. visualizing the scenarios on the output distribution by color-coding its segments.
20
20
 
@@ -22,7 +22,15 @@ SimDec reveals the nature of causalities and interaction effects in the model.
22
22
  See our [publications](https://www.simdec.fi/publications) and join our
23
23
  [discord community](https://discord.gg/54SFcNsZS4).
24
24
 
25
- ...
25
+ ## Python API
26
+ The library is distributed on PyPi and can be installed with:
27
+
28
+ pip install simdec
29
+
30
+ ## Dashboard
31
+ A live dashboard is available at:
32
+
33
+ https://simdec.io
26
34
 
27
35
  ## Citations
28
36
 
@@ -34,13 +42,6 @@ Foundation, and Finnish Foundation for Economic Education.
34
42
  If you use SimDec in your research we would appreciate a citation to the
35
43
  following publications:
36
44
 
37
- - Kozlova, M., & Yeomans, J. S. (2022). Monte Carlo Enhancement via Simulation
38
- Decomposition: A “Must-Have” Inclusion for Many Disciplines. _INFORMS
39
- Transactions on Education, 22_(3), 147-159. DOI:10.1287/ited.2019.0240.
40
- - Kozlova, M., Moss, R. J., Yeomans, J. S., & Caers, J. (forthcoming).
41
- Uncovering Heterogeneous Effects in Computational Models for Sustainable
42
- Decision-making. _Environmental Modelling & Software_.
43
- - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (forthcoming).
44
- SimDec algorithm. In M. Kozlova & J. S. Yeomans (Eds.), _Sensitivity Analysis
45
- for Business, Technology, and Policymaking Made Easy with Simulation
46
- Decomposition_. Routledge.
45
+ - Kozlova, M., & Yeomans, J. S. (2022). Monte Carlo Enhancement via Simulation Decomposition: A “Must-Have” Inclusion for Many Disciplines. _INFORMS Transactions on Education, 22_(3), 147-159. [Available here](https://pubsonline.informs.org/doi/10.1287/ited.2019.0240).
46
+ - Kozlova, M., Moss, R. J., Yeomans, J. S., & Caers, J. (2024). Uncovering Heterogeneous Effects in Computational Models for Sustainable Decision-making. _Environmental Modelling & Software_, 171, 105898. [https://doi.org/10.1016/j.envsoft.2023.105898](https://doi.org/10.1016/j.envsoft.2023.105898)
47
+ - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (forthcoming). SimDec algorithm and guidelines for its usage and interpretation. In M. Kozlova & J. S. Yeomans (Eds.), _Sensitivity Analysis for Business, Technology, and Policymaking. Made Easy with Simulation Decomposition_. Routledge.
@@ -0,0 +1,115 @@
1
+ @article{Herman2017,
2
+ doi = {10.21105/joss.00097},
3
+ year = {2017},
4
+ month = {jan},
5
+ publisher = {The Open Journal},
6
+ volume = {2},
7
+ number = {9},
8
+ author = {Jon Herman and Will Usher},
9
+ title = {{SALib}: An open-source {Python} library for Sensitivity Analysis},
10
+ journal = {The Journal of Open Source Software}
11
+ }
12
+
13
+ @article{Kozlova2024,
14
+ title = {Uncovering heterogeneous effects in computational models for sustainable decision-making},
15
+ journal = {Environmental Modelling & Software},
16
+ volume = {171},
17
+ pages = {105898},
18
+ year = {2024},
19
+ issn = {1364-8152},
20
+ doi = {10.1016/j.envsoft.2023.105898},
21
+ author = {Mariia Kozlova and Robert J. Moss and Julian Scott Yeomans and Jef Caers},
22
+ keywords = {Global sensitivity analysis, Simulation decomposition, Monte Carlo simulation, Decision-making under uncertainty}
23
+ }
24
+
25
+ @article{Roy2023,
26
+ doi = {10.21105/joss.05309},
27
+ year = {2023},
28
+ publisher = {The Open Journal},
29
+ volume = {8},
30
+ number = {84},
31
+ pages = {5309},
32
+ author = {Pamphile T. Roy and Art B. Owen and Maximilian Balandat and Matt Haberland},
33
+ title = {Quasi-Monte Carlo Methods in {Python}},
34
+ journal = {Journal of Open Source Software}
35
+ }
36
+
37
+ @article{Virtanen2020,
38
+ title={SciPy 1.0: fundamental algorithms for scientific computing in {P}ython},
39
+ author={Virtanen, Pauli and Gommers, Ralf and Oliphant, Travis E and Haberland, Matt and Reddy, Tyler and Cournapeau, David and Burovski, Evgeni and Peterson, Pearu and Weckesser, Warren and Bright, Jonathan et al.},
40
+ journal={Nature methods},
41
+ volume={17},
42
+ number={3},
43
+ pages={261--272},
44
+ year={2020},
45
+ publisher={Nature Publishing Group},
46
+ doi={10.1038/s41592-019-0686-2}
47
+ }
48
+
49
+ @book{Saltelli2007,
50
+ author = {Saltelli, Andrea and Ratto, Marco and Andres, Terry and Campolongo, Francesca and Cariboni, Jessica and Gatelli, Debora and Saisana, Michaela and Tarantola, Stefano},
51
+ booktitle = {Global Sensitivity Analysis. The Primer},
52
+ doi = {10.1002/9780470725184},
53
+ isbn = {9780470725184},
54
+ month = {dec},
55
+ pages = {237--275},
56
+ publisher = {John Wiley {\&} Sons, Ltd},
57
+ title = {{Global Sensitivity Analysis. The Primer}},
58
+ year = {2007}
59
+ }
60
+
61
+ @article{sobol1993,
62
+ title={Sensitivity analysis for non-linear mathematical models, originally “Sensitivity estimates for non-linear mathematical models”},
63
+ author={Sobol, Ilya M},
64
+ journal={Math Model Comput Exp},
65
+ volume={1},
66
+ pages={407--414},
67
+ year={1993}
68
+ }
69
+
70
+ @report{europeancommission2021,
71
+ title = {Better {{Regulation Toolbox}}},
72
+ author = {{European Commission}},
73
+ date = {2021-11},
74
+ url = {https://ec.europa.eu/info/law/law-making-process/planning-and-proposing-law/better-regulation-why-and-how/better-regulation-guidelines-and-toolbox_en},
75
+ city = {Brussels},
76
+ keywords = {\#nosource}
77
+ }
78
+
79
+ @software{panel,
80
+ author = {Philipp Rudiger and
81
+ Marc Skov Madsen and
82
+ Simon Høxbro Hansen and
83
+ Maxime Liquet and
84
+ Andrew and
85
+ Xavier Artusi and
86
+ James A. Bednar and
87
+ Chris B and
88
+ Jean-Luc Stevens and
89
+ Christoph Deil and
90
+ Demetris Roumis and
91
+ Julia Signell and
92
+ Mateusz Paprocki and
93
+ Jerry Wu and
94
+ Jon Mease and
95
+ Arne and
96
+ Coderambling and
97
+ Hugues-Yanis Amanieu and
98
+ thuydotm and
99
+ Simon and
100
+ sdc50 and
101
+ Luca Fabbri and
102
+ kbowen and
103
+ Theom and
104
+ Joel Ostblom and
105
+ Govinda Totla and
106
+ Niko Föhr and
107
+ TBym},
108
+ title = {holoviz/panel: Version 1.4.3},
109
+ month = may,
110
+ year = 2024,
111
+ publisher = {Zenodo},
112
+ version = {v1.4.3},
113
+ doi = {10.5281/zenodo.11261266},
114
+ url = {https://doi.org/10.5281/zenodo.11261266}
115
+ }
@@ -0,0 +1,76 @@
1
+ ---
2
+ title: 'Simulation Decomposition in Python'
3
+ tags:
4
+ - Python
5
+ - SimDec
6
+ - statistics
7
+ - Sensitivity Analysis
8
+ - Visualization
9
+ authors:
10
+ - name: Pamphile T. Roy
11
+ affiliation: 1
12
+ corresponding: true
13
+ orcid: 0000-0001-9816-1416
14
+ - name: Mariia Kozlova
15
+ affiliation: 2
16
+ orcid: 0000-0002-6952-7682
17
+ affiliations:
18
+ - name: Consulting Manao GmbH, Vienna, Austria
19
+ index: 1
20
+ - name: LUT Business School, LUT University, Lappeenranta, Finland
21
+ index: 2
22
+ date: 1 April 2024
23
+ bibliography: paper.bib
24
+
25
+ ---
26
+
27
+ # Summary
28
+
29
+ Uncertainties are everywhere. Whether you are developing a new Artificial Intelligence (AI) system,
30
+ running complex simulations or making an experiment in a lab, uncertainties
31
+ influence the system. Therefore, an approach is needed to understand how these uncertainties impact the system's performance.
32
+
33
+ SimDec offers a novel visual way to understand the intricate role that
34
+ uncertainties play. A clear Python Application Programming Interface (API) and a no-code interactive web
35
+ dashboard make uncertainty analysis with SimDec accessible to everyone.
36
+
37
+ # Statement of need
38
+
39
+ From real life experiments to numerical simulations, uncertainties play a
40
+ crucial role in the system under study. With the advent of AI
41
+ and new regulations such as the [AI Act](https://artificialintelligenceact.eu) or the
42
+ *Better Regulation Guideline* [@europeancommission2021], there is a growing need for explainability and
43
+ impact assessments of systems under uncertainties.
44
+
45
+ Traditional methods to analyse the uncertainties focus on quantitative methods
46
+ to compare the importance of factors, there is a large body of literature and
47
+ the field is known as: Sensitivity Analysis (SA) [@Saltelli2007]. The indices of Sobol' are a
48
+ prominent example of such methods [@sobol1993].
49
+
50
+ Simulation Decomposition or SimDec moves the field of SA forward by supplementing the computation of sensitivity indices with the visualization of the type of interactions involved, which proves critical for understanding the system's behavior and decision-making [@Kozlova2024].
51
+ In short, SimDec is a hybrid uncertainty-sensitivity analysis approach
52
+ that reveals the critical behavior of a computational model or an empirical
53
+ dataset. It decomposes the distribution of the output
54
+ (target variable) by automatically forming scenarios that reveal the most critical behavior of the system. The scenarios are formed out of the most influential input variables (defined with variance-based sensitivity indices) by breaking down their numeric ranges into states (e.g. _low_ and _high_) and creating an exhaustive list of their combinations (e.g. (i) _low_ _**A**_ & _low_ _**B**_, (ii) _low_ _**A**_ & _high_ _**B**_, (iii) _high_ **_A_** & _low_ **_B_**, and (iv) _high_ **_A_** and _high_ **_B_**). The resulting visualization shows how different
55
+ output ranges can be achieved and what kind of critical interactions affect
56
+ the output—as seen in \autoref{fig:simdec}. The method has shown value for
57
+ various computational models from different fields, including business,
58
+ environment, and engineering, as well as an emerging evidence of use for
59
+ empirical data and AI.
60
+
61
+ ![SimDec: explanation of output by most important inputs. A simulation dataset of a structural reliability model with one key output variable and four input variables is used for this case. Inputs 3 and 1 have the highest sensitivity indices and thus are automatically chosen for decomposition. The most influential input 3 divides the distribution of the output into three main states with distinct colors. Input 1 further subdivides them into shades. From the graph, it becomes obvious that input 1 influences the output when input 3 is low, but has a negligible effect when input 3 is medium or high.\label{fig:simdec}](simdec_presentation.png)
62
+
63
+ Besides proposing a comprehensive yet simple API through a Python package
64
+ available on PyPi, SimDec is also made available
65
+ to practitioners through an online dashboard at [https://simdec.io](https://simdec.io). The project
66
+ relies on powerful variance-based sensitivity analysis methods from SALib [@Herman2017] and
67
+ SciPy [@Virtanen2020; @Roy2023]—notably the Quasi-Monte Carlo capabilities with
68
+ `sp.stats.qmc` and in the future sensitivity indices with `sp.stats.sensitivity_indices`.
69
+ The dashboard is made possible thanks to Panel [@panel].
70
+
71
+ # Acknowledgements
72
+
73
+ The work on this open-source software was supported by grant #220177 from
74
+ Finnish Foundation for Economic Foundation.
75
+
76
+ # References
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "simdec"
7
- version = "1.0.0"
7
+ version = "1.2.0"
8
8
  description = "Sensitivity analysis using simulation decomposition"
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
10
+ requires-python = ">=3.10"
11
11
  license = "BSD-3-Clause"
12
12
  authors = [
13
13
  { name = "Pamphile Roy" },
@@ -23,9 +23,9 @@ classifiers = [
23
23
  "Operating System :: OS Independent",
24
24
  "Programming Language :: Python",
25
25
  "Programming Language :: Python :: 3",
26
- "Programming Language :: Python :: 3.9",
27
26
  "Programming Language :: Python :: 3.10",
28
27
  "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
29
  ]
30
30
 
31
31
  dependencies = [
@@ -33,11 +33,14 @@ dependencies = [
33
33
  "pandas",
34
34
  "SALib",
35
35
  "seaborn",
36
- "typer[all]",
37
- "panel",
38
36
  ]
39
37
 
40
38
  [project.optional-dependencies]
39
+ dashboard = [
40
+ "panel>=1.3.8",
41
+ "cryptography",
42
+ ]
43
+
41
44
  test = [
42
45
  "pytest",
43
46
  "pytest-cov",
@@ -48,32 +51,37 @@ doc = [
48
51
  "pydata-sphinx-theme",
49
52
  "accessible-pygments",
50
53
  "numpydoc",
54
+ "myst-nb",
51
55
  ]
52
56
 
53
57
  dev = [
54
- "simdec[doc,test]",
58
+ "simdec[doc,test,dashboard]",
55
59
  "pre-commit",
56
60
  "hatch",
57
61
  ]
58
62
 
59
- [project.scripts]
60
- simdec = "simdec.workflow:app"
61
-
62
63
  [project.urls]
63
64
  homepage = "https://www.simdec.fi/"
64
65
  documentation = "https://simdec.readthedocs.io"
65
66
  source = "https://github.com/Simulation-Decomposition/simdec-python"
66
67
 
67
68
  [tool.hatch]
69
+ build.targets.wheel.packages = ["src/simdec"]
68
70
  build.targets.sdist.exclude = [
69
71
  ".github",
70
72
  "docs",
73
+ "panel",
71
74
  "tests",
72
75
  "*.rst",
73
76
  "*.yml",
74
77
  ".*",
78
+ "Makefile",
79
+ "Dockerfile",
75
80
  ]
76
81
 
82
+ [project.entry-points."panel.auth"]
83
+ custom_google = "simdec.auth:CustomGoogleLoginHandler"
84
+
77
85
  [tool.pytest.ini_options]
78
86
  addopts = "--durations 10"
79
87
  testpaths = [
@@ -0,0 +1,13 @@
1
+ """SimDec main namespace."""
2
+ from simdec.decomposition import *
3
+ from simdec.sensitivity_indices import *
4
+ from simdec.visualization import *
5
+
6
+ __all__ = [
7
+ "sensitivity_indices",
8
+ "states_expansion",
9
+ "decomposition",
10
+ "visualization",
11
+ "tableau",
12
+ "palette",
13
+ ]
@@ -0,0 +1,17 @@
1
+ from panel.auth import GoogleLoginHandler
2
+ from panel.io.resources import CDN_DIST
3
+
4
+
5
+ class CustomGoogleLoginHandler(GoogleLoginHandler):
6
+ def _simple_get(self):
7
+ html = self._login_template.render(errormessage="", PANEL_CDN=CDN_DIST)
8
+ self.write(html)
9
+
10
+ async def get(self):
11
+ if "login" in self.request.uri and "state" not in self.request.uri:
12
+ self._simple_get()
13
+ else:
14
+ await super().get()
15
+
16
+ async def post(self):
17
+ await super().get()