metacountregressor 0.1.137__tar.gz → 0.1.139__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/PKG-INFO +1 -1
  2. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/helperprocess.py +15 -2
  3. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/metaheuristics.py +14 -4
  4. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/solution.py +18 -8
  5. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor.egg-info/PKG-INFO +1 -1
  6. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/LICENSE.txt +0 -0
  7. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/README.rst +0 -0
  8. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/__init__.py +0 -0
  9. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/_device_cust.py +0 -0
  10. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/app_main.py +0 -0
  11. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/data_split_helper.py +0 -0
  12. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/halton.py +0 -0
  13. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/main.py +0 -0
  14. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/main_old.py +0 -0
  15. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/pareto_file.py +0 -0
  16. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/pareto_logger__plot.py +0 -0
  17. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/setup.py +0 -0
  18. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/single_objective_finder.py +0 -0
  19. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor/test_generated_paper2.py +0 -0
  20. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor.egg-info/SOURCES.txt +0 -0
  21. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor.egg-info/dependency_links.txt +0 -0
  22. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor.egg-info/not-zip-safe +0 -0
  23. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor.egg-info/requires.txt +0 -0
  24. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/metacountregressor.egg-info/top_level.txt +0 -0
  25. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/setup.cfg +0 -0
  26. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/setup.py +0 -0
  27. {metacountregressor-0.1.137 → metacountregressor-0.1.139}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: metacountregressor
3
- Version: 0.1.137
3
+ Version: 0.1.139
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,15 +1,28 @@
1
1
  from os.path import exists
2
-
3
2
  import numpy as np
4
3
  import pandas as pd
5
4
  import csv
6
5
  import matplotlib.pyplot as plt
7
6
  from scipy import stats as st
8
7
  from sklearn.preprocessing import StandardScaler
9
- from win32comext.shell.demos.IActiveDesktop import existing_item
8
+
10
9
 
11
10
  plt.style.use('https://github.com/dhaitz/matplotlib-stylesheets/raw/master/pitayasmoothie-dark.mplstyle')
12
11
 
12
+
13
+
14
+
15
+
16
+ from itertools import product
17
+
18
+ # Function to create a list of dictionaries from a parameter grid
19
+ def generate_param_combinations(param_grid):
20
+ keys = param_grid.keys()
21
+ values = param_grid.values()
22
+ combinations = [dict(zip(keys, v)) for v in product(*values)]
23
+ return combinations
24
+
25
+
13
26
  ##Select the best Features Based on RF
14
27
  def select_features(X_train, y_train, n_f=16):
15
28
  try:
@@ -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):
@@ -32,7 +32,7 @@ from sklearn.metrics import mean_squared_error as MSPE
32
32
  from statsmodels.tools.numdiff import approx_fprime, approx_hess
33
33
  from sklearn.preprocessing import StandardScaler, MinMaxScaler
34
34
  from texttable import Texttable
35
-
35
+ import time
36
36
  try:
37
37
  from ._device_cust import device as dev
38
38
  from .pareto_file import Pareto, Solution
@@ -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
@@ -204,12 +204,17 @@ class ObjectiveFunction(object):
204
204
  if 'instance_number' in kwargs:
205
205
  self.instance_number = str(kwargs['instance_number'])
206
206
  else:
207
+
208
+ print('no name set, setting name as 0')
207
209
  self.instance_number = str(0) # set an arbitrary instance number
208
210
 
209
211
  if not os.path.exists(self.instance_number):
210
- os.makedirs(self.instance_number)
212
+ if kwargs.get('make_directory', True):
213
+ print('Making a Directory, if you want to stop from storing the files to this directory set argumet: make_directory:False')
214
+ os.makedirs(self.instance_number)
211
215
 
212
216
  if not hasattr(self, '_obj_1'):
217
+ print('_obj_1 required, define as bic, aic, ll')
213
218
  raise Exception
214
219
 
215
220
  self.pvalue_penalty = float(kwargs.get('pvalue_penalty', 0.5))
@@ -238,6 +243,9 @@ class ObjectiveFunction(object):
238
243
  self.test_percentage = float(kwargs.get('test_percentage', 0))
239
244
  self.val_percentage = float(kwargs.get('val_percentage', 0))
240
245
  if self.test_percentage == 0:
246
+ print('test percentage is 0, please enter arg test_percentage as decimal, eg 0.8')
247
+ print('continuing single objective')
248
+ time.sleep(2)
241
249
  self.is_multi = False
242
250
 
243
251
  if 'panels' in kwargs and not (kwargs.get('panels') == None):
@@ -348,6 +356,7 @@ class ObjectiveFunction(object):
348
356
 
349
357
 
350
358
  else:
359
+ print('No Panels. Grouped Random Paramaters Will not be estimated')
351
360
  self.G = None
352
361
  self._Gnum = 1
353
362
  self._max_group_all_means = 0
@@ -395,7 +404,7 @@ class ObjectiveFunction(object):
395
404
 
396
405
 
397
406
 
398
- self.Ndraws = 200 # todo: change back
407
+ self.Ndraws = kwargs.get('Ndraws', 200)
399
408
  self.draws1 = None
400
409
  self.initial_sig = 1 # pass the test of a single model
401
410
  self.pvalue_sig_value = .1
@@ -413,6 +422,7 @@ class ObjectiveFunction(object):
413
422
  print('Setup Complete...')
414
423
  else:
415
424
  print('No Panels Supplied')
425
+ print('Setup Complete...')
416
426
  self._characteristics_names = list(self._x_data.columns)
417
427
  # define the variables
418
428
  # self._transformations = ["no", "sqrt", "log", "exp", "fact", "arcsinh", 2, 3]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: metacountregressor
3
- Version: 0.1.137
3
+ Version: 0.1.139
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