metacountregressor 0.1.73__py3-none-any.whl → 0.1.88__py3-none-any.whl
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.
- metacountregressor/data_split_helper.py +90 -0
- metacountregressor/helperprocess.py +115 -0
- metacountregressor/main.py +51 -72
- metacountregressor/metaheuristics.py +25 -24
- metacountregressor/solution.py +281 -694
- {metacountregressor-0.1.73.dist-info → metacountregressor-0.1.88.dist-info}/METADATA +78 -20
- {metacountregressor-0.1.73.dist-info → metacountregressor-0.1.88.dist-info}/RECORD +10 -9
- {metacountregressor-0.1.73.dist-info → metacountregressor-0.1.88.dist-info}/WHEEL +1 -1
- {metacountregressor-0.1.73.dist-info → metacountregressor-0.1.88.dist-info}/LICENSE.txt +0 -0
- {metacountregressor-0.1.73.dist-info → metacountregressor-0.1.88.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: metacountregressor
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.88
|
4
4
|
Summary: Extensions for a Python package for estimation of count models.
|
5
5
|
Home-page: https://github.com/zahern/CountDataEstimation
|
6
6
|
Author: Zeke Ahern
|
@@ -11,12 +11,18 @@ Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE.txt
|
12
12
|
Requires-Dist: numpy >=1.13.1
|
13
13
|
Requires-Dist: scipy >=1.0.0
|
14
|
+
Requires-Dist: requests
|
14
15
|
|
15
16
|
<div style="display: flex; align-items: center;">
|
16
|
-
<img src="https://github.com/zahern/data/raw/main/m.png" alt="My Image" style="width:
|
17
|
+
<img src="https://github.com/zahern/data/raw/main/m.png" alt="My Image" style="width: 100px; margin-right: 20px;">
|
17
18
|
<p><span style="font-size: 60px;"><strong>MetaCountRegressor</strong></span></p>
|
18
19
|
</div>
|
19
20
|
|
21
|
+
# Tutorial also available as a jupyter notebook
|
22
|
+
[Download Example Notebook](https://github.com/zahern/CountDataEstimation/blob/main/Tutorial.ipynb)
|
23
|
+
|
24
|
+
The tutorial provides more extensive examples on how to run the code and perform experiments. Further documentation is currently in development.
|
25
|
+
|
20
26
|
##### Quick Setup
|
21
27
|
The Below code demonstrates how to set up automatic optimization assisted by the harmony search algorithm. References to the Differential Evolution and Simulated Annealing has been mentioned (change accordingly)
|
22
28
|
|
@@ -35,8 +41,15 @@ from metacountregressor.solution import ObjectiveFunction
|
|
35
41
|
from metacountregressor.metaheuristics import (harmony_search,
|
36
42
|
differential_evolution,
|
37
43
|
simulated_annealing)
|
44
|
+
|
45
|
+
|
38
46
|
```
|
39
47
|
|
48
|
+
loaded standard packages
|
49
|
+
loaded helper
|
50
|
+
testing
|
51
|
+
|
52
|
+
|
40
53
|
#### Basic setup.
|
41
54
|
The initial setup involves reading in the data and selecting an optimization algorithm. As the runtime progresses, new solutions will be continually evaluated. Finally, at the end of the runtime, the best solution will be identified and printed out. In the case of multiple objectives all of the best solutions will be printed out that belong to the Pareto frontier.
|
42
55
|
|
@@ -53,7 +66,7 @@ X = df.drop(columns=['FREQ', 'ID', 'AADT'])
|
|
53
66
|
|
54
67
|
#some example argument, these are defualt so the following line is just for claritity. See the later agruments section for detials.
|
55
68
|
arguments = {'algorithm': 'hs', 'test_percentage': 0.15, 'test_complexity': 6, 'instance_number':1,
|
56
|
-
'val_percentage':0.15, 'obj_1': 'bic', '_obj_2': 'RMSE_TEST', "
|
69
|
+
'val_percentage':0.15, 'obj_1': 'bic', '_obj_2': 'RMSE_TEST', "_max_time": 6}
|
57
70
|
# Fit the model with metacountregressor
|
58
71
|
obj_fun = ObjectiveFunction(X, y, **arguments)
|
59
72
|
#replace with other metaheuristics if desired
|
@@ -71,7 +84,7 @@ Note: Please Consider the main arguments to change.
|
|
71
84
|
- `val_percentage`: This parameter represents the percentage of data used to validate the model. The value 0.15 corresponds to 15% of the data.
|
72
85
|
- `test_complexity`: This parameter defines the complexity level for testing. The value 6 tests all complexities. Alternatively, you can provide a list of numbers to consider different complexities. The complexities are further explained later in this document.
|
73
86
|
- `instance_number`: This parameter is used to give a name to the outputs.
|
74
|
-
- `
|
87
|
+
- `_obj_1`: This parameter has multiple choices for obj_1, such as 'bic', 'aic', and 'hqic'. Only one choice should be defined as a string value.
|
75
88
|
- `_obj_2`: This parameter has multiple choices for objective 2, such as 'RMSE_TEST', 'MSE_TEST', and 'MAE_TEST'.
|
76
89
|
- `_max_time`: This parameter specifies the maximum number of seconds for the total estimation before stopping.
|
77
90
|
- `distribution`: This parameter is a list of distributions to consider. Please select all of the available options and put them into a list of valid options if you want to to consider the distribution type for use when modellign with random parameters. The valid options include: 'Normal', 'LnNormal', 'Triangular', and 'Uniform'.
|
@@ -80,7 +93,7 @@ Note: Please Consider the main arguments to change.
|
|
80
93
|
|
81
94
|
|
82
95
|
|
83
|
-
###
|
96
|
+
### Example of changing the arguments:
|
84
97
|
Modify the arguments according to your preferences using the commented code as a guide.
|
85
98
|
|
86
99
|
|
@@ -108,16 +121,18 @@ Listed below is an example of how to specify an initial solution within the fram
|
|
108
121
|
|
109
122
|
|
110
123
|
```python
|
111
|
-
#Model Decisions, Specify for
|
124
|
+
#Model Decisions, Specify for initial solution that will be optimised.
|
112
125
|
manual_fit_spec = {
|
113
126
|
'fixed_terms': ['SINGLE', 'LENGTH'],
|
114
127
|
'rdm_terms': ['AADT:normal'],
|
115
|
-
'rdm_cor_terms': ['GRADEBR:
|
128
|
+
'rdm_cor_terms': ['GRADEBR:normal', 'CURVES:normal'],
|
116
129
|
'grouped_terms': [],
|
117
130
|
'hetro_in_means': ['ACCESS:normal', 'MINRAD:normal'],
|
118
131
|
'transformations': ['no', 'no', 'log', 'no', 'no', 'no', 'no'],
|
119
|
-
'dispersion':
|
132
|
+
'dispersion': 0
|
120
133
|
}
|
134
|
+
|
135
|
+
|
121
136
|
#Search Arguments
|
122
137
|
arguments = {
|
123
138
|
'algorithm': 'hs',
|
@@ -129,7 +144,47 @@ arguments = {
|
|
129
144
|
obj_fun = ObjectiveFunction(X, y, **arguments)
|
130
145
|
```
|
131
146
|
|
132
|
-
|
147
|
+
Setup Complete...
|
148
|
+
Benchmaking test with Seed 42
|
149
|
+
--------------------------------------------------------------------------------
|
150
|
+
Log-Likelihood: -1339.1862434675106
|
151
|
+
--------------------------------------------------------------------------------
|
152
|
+
bic: 2732.31
|
153
|
+
--------------------------------------------------------------------------------
|
154
|
+
MSE: 650856.32
|
155
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
156
|
+
| Effect | $\tau$ | Coeff | Std. Err | z-values | Prob |z|>Z |
|
157
|
+
+==========================+========+=======+==========+==========+============+
|
158
|
+
| LENGTH | no | -0.15 | 0.01 | -12.98 | 0.00*** |
|
159
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
160
|
+
| SINGLE | no | -2.46 | 0.04 | -50.00 | 0.00*** |
|
161
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
162
|
+
| GRADEBR | log | 4.23 | 0.10 | 42.17 | 0.00*** |
|
163
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
164
|
+
| CURVES | no | 0.51 | 0.01 | 34.78 | 0.00*** |
|
165
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
166
|
+
| Chol: GRADEBR (Std. | | 2.21 | 0.00 | 50.00 | 0.00*** |
|
167
|
+
| Dev. normal) ) | | | | | |
|
168
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
169
|
+
| Chol: CURVES (Std. Dev. | | -0.51 | 0.00 | -50.00 | 0.00*** |
|
170
|
+
| normal) ) | | | | | |
|
171
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
172
|
+
| Chol: CURVES (Std. Dev. | no | 0.55 | 0.00 | 50.00 | 0.00*** |
|
173
|
+
| normal) . GRADEBR (Std. | | | | | |
|
174
|
+
| Dev. normal ) | | | | | |
|
175
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
176
|
+
| main: MINRAD: hetro | no | -0.00 | 0.00 | -44.36 | 0.00*** |
|
177
|
+
| group 0 | | | | | |
|
178
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
179
|
+
| ACCESS: hetro group 0 | | 0.68 | 0.09 | 7.68 | 0.00*** |
|
180
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
181
|
+
| main: MINRAD: hetro | | -0.00 | 0.00 | -44.86 | 0.00*** |
|
182
|
+
| group 0:normal:sd hetro | | | | | |
|
183
|
+
| group 0 | | | | | |
|
184
|
+
+--------------------------+--------+-------+----------+----------+------------+
|
185
|
+
|
186
|
+
|
187
|
+
Simarly to return the results feed the objective function into a metaheuristic solution algorithm. An example of this is provided below:
|
133
188
|
|
134
189
|
|
135
190
|
```python
|
@@ -137,7 +192,7 @@ results = harmony_search(obj_fun)
|
|
137
192
|
print(results)
|
138
193
|
```
|
139
194
|
|
140
|
-
|
195
|
+
# Notes:
|
141
196
|
### Capabilities of the software include:
|
142
197
|
* Handling of Panel Data
|
143
198
|
* Support for Data Transformations
|
@@ -155,11 +210,11 @@ Capability to handle heterogeneity in the means of the random parameters
|
|
155
210
|
* Customization of Hyper-parameters to solve problems tailored to your dataset
|
156
211
|
* Out-of-the-box optimization capability using default metaheuristics
|
157
212
|
|
158
|
-
###
|
213
|
+
### Intepreting the output of the model:
|
159
214
|
A regression table is produced. The following text elements are explained:
|
160
215
|
- Std. Dev.: This column appears for effects that are related to random paramters and displays the assument distributional assumption next to it
|
161
216
|
- Chol: This term refers to Cholesky decomposition element, to show the correlation between two random paramaters. The combination of the cholesky element on iyself is equivalent to a normal random parameter.
|
162
|
-
- hetro group
|
217
|
+
- hetro group: This term represents the heterogeneity group number, which refers all of the contributing factors that share hetrogentiy in the means to each other under the same numbered value.
|
163
218
|
- $\tau$: This column, displays the type of transformation that was applied to the specific contributing factor in the data.
|
164
219
|
|
165
220
|
|
@@ -211,10 +266,10 @@ The following list describes the arguments available in this function. By defaul
|
|
211
266
|
|
212
267
|
8. **`_max_time`**: This argument is used to add a termination time in the algorithm. It takes values as seconds. Note the time is only dependenant on the time after intial population of solutions are generated.
|
213
268
|
|
214
|
-
|
269
|
+
## Example: Assistance by Harmony Search
|
215
270
|
|
216
271
|
|
217
|
-
Let's
|
272
|
+
Let's begin by fitting very simple models and use the structure of these models to define our objectives. Then, we can conduct a more extensive search on the variables that are more frequently identified. For instance, in the case below, the complexity is level 3, indicating that we will consider, at most randomly correlated parameters. This approach is useful for initially identifying a suitable set of contributing factors for our search.
|
218
273
|
|
219
274
|
|
220
275
|
|
@@ -241,27 +296,30 @@ arguments = {
|
|
241
296
|
'_max_time': 10000
|
242
297
|
}
|
243
298
|
obj_fun = ObjectiveFunction(X, y, **arguments)
|
244
|
-
|
245
299
|
results = harmony_search(obj_fun)
|
246
300
|
print(results)
|
247
301
|
```
|
248
302
|
|
303
|
+
## Paper
|
304
|
+
|
305
|
+
The following tutorial is in conjunction with our latest paper. A link the current paper can be found here [MetaCountRegressor](https://www.overleaf.com/read/mszwpwzcxsng#c5eb0c)
|
306
|
+
|
249
307
|
## Contact
|
250
308
|
If you have any questions, ideas to improve MetaCountRegressor, or want to report a bug, just open a new issue in [GitHub repository](https://github.com/zahern/CountDataEstimation).
|
251
309
|
|
252
310
|
## Citing MetaCountRegressor
|
253
311
|
Please cite MetaCountRegressor as follows:
|
254
312
|
|
255
|
-
Ahern, Z., Corry P., Paz A. (
|
313
|
+
Ahern, Z., Corry P., Paz A. (2024). MetaCountRegressor [Computer software]. [https://pypi.org/project/metacounregressor/](https://pypi.org/project/metacounregressor/)
|
256
314
|
|
257
315
|
Or using BibTex as follows:
|
258
316
|
|
259
317
|
```bibtex
|
260
|
-
@misc{
|
261
|
-
author = {Zeke Ahern
|
318
|
+
@misc{Ahern2024Meta,
|
319
|
+
author = {Zeke Ahern, Paul Corry and Alexander Paz},
|
262
320
|
journal = {PyPi},
|
263
321
|
title = {metacountregressor · PyPI},
|
264
|
-
url = {https://pypi.org/project/metacountregressor/0.1.
|
265
|
-
year = {
|
322
|
+
url = {https://pypi.org/project/metacountregressor/0.1.80/},
|
323
|
+
year = {2024},
|
266
324
|
}
|
267
325
|
|
@@ -1,18 +1,19 @@
|
|
1
1
|
metacountregressor/__init__.py,sha256=UM4zaqoAcZVWyx3SeL9bRS8xpQ_iLZU9fIIARWmfjis,2937
|
2
2
|
metacountregressor/_device_cust.py,sha256=759fnKmTYccJm4Lpi9_1reurh6OB9d6q9soPR0PltKc,2047
|
3
|
+
metacountregressor/data_split_helper.py,sha256=M2fIMdIO8znUaYhx5wlacRyNWdQjNYu1z1wkE-kFUYU,3373
|
3
4
|
metacountregressor/halton.py,sha256=jhovA45UBoZYU9g-hl6Lb2sBIx_ZBTNdPrpgkzR9fng,9463
|
4
|
-
metacountregressor/helperprocess.py,sha256=
|
5
|
-
metacountregressor/main.py,sha256=
|
5
|
+
metacountregressor/helperprocess.py,sha256=Sc5gJ7ffFlkya5B5KQwE33xxXuIQyF6OaYtSikLa3pQ,12968
|
6
|
+
metacountregressor/main.py,sha256=RKddYRv3UKkszbWD-d2-u8yqcYeniCB5vL3vmj7am5I,16700
|
6
7
|
metacountregressor/main_old.py,sha256=eTS4ygq27MnU-dZ_j983Ucb-D5XfbVF8OJQK2hVVLZc,24123
|
7
|
-
metacountregressor/metaheuristics.py,sha256=
|
8
|
+
metacountregressor/metaheuristics.py,sha256=2MW3qlgs7BFbe_w64snLSKc4Y0-e_9sa3s_96rUm_SE,105887
|
8
9
|
metacountregressor/pareto_file.py,sha256=whySaoPAUWYjyI8zo0hwAOa3rFk6SIUlHSpqZiLur0k,23096
|
9
10
|
metacountregressor/pareto_logger__plot.py,sha256=mEU2QN4wmsM7t39GJ_XhJ_jjsdl09JOmG0U2jICrAkI,30037
|
10
11
|
metacountregressor/setup.py,sha256=8w6IqX0tJsbYrOI1BJLIJCIvOnunKli5I9fsF5PhHv4,919
|
11
12
|
metacountregressor/single_objective_finder.py,sha256=jVG7GJBqzSP4_riYr-kMMKy_LE3SlGmKMunNhHYxgRg,8011
|
12
|
-
metacountregressor/solution.py,sha256=
|
13
|
+
metacountregressor/solution.py,sha256=6UFri1O62X5GGEmrhMTpi2PQdtbtbJoc02uKixfYXGo,266195
|
13
14
|
metacountregressor/test_generated_paper2.py,sha256=pwOoRzl1jJIIOUAAvbkT6HmmTQ81mwpsshn9SLdKOg8,3927
|
14
|
-
metacountregressor-0.1.
|
15
|
-
metacountregressor-0.1.
|
16
|
-
metacountregressor-0.1.
|
17
|
-
metacountregressor-0.1.
|
18
|
-
metacountregressor-0.1.
|
15
|
+
metacountregressor-0.1.88.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
16
|
+
metacountregressor-0.1.88.dist-info/METADATA,sha256=BLyeZoC1G7i0pMCkJBmsop3EFSg_QFYKH0nWPjWFkHE,18165
|
17
|
+
metacountregressor-0.1.88.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
18
|
+
metacountregressor-0.1.88.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
|
19
|
+
metacountregressor-0.1.88.dist-info/RECORD,,
|
File without changes
|
File without changes
|