metacountregressor 0.1.139__py3-none-any.whl → 0.1.141__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.139
3
+ Version: 0.1.141
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
@@ -3,18 +3,18 @@ metacountregressor/_device_cust.py,sha256=759fnKmTYccJm4Lpi9_1reurh6OB9d6q9soPR0
3
3
  metacountregressor/app_main.py,sha256=vY3GczTbGbBRalbzMkl_9jVW7RMgEOc6z2Dr1IZJv9c,10014
4
4
  metacountregressor/data_split_helper.py,sha256=M2fIMdIO8znUaYhx5wlacRyNWdQjNYu1z1wkE-kFUYU,3373
5
5
  metacountregressor/halton.py,sha256=jhovA45UBoZYU9g-hl6Lb2sBIx_ZBTNdPrpgkzR9fng,9463
6
- metacountregressor/helperprocess.py,sha256=WiCItpiGJQJNxwczsNzWobDeltfmSKzSJKlxz8_9pxk,20504
6
+ metacountregressor/helperprocess.py,sha256=05698FXkXiAZi2JvVxCtaBwSf9LbW1lY8q_eFmEF5Nc,20739
7
7
  metacountregressor/main.py,sha256=2Rx_mGIGzl4lhwkMb7DHvsBaawqEakKiVR1Yr2uG9Yo,22819
8
8
  metacountregressor/main_old.py,sha256=eTS4ygq27MnU-dZ_j983Ucb-D5XfbVF8OJQK2hVVLZc,24123
9
- metacountregressor/metaheuristics.py,sha256=Kkx1Jfox6NBlm5zVrI26Vc_NI7NFQSS9dinrZU9SpV8,105871
9
+ metacountregressor/metaheuristics.py,sha256=f3Jgg6NkPalcAeY2Nz8AePSDHQkVASxfceOLs_OMCug,106265
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=6qAtCSKNvmrCpIpBCzp2Zt8wWKZBHRQtTriyiMHUo54,277519
14
+ metacountregressor/solution.py,sha256=j8pWlmMmEkjBC798Fnh1fu0w7F6jrVtW43H2OSXv8Ts,278258
15
15
  metacountregressor/test_generated_paper2.py,sha256=pwOoRzl1jJIIOUAAvbkT6HmmTQ81mwpsshn9SLdKOg8,3927
16
- metacountregressor-0.1.139.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
- metacountregressor-0.1.139.dist-info/METADATA,sha256=_jvPMVa-G1tSUPlH9VjpCAPT1nl6TCFWSsq6SMDwTw8,23434
18
- metacountregressor-0.1.139.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
19
- metacountregressor-0.1.139.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
20
- metacountregressor-0.1.139.dist-info/RECORD,,
16
+ metacountregressor-0.1.141.dist-info/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
17
+ metacountregressor-0.1.141.dist-info/METADATA,sha256=0P_boUzZxFlgmSBgeEXHip5O0Yg-H6JMWurOQi7H9UQ,23434
18
+ metacountregressor-0.1.141.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
19
+ metacountregressor-0.1.141.dist-info/top_level.txt,sha256=zGG7UC5WIpr76gsFUpwJ4En2aCcoNTONBaS3OewwjR0,19
20
+ metacountregressor-0.1.141.dist-info/RECORD,,