metacountregressor 0.1.136__tar.gz → 0.1.138__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 (27) hide show
  1. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/PKG-INFO +1 -1
  2. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/helperprocess.py +50 -6
  3. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/metaheuristics.py +14 -4
  4. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/solution.py +6 -6
  5. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor.egg-info/PKG-INFO +1 -1
  6. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/LICENSE.txt +0 -0
  7. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/README.rst +0 -0
  8. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/__init__.py +0 -0
  9. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/_device_cust.py +0 -0
  10. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/app_main.py +0 -0
  11. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/data_split_helper.py +0 -0
  12. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/halton.py +0 -0
  13. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/main.py +0 -0
  14. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/main_old.py +0 -0
  15. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/pareto_file.py +0 -0
  16. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/pareto_logger__plot.py +0 -0
  17. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/setup.py +0 -0
  18. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/single_objective_finder.py +0 -0
  19. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor/test_generated_paper2.py +0 -0
  20. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor.egg-info/SOURCES.txt +0 -0
  21. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor.egg-info/dependency_links.txt +0 -0
  22. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor.egg-info/not-zip-safe +0 -0
  23. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor.egg-info/requires.txt +0 -0
  24. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/metacountregressor.egg-info/top_level.txt +0 -0
  25. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/setup.cfg +0 -0
  26. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/setup.py +0 -0
  27. {metacountregressor-0.1.136 → metacountregressor-0.1.138}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: metacountregressor
3
- Version: 0.1.136
3
+ Version: 0.1.138
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
@@ -1,12 +1,29 @@
1
+ from os.path import exists
2
+
1
3
  import numpy as np
2
4
  import pandas as pd
3
5
  import csv
4
6
  import matplotlib.pyplot as plt
5
7
  from scipy import stats as st
6
8
  from sklearn.preprocessing import StandardScaler
9
+ from win32comext.shell.demos.IActiveDesktop import existing_item
7
10
 
8
11
  plt.style.use('https://github.com/dhaitz/matplotlib-stylesheets/raw/master/pitayasmoothie-dark.mplstyle')
9
12
 
13
+
14
+
15
+
16
+
17
+ from itertools import product
18
+
19
+ # Function to create a list of dictionaries from a parameter grid
20
+ def generate_param_combinations(param_grid):
21
+ keys = param_grid.keys()
22
+ values = param_grid.values()
23
+ combinations = [dict(zip(keys, v)) for v in product(*values)]
24
+ return combinations
25
+
26
+
10
27
  ##Select the best Features Based on RF
11
28
  def select_features(X_train, y_train, n_f=16):
12
29
  try:
@@ -179,17 +196,38 @@ config = {
179
196
  }
180
197
  }
181
198
  '''
182
- def set_up_analyst_constraints(data_characteristic, variable_decisions_alt = None):
199
+ def null_handler(vari):
200
+ if vari in locals():
201
+ return vari
202
+ else:
203
+ print(f'{vari} does not exist, setting None..')
204
+ return None
205
+
206
+
207
+ def set_up_analyst_constraints(data_characteristic, model_terms, variable_decisions_alt = None):
208
+
209
+
183
210
  name_data_characteristics = data_characteristic.columns.tolist()
184
- distu = ['n', 'u', 't']
185
- tra = ['no']
211
+ # Get non-None values as a list
212
+ non_none_terms = [value for value in model_terms.values() if value is not None]
213
+ # how to make name_data_characteristics - non_none_terms
214
+
215
+ result = [item for item in name_data_characteristics if item not in non_none_terms]
216
+ distu = ['Normal', 'Uniform', 'Triangular']
217
+ tra = ['no', 'sqrt', 'arcsinh']
218
+ if model_terms.get('grouped') is None:
219
+ print('cant have grouped rpm, removing level 4 from every item')
220
+ MAKE_ALL_4_FALSE = True
221
+ else:
222
+ MAKE_ALL_4_FALSE = False
223
+
186
224
  variable_decisions = {
187
225
  name: {
188
226
  'levels': list(range(6)),
189
227
  'distributions': distu,
190
228
  'transformations': tra
191
229
  }
192
- for name in name_data_characteristics
230
+ for name in result
193
231
  }
194
232
  # Override elements in the original dictionary with the alt dictionary
195
233
  if variable_decisions_alt is not None:
@@ -208,7 +246,11 @@ def set_up_analyst_constraints(data_characteristic, variable_decisions_alt = Non
208
246
 
209
247
  # Add levels as True/False for Level 0 through Level 5
210
248
  for level in range(6): # Assuming Level 0 to Level 5
211
- row[f'Level {level}'] = level in details['levels']
249
+
250
+ if level == 4 and MAKE_ALL_4_FALSE:
251
+ row[f'Level {level}'] = False
252
+ else:
253
+ row[f'Level {level}'] = level in details['levels']
212
254
 
213
255
  # Add distributions and transformations directly
214
256
  row['distributions'] = details['distributions']
@@ -218,7 +260,9 @@ def set_up_analyst_constraints(data_characteristic, variable_decisions_alt = Non
218
260
 
219
261
  # Create the DataFrame
220
262
  df = pd.DataFrame(rows)
221
- return df
263
+
264
+ data_new = data_characteristic.rename(columns={v: k for k, v in model_terms.items() if v in data_characteristic.columns})
265
+ return df, data_new
222
266
 
223
267
  # Function to guess Low, Medium, High ranges
224
268
  def guess_low_medium_high(column_name, series):
@@ -787,7 +787,7 @@ class SimulatedAnnealing(object):
787
787
  self.accept = 0
788
788
  self.profiler = []
789
789
  self.update_t = self.cooling_linear_m
790
- self.get_direcotory()
790
+ self.get_directory()
791
791
  self._crossover_perc = float(kwargs.get('_crossover_perc', 0.2)) or float(kwargs.get('_cr', 0.2))
792
792
  self._obj_fun = objective_function
793
793
  if objective_function.is_multi: # TODO Define more specific objectives in the intialiser
@@ -801,7 +801,7 @@ class SimulatedAnnealing(object):
801
801
  self.pf = Pareto(self.obj_1, self.obj_2, False)
802
802
  self._sa_memory = list()
803
803
 
804
- def get_direcotory(self):
804
+ def get_directory(self):
805
805
  # checking if the directory demo_folder2
806
806
  # exist or not.
807
807
  if not os.path.isdir(self.instance_number):
@@ -1237,6 +1237,16 @@ class HarmonySearch(object):
1237
1237
  Initialize HS with the specified objective function. Note that this objective function must implement ObjectiveFunctionInterface.
1238
1238
  """
1239
1239
  self._obj_fun = objective_function
1240
+ ## NEW CODE, TRYING TO EXCTACT OUT THE PARAMATERS
1241
+ self._hms = kwargs.get('_hms', 20)
1242
+ self._par = kwargs.get(_'par', .30)
1243
+ self.F = kwargs.get('_AI', 2) # mutation scale
1244
+ self.iter = kwargs.get('_max_iter', 10000)
1245
+ self.cr = kwargs.get('_crossover_perc') or kwargs.get('_cr', 0.2)
1246
+ self.instance_number = str(kwargs.get('instance_number', 1))
1247
+
1248
+
1249
+
1240
1250
  # for printing basics metrics
1241
1251
  self.print_verbose = True
1242
1252
  # harmony_memory stores the best hms harmonies
@@ -1245,7 +1255,7 @@ class HarmonySearch(object):
1245
1255
  self._harmony_history = list()
1246
1256
  # saves the best fitness
1247
1257
  self.instance_number = str(objective_function.instance_number)
1248
- self.get_direcotory()
1258
+ self.get_directory()
1249
1259
  self._harmony_trace_best = list()
1250
1260
  self._harmony_trace_incumbent = list()
1251
1261
  if self._obj_fun.is_multi: # TODO Define more specific objectives in the intialiser
@@ -1261,7 +1271,7 @@ class HarmonySearch(object):
1261
1271
 
1262
1272
  self.pf = Pareto(self.obj_1, self.obj_2, False)
1263
1273
 
1264
- def get_direcotory(self):
1274
+ def get_directory(self):
1265
1275
  # checking if the directory demo_folder2
1266
1276
  # exist or not.
1267
1277
  if not os.path.isdir(self.instance_number):
@@ -153,14 +153,14 @@ class ObjectiveFunction(object):
153
153
 
154
154
  self.MAE = None
155
155
  self.best_obj_1 = 1000000.0
156
- self._obj_1 = 'bic'
157
- self._obj_2 = 'MSE'
156
+ self._obj_1 = kwargs.get('_obj_1', 'bic')
157
+ self._obj_2 = kwargs.get('_obj_2', 'MSE')
158
158
  self.numerical_hessian_calc = 0 # calculates hessian by statsmodels otherwise scipy
159
159
  self.full_model = None
160
160
  self.GP_parameter = 0
161
- self.is_multi = 0
161
+ self.is_multi = kwargs.get('is_multi', False)
162
162
  self.complexity_level = 6
163
- self._max_iterations_improvement = 100
163
+ self._max_iterations_improvement = 10000
164
164
  self.generated_sln = set()
165
165
  self.ave_mae = 0
166
166
  # defalt paramaters for hs #TODO unpack into harmony search class
@@ -168,7 +168,7 @@ class ObjectiveFunction(object):
168
168
  self._hms = 20
169
169
  self._max_time = 60 * 60 * 24
170
170
  self._hmcr = .5
171
- self._par = 0.3
171
+ self._par = 0.3 #dont think this gets useted
172
172
  self._mpai = 1
173
173
  self._max_imp = 100000
174
174
  self._WIC = 1000 # Number of Iterations without Multiobjective Improvement #tod chuck into solution
@@ -395,7 +395,7 @@ class ObjectiveFunction(object):
395
395
 
396
396
 
397
397
 
398
- self.Ndraws = 200 # todo: change back
398
+ self.Ndraws = kwargs.get('Ndraws', 200)
399
399
  self.draws1 = None
400
400
  self.initial_sig = 1 # pass the test of a single model
401
401
  self.pvalue_sig_value = .1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: metacountregressor
3
- Version: 0.1.136
3
+ Version: 0.1.138
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