metacountregressor 0.1.232__py3-none-any.whl → 0.1.233__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.
@@ -117,7 +117,7 @@ def logger(iteration, incumbent1, best1=None, alt_method=True, name=None, multi=
117
117
  try:
118
118
  incumbent.pop('pvalues')
119
119
  except Exception as e:
120
- print(e)
120
+ print(e, 'cant pop')
121
121
 
122
122
  incumbent = pd.DataFrame(incumbent, index=[0])
123
123
  incumbent = incumbent.add_prefix('incumbent_')
@@ -376,7 +376,7 @@ class Metaheuristic(object):
376
376
  fitness = 10 ** 9
377
377
  except Exception as e:
378
378
  fitness = 10 ** 9
379
- print(e)
379
+ print(e, 'fitness eror meta')
380
380
  # print('solution struct', initial_slns[i])
381
381
  print('the final fitness is', fitness)
382
382
  if self.pf.get_objective_is_multi():
@@ -503,7 +503,7 @@ class DifferentialEvolution(object):
503
503
  new_index = current_index + self.F * (
504
504
  self._obj_fun.get_index(i, struct_b[i]) - self._obj_fun.get_index(i, struct_c[i]))
505
505
  except Exception as e:
506
- print(e)
506
+ print(e, 'index errpr [rpb;es jere]')
507
507
  print(struct_b)
508
508
  print(struct_c)
509
509
  new_index = 0
@@ -855,7 +855,7 @@ class SimulatedAnnealing(object):
855
855
  fit_ob_2 = fitness.get(self.obj_2)
856
856
  self.pf.evaluate_frontier_against_new_sln(fitness)
857
857
  except Exception as e:
858
- print(e)
858
+ print(e, 'sa error part')
859
859
 
860
860
 
861
861
 
@@ -1012,7 +1012,7 @@ class SimulatedAnnealing(object):
1012
1012
  elif num_of_changeablePARMs == 0:
1013
1013
  rdm_i = random.choice(range(len(prmVect)))
1014
1014
  if self._obj_fun.get_num_discrete_values(rdm_i) <= 1:
1015
- print('retry')
1015
+ print('retry, not a enough choices')
1016
1016
 
1017
1017
  while self._obj_fun.get_num_discrete_values(rdm_i) <= 1:
1018
1018
  rdm_i = random.randint(0, self._obj_fun.get_num_parameters() - 1)
@@ -1123,7 +1123,7 @@ class SimulatedAnnealing(object):
1123
1123
  fitness = 10 ** 9
1124
1124
  except Exception as e:
1125
1125
  fitness = 10 ** 9
1126
- print(e)
1126
+ print(e, 'sa here co')
1127
1127
  # print('solution struct', initial_slns[i])
1128
1128
  print('the final fitness is', fitness)
1129
1129
  if self.pf.get_objective_is_multi():
@@ -1175,7 +1175,8 @@ class SimulatedAnnealing(object):
1175
1175
  fitness.get(self._obj_fun._obj_1)) # TODO handle specific swithhing of objectives.
1176
1176
  fitness_list_2.append(fitness.get(self._obj_fun._obj_2))
1177
1177
  except Exception as e:
1178
- print(e)
1178
+ print(e,
1179
+ 'fitness list eror')
1179
1180
 
1180
1181
  # Temp1
1181
1182
  Temp1 = (-st.stdev(fitness_list)) / np.log(1 - acceptance_prob)
@@ -1398,7 +1399,7 @@ class HarmonySearch(object):
1398
1399
  logger(num_imp, fitness, self._harmony_memory, True, self.get_instance_name(),
1399
1400
  1) # for consistency
1400
1401
  except Exception as e:
1401
- print(e)
1402
+ print(e, 'logger run hs')
1402
1403
  # logger(num_imp, fitness, self._pareto_harmony_memory, True, self.instance_number +'/log_for_pareto_harmony_memory.csv', 1)
1403
1404
 
1404
1405
 
@@ -1670,7 +1671,7 @@ class HarmonySearch(object):
1670
1671
  try:
1671
1672
  new_index = current_index + random.randint(1, self._obj_fun.get_mpai()) * random.choice([-1, 1])
1672
1673
  except Exception as e:
1673
- print(e)
1674
+ print(e, 'index error, this is probs it')
1674
1675
  new_index = current_index
1675
1676
  if new_index not in range(0, len(self._obj_fun._discrete_values[i])):
1676
1677
  new_index = self._obj_fun.modulo_or_divisor(new_index,
@@ -1351,7 +1351,7 @@ class ObjectiveFunction(object):
1351
1351
  self.save_to_file(latextable.draw_latex(
1352
1352
  table, caption=caption), file_name)
1353
1353
  except Exception as e:
1354
- print(e)
1354
+ print(e, 'here, summary table')
1355
1355
 
1356
1356
  def save_to_file(self, content, filename):
1357
1357
  with open(filename, 'w') as file:
@@ -1967,125 +1967,111 @@ class ObjectiveFunction(object):
1967
1967
  def get_pvalue_info_alt(self, pvalues, names, sig_value=0.05, dispersion=0, is_halton=1, delete=0,
1968
1968
  return_violated_terms=0):
1969
1969
 
1970
- num_params = len(pvalues)
1971
- Kf, Kr, Kc, Kr_b, Kchol, Kh = self.get_num_params()
1972
-
1973
- vio_counts = 0
1974
- pvalues = np.array([float(string) for string in pvalues])
1975
- if dispersion == 0:
1976
- subpvalues = pvalues.copy()
1977
-
1978
- else:
1979
- slice_this_amount = self.num_dispersion_params(dispersion)
1980
- slice_this_amount = 0 #TODO handle this
1981
- if pvalues[-1] > sig_value:
1982
- vio_counts += 1
1983
- subpvalues = pvalues[:-slice_this_amount].copy()
1984
-
1985
- if Kh > 1:
1986
- if subpvalues[-1] < sig_value:
1987
- subpvalues[-Kh] = 0
1988
-
1989
- subpvalues = np.array([float(string) for string in subpvalues])
1990
-
1991
- if Kr_b + Kchol > 0:
1992
- sum_k = Kf + Kr + Kc
1993
- for i in range(Kf, sum_k):
1994
- subpvalues[i] = 0
1995
-
1996
- sum_k += Kr_b
1997
- lower_triangular = subpvalues[sum_k:sum_k + Kchol]
1998
-
1999
-
2000
- # initialize matrix with zeros
2001
- matrix_alt = [[0] * Kc for _ in range(Kc)]
2002
- index = 0
2003
-
2004
- for i in range(Kc):
2005
- for j in range(i + 1):
2006
- # fill in lower triangular entries
2007
- matrix_alt[i][j] = lower_triangular[index]
2008
- # fill in upper triangular entries
2009
- matrix_alt[j][i] = lower_triangular[index]
2010
- index += 1
2011
-
2012
- if len(matrix_alt) > 0:
2013
- matrix_alt = np.array(matrix_alt)
2014
- # block out potential random parameters
2015
- matrix_diag = np.diag(matrix_alt).copy()
2016
-
2017
- np.fill_diagonal(matrix_alt, sig_value)
2018
-
2019
- # set_matrix_alt to 0 for signficant correlated tersm
2020
- # Find the rows where any element is less than the threshold
2021
- rows_to_zero = np.any(matrix_alt < sig_value, axis=1)
2022
-
2023
- # Set the corresponding rows to zero
2024
- matrix_alt[rows_to_zero, :] = 0
2025
-
2026
- if np.max(matrix_alt) < sig_value:
2027
- for j in range(sum_k, sum_k + Kchol):
2028
- subpvalues[j] = 0
2029
- else:
2030
-
2031
- # revert the matrix
2032
- np.fill_diagonal(matrix_alt, matrix_diag)
2033
-
2034
- # convert 2d matrix, into a lower triangular marix flattened
2035
- result = []
2036
- n_rows, n_cols = np.shape(matrix_alt)
2037
- for i in range(n_rows):
2038
- for j in range(n_cols):
2039
- if j <= i:
2040
- result.append(matrix_alt[i][j])
2041
-
2042
- ii = 0
2043
- for j in range(sum_k, sum_k + Kchol):
2044
- # print(names[i])
2045
-
2046
- subpvalues[j] = result[ii]
2047
- ii += 1
2048
-
2049
- vio_counts += len([i for i in subpvalues if i > sig_value])
2050
-
2051
- saving_at_least = random.randint(1, 6)
2052
- max_delete_pre = np.max((len(self.none_handler(self.fixed_fit) + self.none_handler(
2053
- self.rdm_fit) + self.none_handler(self.rdm_cor_fit)) - saving_at_least, 0))
2054
- max_delete = np.min((max_delete_pre, saving_at_least))
2055
- indexes = sorted(range(len(subpvalues)),
2056
- key=lambda i: subpvalues[i], reverse=True)
2057
- indexes = indexes[:max_delete]
1970
+ try:
1971
+ num_params = len(pvalues)
1972
+ Kf, Kr, Kc, Kr_b, Kchol, Kh = self.get_num_params()
2058
1973
 
2059
- if np.max(subpvalues) > sig_value:
2060
- if num_params <= self._min_characteristics:
2061
- self.significant = 2
2062
- if return_violated_terms:
1974
+ vio_counts = 0
1975
+ pvalues = np.array([float(string) for string in pvalues])
1976
+ if dispersion == 0:
1977
+ subpvalues = pvalues.copy()
1978
+ else:
1979
+ slice_this_amount = self.num_dispersion_params(dispersion)
1980
+ slice_this_amount = 0 # TODO handle this
1981
+ if pvalues[-1] > sig_value:
1982
+ vio_counts += 1
1983
+ subpvalues = pvalues[:-slice_this_amount].copy()
1984
+
1985
+ if Kh > 1:
1986
+ if subpvalues[-1] < sig_value:
1987
+ subpvalues[-Kh] = 0
1988
+
1989
+ subpvalues = np.array([float(string) for string in subpvalues])
1990
+
1991
+ if Kr_b + Kchol > 0:
1992
+ sum_k = Kf + Kr + Kc
1993
+ for i in range(Kf, sum_k):
1994
+ subpvalues[i] = 0
1995
+
1996
+ sum_k += Kr_b
1997
+ lower_triangular = subpvalues[sum_k:sum_k + Kchol]
1998
+
1999
+ # initialize matrix with zeros
2000
+ matrix_alt = [[0] * Kc for _ in range(Kc)]
2001
+ index = 0
2002
+
2003
+ for i in range(Kc):
2004
+ for j in range(i + 1):
2005
+ # fill in lower triangular entries
2006
+ matrix_alt[i][j] = lower_triangular[index]
2007
+ # fill in upper triangular entries
2008
+ matrix_alt[j][i] = lower_triangular[index]
2009
+ index += 1
2010
+
2011
+ if len(matrix_alt) > 0:
2012
+ matrix_alt = np.array(matrix_alt)
2013
+ # block out potential random parameters
2014
+ matrix_diag = np.diag(matrix_alt).copy()
2015
+
2016
+ np.fill_diagonal(matrix_alt, sig_value)
2017
+
2018
+ # set_matrix_alt to 0 for significant correlated terms
2019
+ rows_to_zero = np.any(matrix_alt < sig_value, axis=1)
2020
+ matrix_alt[rows_to_zero, :] = 0
2021
+
2022
+ if np.max(matrix_alt) < sig_value:
2023
+ for j in range(sum_k, sum_k + Kchol):
2024
+ subpvalues[j] = 0
2025
+ else:
2026
+ # revert the matrix
2027
+ np.fill_diagonal(matrix_alt, matrix_diag)
2028
+
2029
+ # convert 2d matrix into a lower triangular matrix flattened
2030
+ result = []
2031
+ n_rows, n_cols = np.shape(matrix_alt)
2032
+ for i in range(n_rows):
2033
+ for j in range(n_cols):
2034
+ if j <= i:
2035
+ result.append(matrix_alt[i][j])
2036
+
2037
+ ii = 0
2038
+ for j in range(sum_k, sum_k + Kchol):
2039
+ subpvalues[j] = result[ii]
2040
+ ii += 1
2041
+
2042
+ vio_counts += len([i for i in subpvalues if i > sig_value])
2043
+
2044
+ saving_at_least = random.randint(1, 6)
2045
+ max_delete_pre = max(len(self.none_handler(self.fixed_fit) +
2046
+ self.none_handler(self.rdm_fit) +
2047
+ self.none_handler(self.rdm_cor_fit)) - saving_at_least, 0)
2048
+ max_delete = min(max_delete_pre, saving_at_least)
2049
+ indexes = sorted(range(len(subpvalues)),
2050
+ key=lambda i: subpvalues[i], reverse=True)
2051
+ indexes = indexes[:max_delete]
2052
+
2053
+ if np.max(subpvalues) > sig_value:
2054
+ if num_params <= self._min_characteristics:
2055
+ self.significant = 2
2063
2056
  return False, vio_counts
2064
- else:
2065
- return False, vio_counts # added for testing
2066
-
2067
- if delete:
2068
- # if self.get_type_and_safe(max_index):
2069
- delete_idx = [i for i in range(
2070
- len(subpvalues)) if subpvalues[i] > sig_value]
2071
- if len(delete_idx) > len(indexes):
2072
- delete_idx = indexes
2073
2057
 
2074
- self.get_block_to_delete(delete_idx, dispersion)
2058
+ if delete:
2059
+ delete_idx = [i for i in range(len(subpvalues)) if subpvalues[i] > sig_value]
2060
+ if len(delete_idx) > len(indexes):
2061
+ delete_idx = indexes
2075
2062
 
2076
- # self.get_value_to_delete(max_index, dispersion)
2077
- if return_violated_terms:
2063
+ self.get_block_to_delete(delete_idx, dispersion)
2078
2064
  return True, vio_counts
2079
- else:
2080
- return True, vio_counts # added for testing
2081
-
2082
- else:
2083
- self.significant = 1
2084
2065
 
2085
- if return_violated_terms:
2066
+ else:
2067
+ self.significant = 1
2086
2068
  return False, vio_counts
2087
- else:
2088
- return False, vio_counts # added for testing
2069
+
2070
+ except IndexError as e:
2071
+ print(f"IndexError encountered: {e}")
2072
+ # Return st and vio_counts when IndexError occurs
2073
+ st = False # or any default value for st
2074
+ return st, vio_counts
2089
2075
 
2090
2076
  def get_coeff_names(self, is_halton, rdm_params, rdm_distr, fixed_params=None, dispersion=0):
2091
2077
  combine_tr = [i + ' (Std. Dev.) ' + rdm_distr[j]
@@ -2435,14 +2421,18 @@ class ObjectiveFunction(object):
2435
2421
  sub_slns.append([obj_1.copy()])
2436
2422
 
2437
2423
  obj_best = obj_1.copy()
2438
- if any(sub_string in obj_1['simple'] for sub_string in ["rp", "c", "zi"]):
2439
- trial_run, vio_counts = self.get_pvalue_info_alt(
2440
- self.pvalues, self.coeff_names, self.pvalue_sig_value, dispersion, 1, trial_run) # i added
2424
+ '''old code turning off'''
2425
+
2441
2426
 
2442
2427
  trial_run = 0
2428
+ if trial_run:
2429
+ if any(sub_string in obj_1['simple'] for sub_string in ["rp", "c", "zi"]):
2430
+ trial_run, vio_counts = self.get_pvalue_info_alt(
2431
+ self.pvalues, self.coeff_names, self.pvalue_sig_value, dispersion, 1, trial_run) # i added
2432
+
2443
2433
 
2444
2434
  # trial_run = self.get_pvalue_info_alt(self.pvalues, self.coeff_names, sig_value = 0.05, dispersion = dispersion ,is_halton = obj_1['simple'], delete = 1)
2445
- if trial_run:
2435
+ while trial_run:
2446
2436
 
2447
2437
  if obj_1['num_parm'] - obj_1['pval_exceed'] > 5:
2448
2438
  self.repair(vector, obj_1['num_parm'] - 5)
@@ -5036,7 +5026,7 @@ class ObjectiveFunction(object):
5036
5026
  #return output
5037
5027
  except Exception as e:
5038
5028
  traceback.print_exc()
5039
- print(e)
5029
+ print(e, 'where loglik')
5040
5030
 
5041
5031
  def minimize_function(self, loglike):
5042
5032
  r'Takes the logliklihood function and tranforms it to a more handed minimization function'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: metacountregressor
3
- Version: 0.1.232
3
+ Version: 0.1.233
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
@@ -6,15 +6,15 @@ metacountregressor/halton.py,sha256=jhovA45UBoZYU9g-hl6Lb2sBIx_ZBTNdPrpgkzR9fng,
6
6
  metacountregressor/helperprocess.py,sha256=_g5j-p5cC5ajqdG0Ab1cSLR-CkzLBCcreIGPCZK1G9s,22157
7
7
  metacountregressor/main.py,sha256=xfpKN2w0kePHp_Q2HOPjtG15PLEN1L3sEnDw1PHBquw,23668
8
8
  metacountregressor/main_old.py,sha256=eTS4ygq27MnU-dZ_j983Ucb-D5XfbVF8OJQK2hVVLZc,24123
9
- metacountregressor/metaheuristics.py,sha256=N8RwP7Y7aNkSOxCusLwtcCx357RlDkVz84haxaQGwXc,106518
9
+ metacountregressor/metaheuristics.py,sha256=d9jIwCTf2XRoW4UqrJHXBSS1W4XU-TwSeWWVMGo2Jdw,106731
10
10
  metacountregressor/pareto_file.py,sha256=whySaoPAUWYjyI8zo0hwAOa3rFk6SIUlHSpqZiLur0k,23096
11
11
  metacountregressor/pareto_logger__plot.py,sha256=mEU2QN4wmsM7t39GJ_XhJ_jjsdl09JOmG0U2jICrAkI,30037
12
12
  metacountregressor/setup.py,sha256=5UcQCCLR8Fm5odA3MX78WwahavxFq4mVD6oq0IuQvAY,936
13
13
  metacountregressor/single_objective_finder.py,sha256=jVG7GJBqzSP4_riYr-kMMKy_LE3SlGmKMunNhHYxgRg,8011
14
- metacountregressor/solution.py,sha256=bXWT-75UAuGnlAvKbHKnyWwJZq93ZyFHJnYEF_eou5k,284741
14
+ metacountregressor/solution.py,sha256=0RGqZ60LVa3Ek-w6haCXpu_6Eav9-qrfQet9EbCTW2Y,284756
15
15
  metacountregressor/test_generated_paper2.py,sha256=pwOoRzl1jJIIOUAAvbkT6HmmTQ81mwpsshn9SLdKOg8,3927
16
- metacountregressor-0.1.232.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
- metacountregressor-0.1.232.dist-info/METADATA,sha256=vG50v7ZciPNwBjJWMFDibsiCWH-lFhtOBUVsrnyfhwo,23529
18
- metacountregressor-0.1.232.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
19
- metacountregressor-0.1.232.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
20
- metacountregressor-0.1.232.dist-info/RECORD,,
16
+ metacountregressor-0.1.233.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
+ metacountregressor-0.1.233.dist-info/METADATA,sha256=2aBoFmLZgCS1eABnQFi-7XvRWbvpCWfXbcNuYZkEeyQ,23529
18
+ metacountregressor-0.1.233.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
19
+ metacountregressor-0.1.233.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
20
+ metacountregressor-0.1.233.dist-info/RECORD,,