metacountregressor 0.1.348__tar.gz → 1.0.2__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.
Files changed (32) hide show
  1. {metacountregressor-0.1.348/metacountregressor.egg-info → metacountregressor-1.0.2}/PKG-INFO +1 -1
  2. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/solution.py +14 -12
  3. metacountregressor-1.0.2/metacountregressor/test_code.py +43 -0
  4. {metacountregressor-0.1.348 → metacountregressor-1.0.2/metacountregressor.egg-info}/PKG-INFO +1 -1
  5. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor.egg-info/SOURCES.txt +1 -0
  6. metacountregressor-1.0.2/version.txt +1 -0
  7. metacountregressor-0.1.348/version.txt +0 -1
  8. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/LICENSE.txt +0 -0
  9. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/MANIFEST.in +0 -0
  10. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/README.md +0 -0
  11. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/README.rst +0 -0
  12. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/__init__.py +0 -0
  13. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/_device_cust.py +0 -0
  14. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/app_main.py +0 -0
  15. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/data_split_helper.py +0 -0
  16. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/halton.py +0 -0
  17. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/helperprocess.py +0 -0
  18. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/main.py +0 -0
  19. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/main_old.py +0 -0
  20. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/metaheuristics.py +0 -0
  21. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/pareto_file.py +0 -0
  22. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/pareto_logger__plot.py +0 -0
  23. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/setup.py +0 -0
  24. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/single_objective_finder.py +0 -0
  25. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor/test_generated_paper2.py +0 -0
  26. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor.egg-info/dependency_links.txt +0 -0
  27. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor.egg-info/not-zip-safe +0 -0
  28. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor.egg-info/requires.txt +0 -0
  29. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/metacountregressor.egg-info/top_level.txt +0 -0
  30. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/setup.cfg +0 -0
  31. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/setup.py +0 -0
  32. {metacountregressor-0.1.348 → metacountregressor-1.0.2}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metacountregressor
3
- Version: 0.1.348
3
+ Version: 1.0.2
4
4
  Summary: Extensive Testing for Estimation of Data Count Models
5
5
  Home-page: https://github.com/zahern/CountDataEstimation
6
6
  Author: Zeke Ahern
@@ -459,14 +459,12 @@ class ObjectiveFunction(object):
459
459
 
460
460
  if self.G is not None:
461
461
  #TODO need to handle this for groups
462
- print('group by groups off for now')
463
- NAH_GROUP = 0
464
- if NAH_GROUP:
465
- self._distribution = ["trad| " + item for item in self._distribution
462
+
463
+
464
+ self._distribution = ["trad| " + item for item in self._distribution
466
465
  ] + ["grpd| " + item for item in self._distribution]
467
- else:
468
- self._distribution = ["trad| " + item for item in self._distribution
469
- ]
466
+
467
+
470
468
 
471
469
  # output information
472
470
  self.convergence = None
@@ -7229,7 +7227,7 @@ class ObjectiveFunction(object):
7229
7227
  if len(self.none_handler(zi)) > 0:
7230
7228
  the_name = the_name + '_zi'
7231
7229
  if model_nature is not None:
7232
- if 'XG' in model_nature:
7230
+ if 'XG' in model_nature and model_nature.get('XG') is not None:
7233
7231
  if model_nature.get('XG').shape[2] > 0:
7234
7232
  the_name = the_name + 'grp'
7235
7233
 
@@ -7302,10 +7300,11 @@ class ObjectiveFunction(object):
7302
7300
  if grouped_rpm is None:
7303
7301
  a =len(self.rdm_cor_fit)+len(self.rdm_fit) != Xr.shape[2]
7304
7302
  else:
7305
- a = len(self.none_handler(self.rdm_cor_fit)) + len(self.none_handler(self.rdm_fit)) + len(self.none_handler(grouped_rpm)) != Xr.shape[2]
7303
+ a = len(self.none_handler(self.rdm_cor_fit)) + len(self.none_handler(self.rdm_fit)) + len(self.none_handler(grouped_rpm))*self._Gnum != Xr.shape[2]
7306
7304
 
7307
7305
  if a:
7308
7306
  print('why')
7307
+
7309
7308
  print('The number of random effects does not match the data')
7310
7309
  print(Xr.shape)
7311
7310
  print(self.rdm_cor_fit)
@@ -7385,16 +7384,19 @@ class ObjectiveFunction(object):
7385
7384
  self.group_dummies.shape[2]) if self.grouped_rpm != [] else []
7386
7385
  X_set = df_tf[:, :, indices4]
7387
7386
  XG = np.tile(self.group_dummies, len(self.grouped_rpm)) * X_set if X_set.shape[2] != 0 else None
7387
+ if XG is not None:
7388
+ model_nature['XG'] = XG
7389
+
7388
7390
  else:
7389
7391
  XG = None
7390
7392
  X = df_tf[:, :, indices]
7391
7393
  XH = df_tf[:, :, indices5]
7392
7394
 
7393
- if XG is not None:
7395
+ if XG is not None and self.is_multi:
7394
7396
  indices4_test = np.repeat(self.get_named_indices(self.grouped_rpm),
7395
7397
  self.group_dummies_test.shape[2]) if self.grouped_rpm != [] else []
7396
7398
  XGtest = np.tile(self.group_dummies_test, len(self.grouped_rpm)) * df_test[:, :, indices4_test]
7397
- model_nature['XG'] = XG
7399
+ #model_nature['XG'] = XG
7398
7400
  model_nature['XGtest'] = XGtest
7399
7401
 
7400
7402
  model_nature['X'] = X
@@ -7413,7 +7415,7 @@ class ObjectiveFunction(object):
7413
7415
  if np.isin(X, [np.inf, -np.inf, None, np.nan]).any(): # type ignore
7414
7416
  raise Exception('there is some kind of error in X')
7415
7417
 
7416
- # numpy data setup fpr estimation
7418
+ # numpy data setup for estimation
7417
7419
  indices2 = self.get_named_indices(self.rdm_fit)
7418
7420
  Xr = df_tf[:, :, indices2]
7419
7421
  if self.rdm_cor_fit is not None:
@@ -0,0 +1,43 @@
1
+ from solution import ObjectiveFunction
2
+ from metaheuristics import (harmony_search,differential_evolution,simulated_annealing)
3
+ #from . import helperprocess
4
+ import pandas as pd
5
+
6
+ df = pd.read_csv("https://raw.githubusercontent.com/zahern/data/refs/heads/main/rural_int.csv")
7
+ y = df['crashes'] # Frequency of crashes
8
+
9
+ df.drop(columns=[ 'year', 'orig_ID',
10
+ 'jurisdiction', 'town', 'maint_region', 'weather_station', 'dummy_winter_2', 'month', 'inj.fat', 'PDO', 'zonal_ID', 'ln_AADT', 'ln_seg'], inplace=True) # was dropped postcode
11
+
12
+
13
+
14
+ arguments_hs = {'_par': 0.3, '_hms': 20}
15
+ arguments = {'test_percentage': 0.2, 'complexity_level': 5, 'reg_penalty':0} #Objective args
16
+ # Step 2: Process Data
17
+ model_terms = {
18
+ 'Y': 'crashes', # Dependent variable
19
+ 'group': 'county', # Grouping column (if any)
20
+ 'panels': 'element_ID', # Panel column (if any)
21
+ 'Offset': None # Offset column (if any)
22
+ }
23
+
24
+
25
+ X = df.drop(columns=['crashes']) # setup X based on data
26
+ X.columns
27
+ print(X.columns)
28
+
29
+ manual_fit_spec = {
30
+ 'fixed_terms': ['const', 'DP10'],
31
+ 'rdm_terms': [ 'DX32:normal'],
32
+ 'rdm_cor_terms': [],
33
+ 'group_rdm': ['DPO1:triangular'],
34
+ 'hetro_in_means': [],
35
+ 'transformations': ['no', 'no', 'no', 'no', 'no', 'no'],
36
+ 'dispersion': 0
37
+ }
38
+ arguments = {'test_percentage': 0.2, 'complexity_level': 6, 'reg_penalty':0, 'group':'county', 'panels':'element_ID'} #Objective args
39
+ arguments['Manual_Fit'] = manual_fit_spec
40
+ #initial_solution = None
41
+ obj_fun = ObjectiveFunction(X, y, **arguments)
42
+ initial_solution = None
43
+ results_hs = harmony_search(obj_fun, initial_solution, **arguments_hs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metacountregressor
3
- Version: 0.1.348
3
+ Version: 1.0.2
4
4
  Summary: Extensive Testing for Estimation of Data Count Models
5
5
  Home-page: https://github.com/zahern/CountDataEstimation
6
6
  Author: Zeke Ahern
@@ -19,6 +19,7 @@ metacountregressor/pareto_logger__plot.py
19
19
  metacountregressor/setup.py
20
20
  metacountregressor/single_objective_finder.py
21
21
  metacountregressor/solution.py
22
+ metacountregressor/test_code.py
22
23
  metacountregressor/test_generated_paper2.py
23
24
  metacountregressor.egg-info/PKG-INFO
24
25
  metacountregressor.egg-info/SOURCES.txt
@@ -0,0 +1 @@
1
+ 1.0.2
@@ -1 +0,0 @@
1
- 0.1.348