metacountregressor 0.1.33__py3-none-any.whl → 0.1.34__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.
@@ -276,7 +276,7 @@ class ObjectiveFunction(object):
276
276
 
277
277
  self._characteristics_names = list(self._x_data.columns)
278
278
  #self._characteristics_names = [x for x in self._characteristics_names if not 'ID' in x]
279
- print('to do, drop the id and panels')
279
+
280
280
 
281
281
  self._max_group_all_means = 1
282
282
 
@@ -907,6 +907,10 @@ class ObjectiveFunction(object):
907
907
  def round_with_padding(self, value, round_digits):
908
908
  return(format(np.round(value, round_digits), "."+str(round_digits)+"f"))
909
909
 
910
+ def round_with_scientific(self, value, round_digits):
911
+ return(format(np.round(value, round_digits), "."+str(round_digits)+"f"))
912
+
913
+
910
914
  def get_dispersion_name(self, dispersion=0):
911
915
  if dispersion == 0:
912
916
  return []
@@ -960,15 +964,20 @@ class ObjectiveFunction(object):
960
964
  big_hetro = [item for sublist in hetro_names_for for item in sublist]
961
965
  name_hetro = list(model_nature['hetro_hold'].keys())
962
966
  hetro_long= []
967
+ hetro_std = []
963
968
 
964
- for i in name_hetro:
965
- hetro = [f"{j}: hetro" for j in model_nature['hetro_hold'][i]]
966
- hetro.append(f"{hetro[0]}:{i}:sd hetro")
969
+ for n, i in enumerate(name_hetro):
970
+ hetro = [f"{j}: hetro group {n}" for j in model_nature['hetro_hold'][i]]
971
+ hetro = [f"main: {j}: hetro group {n}" if idx == 0 else f"{j}: hetro group {n}" for idx, j in enumerate(model_nature['hetro_hold'][i])]
972
+ hetro_std.append(f"{hetro[0]}:{i}:sd hetro group {n}")
967
973
  hetro_long = hetro_long +hetro
968
974
 
969
975
  abct = []
976
+ hetro_long = hetro_long + hetro_std
977
+ for i in model_nature['transfrom_hetro']:
978
+ abct = abct + i
970
979
  for i in model_nature['transfrom_hetro']:
971
- abct = abct + i + ['']
980
+ abct = abct + ['']
972
981
  else:
973
982
  big_hetro = []
974
983
  hetro_long = []
@@ -1065,19 +1074,26 @@ class ObjectiveFunction(object):
1065
1074
  if not isinstance(self.pvalues, np.ndarray):
1066
1075
  raise Exception
1067
1076
 
1077
+
1078
+ self.pvalues= [self.round_with_padding(x, 2) for x in self.pvalues]
1079
+ #self.pvalues= [self.round_with_scientific(x, 2) for x in self.pvalues]
1080
+
1068
1081
  for i in range(len(self.coeff_)):
1069
1082
  signif = ""
1070
-
1083
+
1071
1084
  if self.pvalues[i] < 0.01:
1072
1085
  signif = "***"
1073
1086
  elif self.pvalues[i] < 0.05:
1074
1087
  signif = "**"
1075
1088
  elif self.pvalues[i] < 0.1:
1076
1089
  signif = "*"
1090
+
1091
+ '''
1077
1092
  print(fmt.format(self.coeff_names[i][:coeff_name_str_length], self.print_transform[i], self.coeff_[i],
1078
- self.stderr[i], self.zvalues[i], self.pvalues[i],
1079
- signif
1080
- ))
1093
+ self.stderr[i], self.zvalues[i], self.pvalues[i],
1094
+ signif
1095
+ ))
1096
+ '''
1081
1097
 
1082
1098
  if not self.convergence:
1083
1099
  print("-" * 50)
@@ -1156,7 +1172,7 @@ class ObjectiveFunction(object):
1156
1172
  caption_parts.append(f"MSPE: {self.round_with_padding(self.MAE, 2)}")
1157
1173
 
1158
1174
  caption = " ".join(caption_parts)
1159
- print(latextable.draw_latex(table, caption=caption, caption_above = True))
1175
+ #print(latextable.draw_latex(table, caption=caption, caption_above = True))
1160
1176
  if solution is None:
1161
1177
  file_name = self.instance_number + "/sln" + \
1162
1178
  "_with_BIC_"+str(self.bic)+".tex"
@@ -1165,7 +1181,7 @@ class ObjectiveFunction(object):
1165
1181
  str(solution['sol_num']) + \
1166
1182
  "_with_BIC_"+str(self.bic)+".tex"
1167
1183
  self.save_to_file(latextable.draw_latex(
1168
- table, caption=caption), file_name)
1184
+ table, caption=caption, caption_above = True), file_name)
1169
1185
 
1170
1186
 
1171
1187
  #print('change this')
@@ -5770,12 +5786,20 @@ class ObjectiveFunction(object):
5770
5786
  bounds = bounds + [(i-5, i+5)]
5771
5787
  '''
5772
5788
  Kf_a, Kr_a, Kr_c, Kr_b_a, Kchol_a, Kh, zi_terms_a = self.get_num_params()
5773
-
5789
+ if Kh > 0:
5790
+ Kh_e = mod.get('XH').shape[-1]
5791
+ Kh_range = Kh-Kh_e
5792
+ else:
5793
+ Kh_e = 0
5794
+ Kh_rannge = 0
5774
5795
  sum1 = Kf_a + Kr_a + Kr_c
5775
- sum2 = sum1 + Kr_b_a
5796
+ sumk = sum1 +Kh_e
5797
+ sum2 = sumk + Kr_b_a
5776
5798
  sum3 = sum2 + Kchol_a
5799
+ sum4 = sum3 +Kh
5777
5800
 
5778
5801
  bounds = []
5802
+ bounds_k = []
5779
5803
  bob = b[0:sum2]
5780
5804
  bob2 = b[sum2:sum3]
5781
5805
  if dispersion ==1 or dispersion ==2:
@@ -5786,6 +5810,9 @@ class ObjectiveFunction(object):
5786
5810
  for j, i in enumerate(bob):
5787
5811
  if j < sum1:
5788
5812
  bounds.append((i-15, i+15))
5813
+ elif j < sumk:
5814
+ bounds_k.append(i)
5815
+
5789
5816
  elif j < sum2:
5790
5817
  bounds.append((0.1, i+7))
5791
5818
 
@@ -5811,6 +5838,12 @@ class ObjectiveFunction(object):
5811
5838
  count = 0
5812
5839
  bounds.append((0.1,bob2[count]+5))
5813
5840
 
5841
+ if Kh > 0:
5842
+ for bbb in bounds_k:
5843
+ bounds.append((bbb-15, bbb+15))
5844
+ for bbb in range(Kh_range):
5845
+ bounds.append((.1, 5))
5846
+
5814
5847
 
5815
5848
 
5816
5849
 
@@ -5908,7 +5941,7 @@ class ObjectiveFunction(object):
5908
5941
  if dispersion ==1:
5909
5942
  mod['dispersion_penalty'] = abs(b[-1])
5910
5943
 
5911
- betas_est = self._minimize(self._loglik_gradient, b, args=(X, y, draws, X, Xr, self.batch_size, False, False, dispersion, 0, False, 0, self.rdm_cor_fit, self.zi_fit, exog_infl, draws_grouped, XG, mod),
5944
+ betas_est = self._minimize(self._loglik_gradient, b, args=(X, y, draws, X, Xr, self.batch_size, True, True, dispersion, 0, False, 0, self.rdm_cor_fit, self.zi_fit, exog_infl, draws_grouped, XG, mod),
5912
5945
  method=method2, tol=tol['ftol'],
5913
5946
  options={'gtol': tol['gtol']}, bounds = bounds)
5914
5947
  # betas_est = self._minimize(self._loglik_gradient, b, args=(X, y, draws, X, Xr, self.batch_size, True, True, dispersion, 0, False, 0, self.rdm_cor_fit, self.zi_fit, exog_infl, draws_grouped, XG, mod),
@@ -6572,11 +6605,11 @@ class ObjectiveFunction(object):
6572
6605
 
6573
6606
 
6574
6607
  alpha_cor_rdm = np.isin(select_data, [item.split(':')[0] for item in data.get('rdm_cor_terms', [])]).astype(int).tolist()
6575
- print(alpha_cor_rdm)
6608
+
6576
6609
  alpha_group_rdm = np.isin(select_data, data.get('group_rdm', [])).astype(int).tolist()
6577
6610
  alpha_hetro = np.isin(select_data, [item.split(':')[0] for item in data.get('hetro_in_means', [])]).astype(int).tolist()
6578
6611
  for i in range(len(alpha_rdm)):
6579
- print(alpha_cor_rdm)
6612
+
6580
6613
  if alpha[i]:
6581
6614
  fixed_transforms.append(data['transformations'][jc+ja+jb+j])
6582
6615
  fixed_terms_subset.append('normal')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: metacountregressor
3
- Version: 0.1.33
3
+ Version: 0.1.34
4
4
  Summary: A python package for count regression of rare events assisted by metaheuristics
5
5
  Author: zahern
6
6
  Author-email: zeke.ahern@hdr.qut.edu.au
@@ -38,7 +38,7 @@ metacountregressor/set_data.csv,sha256=2LEtfJXHK9Jh3YZ_MpBt6TUGWWk-zsXIyI9PnH_Ye
38
38
  metacountregressor/set_data_s.csv,sha256=hELwnv6RjpmXcMheFafwrYbLbyYE21hFKyqJhA8L05o,11111
39
39
  metacountregressor/setup.py,sha256=CpbdBScFhvStc6WByFiAlP7T5wGdWetsLI8X5JRRpP4,268
40
40
  metacountregressor/single_objective_finder.py,sha256=QYXUpxJp7-ul5ZiIKGgYGaH_yFFGUbI7X3yKu5asogE,1960
41
- metacountregressor/solution.py,sha256=ULUjgXLKUn-unMsseCDreIwvv4_tTTeM2MkH6RlLjjo,290351
41
+ metacountregressor/solution.py,sha256=tUd2f36cN60D6FOjIVZJfaWLi7yFhAVGLgFRPcBycZo,291869
42
42
  metacountregressor/Stage5A_1848_All_Initial_Columns.csv,sha256=uwsadEyupgIH1w5f8vnlwlo13ryww3VCGYlOnN0dEL0,188769
43
43
  metacountregressor/Stage5A_1848_All_Initial_Columns.xlsx,sha256=5U5Ab1jjGi5qoKp06Bw2tpdPjGaDGoyt5976AAFdEbs,699231
44
44
  metacountregressor/synth_dataset_generator.ipynb,sha256=caBMQJOaeINPZJw5aTsSOXhmenSqrpS7GycINAzUUxs,27153
@@ -48,6 +48,6 @@ metacountregressor/testML.R,sha256=UbTsLFUhoJG9bJnU2rbUKlfcprAkROnhREK41qKzbvQ,2
48
48
  metacountregressor/TestSetFake.csv,sha256=JPYAWYLAw7rgQHdGTz0rltMfapX8QYt3BVSyK_D-Lzg,1640
49
49
  metacountregressor/ThaiAccident.csv,sha256=NIi_uPyo5u-B6Hj0Ln9xuJ8fnvGbWK9GLdTWdpG5uug,418202
50
50
  metacountregressor/tk_app.py,sha256=0UM76hpQ-ha96ma_Z5ryxYQUSdF4PJBCsLuI1EGu6_E,59490
51
- metacountregressor-0.1.33.dist-info/METADATA,sha256=yAVqCOFeUdZhARSH5jb6XwGXgWDXZTNWJxbqYZCAyVc,3391
52
- metacountregressor-0.1.33.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
53
- metacountregressor-0.1.33.dist-info/RECORD,,
51
+ metacountregressor-0.1.34.dist-info/METADATA,sha256=KVCPwaZPaSW7ETzwDlOhAR419gwNidItaPth5Ai_dWE,3391
52
+ metacountregressor-0.1.34.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
53
+ metacountregressor-0.1.34.dist-info/RECORD,,