phylokrr-dev 0.2.0__tar.gz → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phylokrr_dev
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Requires-Python: >=3.5
6
6
  Requires-Dist: numpy
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: phylokrr_dev
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Requires-Python: >=3.5
6
6
  Requires-Dist: numpy
@@ -11,7 +11,7 @@ with open('README.md') as readme_file:
11
11
  readme = readme_file.read()
12
12
 
13
13
  setup(name = "phylokrr_dev",
14
- version = '0.2.0',
14
+ version = '0.2.1',
15
15
  # long_description = readme,
16
16
  # long_description_content_type = 'text/markdown',
17
17
  packages = ['phylokrr_dev'],
@@ -79,7 +79,7 @@ def pick_init_index(P_index, P_r, seed):
79
79
  return init_idx
80
80
 
81
81
  def init_model(X_train, y_train, vcv_train, model,
82
- param_init, i):
82
+ param_init, verbose = False):
83
83
  """
84
84
  Initialize the model.
85
85
  This initialization of the model is used at the beginning of every
@@ -111,7 +111,8 @@ def init_model(X_train, y_train, vcv_train, model,
111
111
  time_start = time.time()
112
112
  model.fit(X_train, y_train, vcv_train)
113
113
  time_end = time.time()
114
- print(f"Initial model fit time: {time_end - time_start:.2f} seconds")
114
+ if verbose:
115
+ print(f"Initial model fit time: {time_end - time_start:.2f} seconds")
115
116
 
116
117
  # for the next iteration alpha is used
117
118
  model.warm_start = False
@@ -168,7 +169,8 @@ def k_fold_cv_weigthed(X, y, vcv, model, W,
168
169
 
169
170
  # O(n^3*folds*sample)
170
171
  for i, (train_idx, test_idx) in enumerate(myfolds):
171
- print("Fold: ", i)
172
+ if verbose:
173
+ print("Fold: ", i)
172
174
  # print(test_idx)
173
175
  X_train, X_test = X[train_idx, :], X[test_idx, :]
174
176
  y_train, y_test = y[train_idx], y[test_idx]
@@ -198,7 +200,7 @@ def k_fold_cv_weigthed(X, y, vcv, model, W,
198
200
  # specified hyperparameter. This initial alpha is
199
201
  # used for all the folds
200
202
  init_model(X_train, y_train, vcv_train,
201
- model, param_init, i)
203
+ model, param_init, verbose = verbose)
202
204
 
203
205
  # init_err1 = model.score(X_test, y_test, vcv_test_12)*len(y_test)
204
206
  # init_err2 = model.score(X_test, y_test, None)*len(y_test)
@@ -208,8 +210,9 @@ def k_fold_cv_weigthed(X, y, vcv, model, W,
208
210
 
209
211
  all_errors.append([init_idx, init_err])
210
212
 
213
+ pb = progressbar(P_r, prefix = "Evaluating hyperparameters: ", size=40) if verbose else P_r
211
214
  j = 0
212
- for p_j in progressbar(P_r, prefix = "Testing hyperparameters: ", size=60):
215
+ for p_j in pb:
213
216
 
214
217
  if j == init_idx:
215
218
  continue
@@ -15,7 +15,7 @@ def progressbar(it, prefix="", size=60, out=sys.stdout):
15
15
  remaining = ((time.time() - start) / j) * (count - j)
16
16
  mins, sec = divmod(remaining, 60) # limited to minutes
17
17
  time_str = f"{int(mins):02}:{sec:03.1f}"
18
- print(f"{prefix}[{u''*x}{('.'*(size-x))}] {j}/{count} Est wait {time_str}", end='\r', file=out, flush=True)
18
+ print(f"{prefix}[{u'*'*x}{('.'*(size-x))}] {j}/{count} Est wait {time_str}", end='\r', file=out, flush=True)
19
19
  show(0.1) # avoid div/0
20
20
  for i, item in enumerate(it):
21
21
  yield item
File without changes
File without changes