simdec 1.4.0__tar.gz → 1.5.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simdec
3
- Version: 1.4.0
3
+ Version: 1.5.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
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
- Requires-Python: >=3.10
22
+ Requires-Python: >=3.11
23
23
  Requires-Dist: numpy
24
24
  Requires-Dist: pandas
25
25
  Requires-Dist: salib
@@ -96,4 +96,4 @@ If you use SimDec in your research we would appreciate a citation to the
96
96
  following publications:
97
97
 
98
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. (2024). 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. [Available here](https://doi.org/10.4324/9781003453789-3).
99
+ - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (2024). 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. [Available here](https://github.com/Simulation-Decomposition/SimDec-book/blob/74ce72c1d3dda650eba1c59e3b215a4bb35c6be0/chapters/02_SimDec_algorithm_and_instructions/Ch2.pdf).
@@ -43,4 +43,4 @@ If you use SimDec in your research we would appreciate a citation to the
43
43
  following publications:
44
44
 
45
45
  - 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)
46
- - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (2024). 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. [Available here](https://doi.org/10.4324/9781003453789-3).
46
+ - Kozlova, M., Moss, R. J., Roy, P., Alam, A., & Yeomans, J. S. (2024). 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. [Available here](https://github.com/Simulation-Decomposition/SimDec-book/blob/74ce72c1d3dda650eba1c59e3b215a4bb35c6be0/chapters/02_SimDec_algorithm_and_instructions/Ch2.pdf).
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "simdec"
7
- version = "1.4.0"
7
+ version = "1.5.0"
8
8
  description = "Sensitivity analysis using simulation decomposition"
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = "BSD-3-Clause"
12
12
  authors = [
13
13
  { name = "Pamphile Roy" },
@@ -166,13 +166,37 @@ def decomposition(
166
166
  # sort and then split in n-state
167
167
  sorted_inputs = np.sort(inputs, axis=0)
168
168
  bin_edges = []
169
+
169
170
  for i, states_ in enumerate(states):
171
+ col = inputs[:, i]
172
+ uniq = np.unique(col)
173
+
174
+ # Categorical-like numeric inputs: if we have few unique numeric values,
175
+ # build edges around the unique values so we don't create empty states.
176
+ # We only apply this when the requested number of states matches the
177
+ # number of categories (uniq.size).
178
+ if uniq.size <= 5 and states_ == uniq.size:
179
+ uniq = np.sort(uniq).astype(float)
180
+
181
+ if uniq.size == 1:
182
+ edges = np.array([uniq[0] - 0.5, uniq[0] + 0.5], dtype=float)
183
+ else:
184
+ gaps = np.diff(uniq)
185
+ margin = 0.1 * np.min(gaps)
186
+ edges = np.concatenate(
187
+ ([uniq[0] - margin], uniq[:-1] + margin, [uniq[-1] + margin])
188
+ ).astype(float)
189
+
190
+ bin_edges.append(edges)
191
+ continue
192
+
193
+ # Default: equal-number-of-samples bins
170
194
  splits = np.array_split(sorted_inputs[:, i], states_)
171
- bin_edges_ = [splits_[0] for splits_ in splits]
172
- bin_edges_.append(splits[-1][-1]) # last point to close the edges
173
- # bin_edges_ = np.unique(bin_edges_) # remove duplicate points, sorted
174
- bin_edges_ += 1e-10 * np.linspace(0, 1, len(bin_edges_))
175
- bin_edges.append(bin_edges_)
195
+ edges = [s[0] for s in splits]
196
+ edges.append(splits[-1][-1]) # last point to close the edges
197
+ edges = np.array(edges, dtype=float)
198
+ edges += 1e-10 * np.linspace(0, 1, len(edges))
199
+ bin_edges.append(edges)
176
200
 
177
201
  res = stats.binned_statistic_dd(
178
202
  inputs, values=output, statistic=statistic_, bins=bin_edges
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes