metacountregressor 0.1.93__py3-none-any.whl → 0.1.97__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.
@@ -1,17 +1,31 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: metacountregressor
3
- Version: 0.1.93
4
- Summary: Extensions for a Python package for estimation of count models.
3
+ Version: 0.1.97
4
+ Summary: Extensive Testing for Estimation of Data Count Models
5
5
  Home-page: https://github.com/zahern/CountDataEstimation
6
6
  Author: Zeke Ahern
7
- Author-email: zeke.ahern@hdr.qut.edu.au
8
- License: QUT
7
+ Author-email: z.ahern@qut.edu.au
8
+ License: MIT
9
9
  Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.txt
12
- Requires-Dist: numpy >=1.13.1
13
- Requires-Dist: scipy >=1.0.0
12
+ Requires-Dist: numpy>=1.13.1
13
+ Requires-Dist: scipy>=1.0.0
14
14
  Requires-Dist: requests
15
+ Requires-Dist: latextable
16
+ Requires-Dist: pandas
17
+ Requires-Dist: scikit_learn>=1.4.1.post1
18
+ Requires-Dist: statsmodels
19
+ Requires-Dist: psutil
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: license
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
15
29
 
16
30
  <div style="display: flex; align-items: center;">
17
31
  <img src="https://github.com/zahern/data/raw/main/m.png" alt="My Image" style="width: 100px; margin-right: 20px;">
@@ -23,10 +37,24 @@ Requires-Dist: requests
23
37
 
24
38
  The tutorial provides more extensive examples on how to run the code and perform experiments. Further documentation is currently in development.
25
39
 
26
- ##### Quick Setup
40
+ # For an Application Setup Download the following GUI
41
+ [Download Application](https://github.com/zahern/MetaCount/tree/master/metacountregressor/application_gui/dist/meta_app)
42
+
43
+ The application involves setting up a problem instance to run the models.
44
+
45
+ ### Entire [Git Repository](https://github.com/zahern/MetaCount.git) is available to clone.
46
+ #### Steps
47
+ 1. Clone Project
48
+ 2. Navigate to "metacountregressor/application_gui/dist/meta_app"
49
+ 3. Run meta_app.exe
50
+ 4. Navigate to metacountregressor/app_main.py
51
+ 5. Run app_main.py
52
+
53
+
54
+ ## Setup For Python Package Approach
27
55
  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)
28
56
 
29
- ## Quick install: Requires Python 3.10
57
+ ## Install: Requires Python 3.10
30
58
 
31
59
  Install `metacountregressor` using pip as follows:
32
60
 
@@ -274,6 +302,8 @@ Let's begin by fitting very simple models and use the structure of these models
274
302
 
275
303
 
276
304
  ```python
305
+
306
+ '''Setup Data'''
277
307
  df = pd.read_csv(
278
308
  "https://raw.githubusercontent.com/zahern/data/main/Ex-16-3.csv")
279
309
  X = df
@@ -281,25 +311,158 @@ y = df['FREQ'] # Frequency of crashes
281
311
  X['Offset'] = np.log(df['AADT']) # Explicitley define how to offset the data, no offset otherwise
282
312
  # Drop Y, selected offset term and ID as there are no panels
283
313
  X = df.drop(columns=['FREQ', 'ID', 'AADT'])
284
-
314
+ '''Aguments for Solution'''
285
315
  arguments = {
286
- 'algorithm': 'hs', #alternatively input 'de', or 'sa'
287
- 'is_multi': 1,
316
+ 'is_multi': 1, #is two objectives considered
288
317
  'test_percentage': 0.2, # used in multi-objective optimisation only. Saves 20% of data for testing.
289
318
  'val_percentage:': 0.2, # Saves 20% of data for testing.
290
319
  'test_complexity': 3, # For Very simple Models
291
320
  'obj_1': 'BIC', '_obj_2': 'RMSE_TEST',
292
- 'instance_number': 'name', # used for creeating a named folder where your models are saved into from the directory
321
+ 'instance_number': 'hs_run', # used for creeating a named folder where your models are saved into from the directory
293
322
  'distribution': ['Normal'],
294
- 'Model': [0], # or equivalently ['POS', 'NB']
323
+ 'Model': [0, 1], # or equivalently ['POS', 'NB']
295
324
  'transformations': ['no', 'sqrt', 'archsinh'],
296
325
  '_max_time': 10000
297
- }
326
+ } '''Arguments for the solution algorithm'''
327
+ argument_hs = {
328
+ '_hms': 20, #harmony memory size,
329
+ '_mpai': 1, #adjustement inded
330
+ '_par': 0.3,
331
+ '_hmcr': .5
332
+ }
298
333
  obj_fun = ObjectiveFunction(X, y, **arguments)
299
- results = harmony_search(obj_fun)
334
+ results = harmony_search(obj_fun, None, argument_hs)
300
335
  print(results)
301
336
  ```
302
337
 
338
+ ## Example: Assistance by Differential Evololution and Simulated Annealing
339
+ Similiar to the above example we only need to change the hyperparamaters, the obj_fun can remane the same
340
+
341
+
342
+ ```python
343
+ argument_de = {'_AI': 2,
344
+ '_crossover_perc': .2,
345
+ '_max_iter': 1000,
346
+ '_pop_size': 25
347
+ }
348
+ de_results = differential_evolution(obj_fun, None, **argument_de)
349
+ print(de_results)
350
+
351
+
352
+ args_sa = {'alpha': .99,
353
+ 'STEPS_PER_TEMP': 10,
354
+ 'INTL_ACPT': 0.5,
355
+ '_crossover_perc': .3,
356
+ 'MAX_ITERATIONS': 1000,
357
+ '_num_intl_slns': 25,
358
+ }
359
+
360
+ sa_results = simulated_annealing(obj_fun, None, **args_sa)
361
+ print(sa_results)
362
+ ```
363
+
364
+ ## Comparing to statsmodels
365
+ The following example illustrates how the output compares to well-known packages, including Statsmodels."
366
+
367
+
368
+ ```python
369
+ # Load modules and data
370
+ import statsmodels.api as sm
371
+
372
+ data = sm.datasets.sunspots.load_pandas().data
373
+ #print(data.exog)
374
+ data_exog = data['YEAR']
375
+ data_exog = sm.add_constant(data_exog)
376
+ data_endog = data['SUNACTIVITY']
377
+
378
+ # Instantiate a gamma family model with the default link function.
379
+ import numpy as np
380
+
381
+ gamma_model = sm.NegativeBinomial(data_endog, data_exog)
382
+ gamma_results = gamma_model.fit()
383
+
384
+ print(gamma_results.summary())
385
+
386
+
387
+
388
+
389
+ #NOW LET's COMPARE THIS TO METACOUNTREGRESSOR
390
+
391
+
392
+
393
+
394
+ #Model Decisions,
395
+ manual_fit_spec = {
396
+ 'fixed_terms': ['const','YEAR'],
397
+ 'rdm_terms': [],
398
+ 'rdm_cor_terms': [],
399
+ 'grouped_terms': [],
400
+ 'hetro_in_means': [],
401
+ 'transformations': ['no', 'no'],
402
+ 'dispersion': 1 #Negative Binomial
403
+ }
404
+
405
+
406
+ #Arguments
407
+ arguments = {
408
+ 'algorithm': 'hs',
409
+ 'test_percentage': 0,
410
+ 'test_complexity': 6,
411
+ 'instance_number': 'name',
412
+ 'Manual_Fit': manual_fit_spec
413
+ }
414
+ obj_fun = ObjectiveFunction(data_exog, data_endog, **arguments)
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+ ```
423
+
424
+ Optimization terminated successfully.
425
+ Current function value: 4.877748
426
+ Iterations: 22
427
+ Function evaluations: 71
428
+ Gradient evaluations: 70
429
+ NegativeBinomial Regression Results
430
+ ==============================================================================
431
+ Dep. Variable: SUNACTIVITY No. Observations: 309
432
+ Model: NegativeBinomial Df Residuals: 307
433
+ Method: MLE Df Model: 1
434
+ Date: Tue, 13 Aug 2024 Pseudo R-squ.: 0.004087
435
+ Time: 14:13:22 Log-Likelihood: -1507.2
436
+ converged: True LL-Null: -1513.4
437
+ Covariance Type: nonrobust LLR p-value: 0.0004363
438
+ ==============================================================================
439
+ coef std err z P>|z| [0.025 0.975]
440
+ ------------------------------------------------------------------------------
441
+ const 0.2913 1.017 0.287 0.774 -1.701 2.284
442
+ YEAR 0.0019 0.001 3.546 0.000 0.001 0.003
443
+ alpha 0.7339 0.057 12.910 0.000 0.622 0.845
444
+ ==============================================================================
445
+ 0.1.88
446
+ Setup Complete...
447
+ Benchmaking test with Seed 42
448
+ 1
449
+ --------------------------------------------------------------------------------
450
+ Log-Likelihood: -1509.0683662284273
451
+ --------------------------------------------------------------------------------
452
+ bic: 3035.84
453
+ --------------------------------------------------------------------------------
454
+ MSE: 10000000.00
455
+ +--------+--------+-------+----------+----------+------------+
456
+ | Effect | $\tau$ | Coeff | Std. Err | z-values | Prob |z|>Z |
457
+ +========+========+=======+==========+==========+============+
458
+ | const | no | 0.10 | 0.25 | 0.39 | 0.70 |
459
+ +--------+--------+-------+----------+----------+------------+
460
+ | YEAR | no | 0.00 | 0.00 | 20.39 | 0.00*** |
461
+ +--------+--------+-------+----------+----------+------------+
462
+ | nb | | 1.33 | 0.00 | 50.00 | 0.00*** |
463
+ +--------+--------+-------+----------+----------+------------+
464
+
465
+
303
466
  ## Paper
304
467
 
305
468
  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)
@@ -1,19 +1,20 @@
1
1
  metacountregressor/__init__.py,sha256=UM4zaqoAcZVWyx3SeL9bRS8xpQ_iLZU9fIIARWmfjis,2937
2
2
  metacountregressor/_device_cust.py,sha256=759fnKmTYccJm4Lpi9_1reurh6OB9d6q9soPR0PltKc,2047
3
+ metacountregressor/app_main.py,sha256=vY3GczTbGbBRalbzMkl_9jVW7RMgEOc6z2Dr1IZJv9c,10014
3
4
  metacountregressor/data_split_helper.py,sha256=M2fIMdIO8znUaYhx5wlacRyNWdQjNYu1z1wkE-kFUYU,3373
4
5
  metacountregressor/halton.py,sha256=jhovA45UBoZYU9g-hl6Lb2sBIx_ZBTNdPrpgkzR9fng,9463
5
- metacountregressor/helperprocess.py,sha256=Sc5gJ7ffFlkya5B5KQwE33xxXuIQyF6OaYtSikLa3pQ,12968
6
- metacountregressor/main.py,sha256=7ln6YvX2Nmesw1ose7T-2BQdLfDz0XmiLnP991AgQHw,18273
6
+ metacountregressor/helperprocess.py,sha256=dfNLJzsl58YHWPa_--m1Wg6ttPubHc-m_DAxFI0rouA,22157
7
+ metacountregressor/main.py,sha256=xfpKN2w0kePHp_Q2HOPjtG15PLEN1L3sEnDw1PHBquw,23668
7
8
  metacountregressor/main_old.py,sha256=eTS4ygq27MnU-dZ_j983Ucb-D5XfbVF8OJQK2hVVLZc,24123
8
- metacountregressor/metaheuristics.py,sha256=2MW3qlgs7BFbe_w64snLSKc4Y0-e_9sa3s_96rUm_SE,105887
9
+ metacountregressor/metaheuristics.py,sha256=rIdBa28EroIYqoE8ZI1isuj_o-tOWHo6jKi1HQJ06lU,106292
9
10
  metacountregressor/pareto_file.py,sha256=whySaoPAUWYjyI8zo0hwAOa3rFk6SIUlHSpqZiLur0k,23096
10
11
  metacountregressor/pareto_logger__plot.py,sha256=mEU2QN4wmsM7t39GJ_XhJ_jjsdl09JOmG0U2jICrAkI,30037
11
- metacountregressor/setup.py,sha256=8w6IqX0tJsbYrOI1BJLIJCIvOnunKli5I9fsF5PhHv4,919
12
+ metacountregressor/setup.py,sha256=5UcQCCLR8Fm5odA3MX78WwahavxFq4mVD6oq0IuQvAY,936
12
13
  metacountregressor/single_objective_finder.py,sha256=jVG7GJBqzSP4_riYr-kMMKy_LE3SlGmKMunNhHYxgRg,8011
13
- metacountregressor/solution.py,sha256=wigjQ4tJrMS0EvbzmRMb2JRT7s0guvPdpCXRwEWUGQg,266891
14
+ metacountregressor/solution.py,sha256=PgGPqxIJhXV5kAOrhPrhY2HC3LtjW7qOkFByh9rpvUc,279566
14
15
  metacountregressor/test_generated_paper2.py,sha256=pwOoRzl1jJIIOUAAvbkT6HmmTQ81mwpsshn9SLdKOg8,3927
15
- metacountregressor-0.1.93.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
16
- metacountregressor-0.1.93.dist-info/METADATA,sha256=lxko7pOT-xFIpuqN3cUYr9hF3SIWszwVmGcfASHysOY,18165
17
- metacountregressor-0.1.93.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
18
- metacountregressor-0.1.93.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
19
- metacountregressor-0.1.93.dist-info/RECORD,,
16
+ metacountregressor-0.1.97.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
+ metacountregressor-0.1.97.dist-info/METADATA,sha256=yJTPnzZKd1Ncg8tV3yTqwiLjp2CgAnqkED5bMGhrQsE,23535
18
+ metacountregressor-0.1.97.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
19
+ metacountregressor-0.1.97.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
20
+ metacountregressor-0.1.97.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5