phyddle 0.2.2__tar.gz → 0.3.0__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,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.2.2
2
+ current_version = 0.3.0
3
3
 
4
4
  [bumpversion:file:pyproject.toml]
5
5
 
@@ -10,7 +10,7 @@ jobs:
10
10
  - uses: actions/setup-python@v3
11
11
  - name: Install dependencies
12
12
  run: |
13
- pip install sphinx sphinx_rtd_theme sphinxemoji sphinxcontrib-googleanalytics
13
+ pip install sphinx sphinx_rtd_theme sphinxemoji sphinxcontrib-googleanalytics sphinx_subfigure
14
14
  - name: Sphinx build
15
15
  run: |
16
16
  sphinx-build docs/source _build
@@ -10,7 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  strategy:
12
12
  matrix:
13
- python-version: ['3.11']
13
+ python-version: ['3.12']
14
14
  R: [ '4.2.2' ]
15
15
 
16
16
  steps:
@@ -33,6 +33,9 @@ workspace/bisse_timehet_pj/bisse_timehet_*_parsed.pj
33
33
  # Ignore extras in tests
34
34
  #tests/workspace/*
35
35
 
36
+ # Ignore documentation files
37
+ docs/source/images/*.pdf
38
+
36
39
  # Ignore phyddle accessory dirs
37
40
  sandbox/
38
41
  paper/
@@ -1,6 +1,6 @@
1
1
  # Released under MIT License
2
2
 
3
- Copyright (c) 2023 Michael Landis, Ammon Thompson
3
+ Copyright (c) 2025 Michael Landis, Ammon Thompson
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (phyddle; the “Software”), to deal in
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: phyddle
3
- Version: 0.2.2
4
- Summary: Software to fiddle around with deep learning for phylogenetic models
3
+ Version: 0.3.0
4
+ Summary: Software for phylogenetic model exploration with deep learning
5
5
  Project-URL: Homepage, https://github.com/mlandis/phyddle
6
6
  Project-URL: Bug Reports, https://github.com/mlandis/phyddle/issues
7
7
  Project-URL: Documentation, https://mlandis.github.io/phyddle
@@ -17,24 +17,23 @@ Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
18
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
19
19
  Classifier: Topic :: Scientific/Engineering :: Mathematics
20
- Requires-Python: >=3.7
21
- Requires-Dist: dendropy
22
- Requires-Dist: graphviz
23
- Requires-Dist: h5py
24
- Requires-Dist: keras
25
- Requires-Dist: matplotlib
26
- Requires-Dist: numpy
27
- Requires-Dist: pandas
28
- Requires-Dist: pydot
29
- Requires-Dist: pypdf
30
- Requires-Dist: scikit-learn
31
- Requires-Dist: scipy
32
- Requires-Dist: torch
33
- Requires-Dist: torchvision
34
- Requires-Dist: tqdm
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: dendropy>=4.6.0
22
+ Requires-Dist: graphviz>=0.20.0
23
+ Requires-Dist: h5py>=3.10.0
24
+ Requires-Dist: matplotlib>=3.8.2
25
+ Requires-Dist: numpy>=1.26.4
26
+ Requires-Dist: pandas>=2.2.0
27
+ Requires-Dist: pydot>=2.0.0
28
+ Requires-Dist: pypdf>=4.0.0
29
+ Requires-Dist: scikit-learn>=1.4.0
30
+ Requires-Dist: scipy>=1.14.0
31
+ Requires-Dist: torch>=2.2.0
32
+ Requires-Dist: torchview>=0.2.6
33
+ Requires-Dist: tqdm>=4.66.1
35
34
  Description-Content-Type: text/markdown
36
35
 
37
- # phyddle 0.2.2
36
+ # phyddle 0.3.0
38
37
 
39
38
  Phylogenetic model exploration with deep learning.
40
39
 
@@ -1,4 +1,4 @@
1
- # phyddle 0.2.2
1
+ # phyddle 0.3.0
2
2
 
3
3
  Phylogenetic model exploration with deep learning.
4
4
 
@@ -0,0 +1,179 @@
1
+ **phyddle v0.3.0** -- 25.02.xx
2
+
3
+ * Includes new safety features, settings, bug fixes, and documentation
4
+ * Estimate now warns user if empirical input/labels are out-of-distribution
5
+ * Estimate/Format no longer require labels file for empirical analyses unless param_data used
6
+ * Plot improved to make it easier to notice out-of-distribution empirical input/labels
7
+ * Plot now makes PCA of encoded trees to help with out-of-distribution detection
8
+ * Replace mean APE scores for training diagnostics with median APE scores
9
+ * Support to choose optimizer: adam, adamw, adagrad, adadelta, rmsprop, sgd
10
+ * Support to choose activation functions: relu, elu, leaky_relu, tanh, sigmoid
11
+ * Support to set learning rate
12
+ * Fix issue where Format reported divide-by-zero warning for summ. stat. with perfectly balanced trees
13
+ * Fix issue where large serial trees were not correctly converted to downsampled extant-only trees
14
+ * Add settings/warnings to prevent nearly-zero-aged tips in extant-only from being treated as extinct
15
+ * Add torchvision to dependency list
16
+ * Replace deprecated PdfMerger with PdfWriter
17
+ * Support to use 2+ GPUs
18
+ * Reorganize documentation
19
+ * Documentation now has Overview -> Safe Usage section
20
+ * Documentation tutorial now contains better explanations of figures
21
+
22
+
23
+ **phyddle v0.2.2** -- 24.07.19
24
+
25
+ * Reduce pypi package size from 100MB to 75kB.
26
+ * Fix bug that caused lower CPI bound to be slightly misestimated.
27
+ * Improve scatter/coverage and training history plots.
28
+
29
+
30
+ **phyddle v0.2.1** -- 24.07.11
31
+
32
+ * New support to save, load, and clean projects. Nice for collaborations! |:handshake:|
33
+ * Improve detection of replicate indexing in Simulate/Format.
34
+ * Better warnings/errors for invalid settings.
35
+ * Remove logit transformation from summary statistics for state frequencies (caused crash in some cases).
36
+
37
+
38
+ **phyddle v0.2.0** -- 24.03.28
39
+
40
+ * New support for categorical labels (e.g. model testing).
41
+ * New plots for categorical results.
42
+ * Add support for GPU + CUDA + PyTorch to accelerate Train and Estimate.
43
+ * Support for early stopping rule with Train.
44
+ * Improved printed feedback for all steps.
45
+ * Better plots for PCA and scatter plot results.
46
+ * Simpler default directory structure. Default phyddle configs, scripts, and outputs now share a proj directory in ./workspace.
47
+ * Better support for multiple project names within a workspace directory.
48
+ * Rewrote how Format/Estimate/Plot interact so simulated-test/empirical datasets are treated similarly.
49
+ * Better error checking and helpful messages for Simulate-Format config mismatches.
50
+
51
+
52
+ **phyddle v0.1.1** -- 24.02.18
53
+
54
+ * Simpler directory settings for analyses
55
+ * Simpler settings application hierarchy
56
+ * Removed workspace and proj arguments
57
+ * Removed requirement for __config_default.py
58
+ * Repo directory restructuring, with clearer distinction between scripts and configs
59
+ * Added example simulation script for PhyloJunction
60
+
61
+
62
+ **phyddle v0.1.0** -- 24.02.08
63
+
64
+ * Update minor version from v0.0.10 to v0.1.0 |:partying_face:|
65
+ * Convert from Tensorflow to PyTorch on backend
66
+ * New support for scalable network architecture in Train
67
+ * New support for output precision for floating point output to files
68
+ * New summary csv report for Plot
69
+ * Better screen output for Train progress
70
+ * Better training history plot
71
+ * Better network architecture plot
72
+ * Better handling of cases where small tree size causes tree statistics to return 0/undefined/etc.
73
+ * Fix bug with non-sequential indices among simulated training examples
74
+ * Fix bug with Format for-loop to process summary statistics
75
+ * Switch summary statistics to log-scale
76
+
77
+
78
+ **phyddle v0.0.10** -- 23.11.10
79
+
80
+ * Basic GitHub Action tests working
81
+ * Format step faster (removed extraneous and costly deepcopy calls)
82
+ * Convert config_R.py to BiSSE example using R + castor
83
+ * Add external validation for phyddle vs. castor
84
+ * Improve config support
85
+ * Cleaning and commenting code
86
+ * Clean and finish sphinx documentation
87
+
88
+
89
+ **phyddle v0.0.9** -- 23.08.23
90
+
91
+ * Package now hosted through conda: https://anaconda.org/landismj/phyddle
92
+ * Better errors for missing files (configs, command, scripts, etc.)
93
+ * PyPI package installed through pip now autoinstalls dependencies
94
+
95
+
96
+ **phyddle v0.0.8** -- 23.08.16
97
+
98
+ * Minor fixes following 0.0.7 update
99
+ * Documentation visuals fixed
100
+
101
+
102
+ **phyddle v0.0.7** -- 23.08.16
103
+
104
+ * Format now splits training from test datasets.
105
+ * Estimate now applies trained model against test dataset.
106
+ * Steps now initialize using settings look-up table.
107
+ * Add PCA contour plot.
108
+ * Simplify filenames within projects for many steps.
109
+ * Timestamp step start/end/duration.
110
+ * Docs now hosted online at http://mlandis.github.io/phyddle
111
+ * Python package now hosted through pip at https://pypi.org/project/phyddle/
112
+ * Add bump2version supports
113
+
114
+
115
+ **phyddle v0.0.6** -- 23.08.09
116
+
117
+ * Refreshed documentation, plus added setting tables and glossary.
118
+ * Centralize management of settings.
119
+ * Settings now automatically apply default config, then user config, then command line arguments.
120
+ * Format only enodes for a single tree width category now.
121
+ * Format now downsamples and stores raw num. taxa for each data point.
122
+ * Allow for "all-but-X" CPUs for multiprocessing.
123
+ * Simulate wth --sim_more option to add new replicates to training examples.
124
+ * Format encodes all detected datasets by default.
125
+ * Support to allow scripts to simulate batches (>1) of replicates.
126
+ * Major overhaul of help docs, but not done.
127
+
128
+
129
+ **phyddle v0.0.5** -- 23.07.30
130
+
131
+ * Pipeline steps renamed to: Simulate, Format, Train, Estimate, Plot
132
+ * Simulators now in scripts/sim/MASTER, scripts/sim/R, scripts/sim/Rev
133
+ * Streamlined handling of phyddle settings, internally
134
+ * Model configuration code moved outside phyddle
135
+ * MASTER simulator now outside phyddle, in scripts/sim/MASTER
136
+ * Complete source code reorg/rename
137
+ * Pipeline script now prints pipeline steps
138
+ * Support for granular management of flow of projects across pipeline steps
139
+ * Support asymmetric CPI calibration
140
+ * Better handling of FileNotFoundError related to Estimate step
141
+ * Much faster Formatting step (>100x speedup)
142
+ * Pipeline steps now generate logs in ``workspace/log/<project_name>`` to track phyddle is used during a project analysis
143
+ * Tested against Apple M1. Not an easy install, because unsupported by Tensorflow. Thanks Albert and Sean!
144
+
145
+
146
+ **phyddle v0.0.4** -- 23.07.09
147
+
148
+ * Simulating now supports command-line scripts
149
+ * Better backend support for alternative phylostate tensor encodings
150
+ * Simplified pipeline scripts and interface
151
+ * Docs improved to reflect current code design
152
+ * Tests now cover Simulating and Formatting
153
+
154
+
155
+ **phyddle v0.0.3** -- 23.07.02
156
+
157
+ * Sphinx configuration for documentation
158
+ * TestPyPI configuration for package deployment
159
+ * GitHub Actions configuration for unit testing
160
+
161
+
162
+ **phyddle v0.0.2** -- 23.06.25
163
+
164
+ * (first internal working version)
165
+ * trained network generates parameter estimates and coverage-calibrated prediction intervals (CPIs) for input datasets
166
+ * provides several state-dependent birth-death model types and variants (more to come)
167
+ * parallelized simulating, formatting, and learning
168
+ * encoding of phylogenetic-state tensor from serial and extant-only input with multiple states (CBLV+S and CDV+S extensions)
169
+ * encoding of auxiliary data tensor from automatically computed summary statistics and "known" parameter (e.g. sampling rate)
170
+ * HDF5 with gzip compression for tensor data
171
+ * shuffles and splits input tensors into training, test, validation, and calibration datasets for supervised learning
172
+ * builds network with convolution, pooling, and dense layers that match input tensors
173
+ * trains network and saves history
174
+ * automatic figure generation with Matplotlib
175
+
176
+
177
+ **phyddle v0.0.1** -- 23.03.16
178
+
179
+ * (initial development version)
@@ -4,31 +4,30 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "phyddle"
7
- version = "0.2.2"
7
+ version = "0.3.0"
8
8
  authors = [
9
9
  { name="Michael Landis", email="michael.landis@wustl.edu" },
10
10
  { name="Ammon Thompson", email="ammonthompson@gmail.com" },
11
11
  ]
12
- description = "Software to fiddle around with deep learning for phylogenetic models"
12
+ description = "Software for phylogenetic model exploration with deep learning"
13
13
  readme = "README.md"
14
14
 
15
- requires-python = ">=3.7"
15
+ requires-python = ">=3.12"
16
16
 
17
17
  dependencies = [
18
- "dendropy",
19
- "graphviz",
20
- "h5py",
21
- "keras",
22
- "matplotlib",
23
- "numpy",
24
- "pandas",
25
- "pydot",
26
- "pypdf",
27
- "scikit-learn",
28
- "scipy",
29
- "torch",
30
- "torchvision",
31
- "tqdm"
18
+ "dendropy>=4.6.0",
19
+ "graphviz>=0.20.0",
20
+ "h5py>=3.10.0",
21
+ "matplotlib>=3.8.2",
22
+ "numpy>=1.26.4",
23
+ "pandas>=2.2.0",
24
+ "pydot>=2.0.0",
25
+ "pypdf>=4.0.0",
26
+ "scikit-learn>=1.4.0",
27
+ "scipy>=1.14.0",
28
+ "torch>=2.2.0",
29
+ "torchview>=0.2.6",
30
+ "tqdm>=4.66.1"
32
31
  ]
33
32
 
34
33
  classifiers = [
@@ -5,7 +5,7 @@ __init__
5
5
  Initializes phyddle package and discovers all modules.
6
6
 
7
7
  Authors: Michael Landis, Ammon Thompson
8
- Copyright: (c) 2022-2023, Michael Landis and Ammon Thompson
8
+ Copyright: (c) 2022-2025, Michael Landis and Ammon Thompson
9
9
  License: MIT
10
10
  """
11
11
 
@@ -14,10 +14,10 @@ License: MIT
14
14
  from multiprocessing import set_start_method
15
15
 
16
16
  __project__ = 'phyddle'
17
- __version__ = '0.2.2'
17
+ __version__ = '0.3.0'
18
18
  __author__ = 'Michael Landis and Ammon Thompson'
19
- __copyright__ = '(c) 2022-2023, Michael Landis and Ammon Thompson'
20
- __citation__ = 'A Thompson, B Liebeskind, EJ Scully, MJ Landis. 2023. Deep learning approaches to viral phylogeography are fast and as robust as likelihood methods to model misspecification. bioRxiv 2023.02.08.527714.'
19
+ __copyright__ = '(c) 2022-2025, Michael Landis and Ammon Thompson'
20
+ __citation__ = 'MJ Landis, A Thompson. 2024. phyddle: software for phylogenetic model exploration with deep learning. bioRxiv 2024.08.06.606717.'
21
21
 
22
22
  # DEFAULT
23
23
  CONFIG_DEFAULT_FN = 'config_default.py'
@@ -39,9 +39,9 @@ def run():
39
39
  if 'E' in step:
40
40
  import phyddle.format as fmt
41
41
  import phyddle.estimate as est
42
- est_prefix = f"{my_args['est_dir']}/{my_args['est_prefix']}"
43
- my_fmt = fmt.load(my_args)
44
- my_fmt.encode_one(tmp_fn=est_prefix, idx=-1, save_phyenc_csv=True)
42
+ # est_prefix = f"{my_args['est_dir']}/{my_args['est_prefix']}"
43
+ # my_fmt = fmt.load(my_args)
44
+ # my_fmt.encode_one(tmp_fn=est_prefix, idx=-1, mode='emp', save_phyenc_csv=True)
45
45
  my_est = est.load(my_args)
46
46
  my_est.run()
47
47
 
@@ -7,7 +7,7 @@ network and uses it to generate new estimates, e.g. estimate model parameters
7
7
  for a new empirical dataset.
8
8
 
9
9
  Authors: Michael Landis and Ammon Thompson
10
- Copyright: (c) 2022-2023, Michael Landis and Ammon Thompson
10
+ Copyright: (c) 2022-2025, Michael Landis and Ammon Thompson
11
11
  License: MIT
12
12
  """
13
13
 
@@ -16,6 +16,7 @@ import os
16
16
 
17
17
  # external imports
18
18
  import numpy as np
19
+ import scipy as sp
19
20
  import pandas as pd
20
21
  import h5py
21
22
  import torch
@@ -88,6 +89,12 @@ class Estimator:
88
89
  self.log_offset = float(args['log_offset'])
89
90
  self.use_cuda = bool(args['use_cuda'])
90
91
 
92
+ # error checking
93
+ self.warn_aux_outlier = float(args['warn_aux_outlier'])
94
+ self.warn_lbl_outlier = float(args['warn_lbl_outlier'])
95
+ self.est_aux_data_raw = None
96
+ self.est_labels_num_raw = None
97
+
91
98
  # get size of CPV+S tensors
92
99
  self.num_tree_col = util.get_num_tree_col(self.tree_encode,
93
100
  self.brlen_encode)
@@ -122,8 +129,10 @@ class Estimator:
122
129
  self.phy_data = None # init in load_format_input()
123
130
  self.aux_data = None # init in load_format_input()
124
131
  self.idx_data = None # init in load_format_input()
125
- self.true_labels_num = None # init in load_format_input()
132
+ self.aux_data_names = None # init in load_format_input()
133
+ self.true_labels_num = None # init in load_format_input()
126
134
  self.true_labels_cat = None # init in load_format_input()
135
+ self.est_labels_num = None # init in make_results()
127
136
  self.mymodel = None # init in make_results()
128
137
 
129
138
  # done
@@ -208,6 +217,9 @@ class Estimator:
208
217
  # make estimates
209
218
  util.print_str('▪ Making empirical estimates', verbose)
210
219
  self.make_results(mode='emp')
220
+
221
+ # check inputs/outputs
222
+ self.check_empirical_results()
211
223
 
212
224
  # done
213
225
  found_emp = True
@@ -348,6 +360,7 @@ class Estimator:
348
360
  label_names = labels[0,:]
349
361
  labels = labels[1:,:].astype('float64')
350
362
  aux_data = aux_data[1:,:].astype('float64')
363
+ aux_data_names = aux_data[0,:]
351
364
 
352
365
  elif self.tensor_format == 'hdf5':
353
366
  hdf5_file = h5py.File(hdf5_fn, 'r')
@@ -358,6 +371,7 @@ class Estimator:
358
371
  if mode == 'sim':
359
372
  labels = pd.DataFrame(hdf5_file['labels']).to_numpy()
360
373
  label_names = [ s.decode() for s in hdf5_file['label_names'][0,:] ]
374
+ aux_data_names = [ s.decode() for s in hdf5_file['aux_data_names'][0,:] ]
361
375
  hdf5_file.close()
362
376
 
363
377
  # get number of samples
@@ -371,7 +385,8 @@ class Estimator:
371
385
  # test dataset normalization
372
386
  assert aux_data.shape[0] == num_sample
373
387
  self.aux_data = util.normalize(aux_data, self.train_aux_data_mean_sd)
374
-
388
+ self.aux_data_names = aux_data_names
389
+
375
390
  # dataset index
376
391
  self.idx_data = idx_data
377
392
 
@@ -394,7 +409,10 @@ class Estimator:
394
409
  for idx in range(self.true_labels_cat.shape[1]):
395
410
  unique_cats, encoded_cats = np.unique(self.true_labels_cat[:,idx],
396
411
  return_inverse=True)
397
- self.true_labels_cat[:,idx] = encoded_cats
412
+ self.true_labels_cat[:,idx] = encoded_cats
413
+ # num_outliers = np.sum(np.abs(self.aux_data[:, i]) > bound)
414
+ # if num_outliers > num_expected:
415
+ # util.print_warn(f'Outlier detected in column {i} of aux_data')
398
416
 
399
417
  # done
400
418
  return
@@ -425,7 +443,7 @@ class Estimator:
425
443
  out_true_labels_cat_fn = f'{path_prefix}_true.labels_cat.csv'
426
444
 
427
445
  # load model
428
- self.mymodel = torch.load(model_arch_fn, map_location=self.TORCH_DEVICE)
446
+ self.mymodel = torch.load(model_arch_fn, map_location=self.TORCH_DEVICE, weights_only=False)
429
447
  self.mymodel.to(self.TORCH_DEVICE)
430
448
 
431
449
  # get estimates
@@ -480,6 +498,15 @@ class Estimator:
480
498
  df_true_labels_cat = pd.concat( [self.idx_data, df_true_labels_cat], axis=1)
481
499
  df_true_labels_cat.to_csv(out_true_labels_cat_fn, index=False, sep=',')
482
500
 
501
+ if mode == 'emp':
502
+ # self.est_labels_num_raw = denorm_est_labels_num
503
+ self.est_aux_data_raw = util.denormalize(self.aux_data,
504
+ self.train_aux_data_mean_sd,
505
+ exp=False)
506
+ self.est_labels_num_raw = util.denormalize(labels_est_num,
507
+ self.train_labels_num_mean_sd,
508
+ exp=False)[0,:,:]
509
+
483
510
  # done
484
511
  return
485
512
 
@@ -499,4 +526,48 @@ class Estimator:
499
526
 
500
527
  return pd.concat(df_list, axis=1)
501
528
 
529
+
530
+ def check_empirical_results(self):
531
+
532
+ # check for outliers in aux_data
533
+ aux_data = util.normalize(self.est_aux_data_raw, self.train_aux_data_mean_sd)
534
+ aux_std_bound = np.round(sp.stats.norm.ppf(1.0 - self.warn_aux_outlier/2, loc=0, scale=1), 2)
535
+ for i in range(aux_data.shape[1]):
536
+ outlier_fail = np.abs(aux_data[:, i]) > aux_std_bound
537
+ mu = self.train_aux_data_mean_sd[0][i]
538
+ sd = self.train_aux_data_mean_sd[1][i]
539
+ raw_lower = "{:.2e}".format(mu - aux_std_bound * sd)
540
+ raw_upper = "{:.2e}".format(mu + aux_std_bound * sd)
541
+ percent = 100*(1.0 - self.warn_aux_outlier)
542
+ outlier_idx = np.where(outlier_fail)[0]
543
+ outliers = self.est_aux_data_raw[outlier_fail, i]
544
+ if outliers.shape[0] > 0:
545
+ util.print_warn(f'Outlier(s) detected in empirical aux. data: {self.aux_data_names[i]}')
546
+ # util.print_str(f' Values outside {(1.0 - self.warn_aux_outlier)*100}% interval of [{raw_lower}, {raw_upper}]')
547
+ util.print_str(f' - Values outside ± {aux_std_bound}sd ({percent}%) interval of [{raw_lower}, {raw_upper}]')
548
+ util.print_str(f' - Detected outlier(s):')
549
+ for j in range(outliers.shape[0]):
550
+ util.print_str(f' index {outlier_idx[j]} : value {outliers[j]}')
551
+
552
+ # check for outliers in labels
553
+ if self.has_label_num:
554
+ est_labels_num = util.normalize(self.est_labels_num_raw, self.train_labels_num_mean_sd)
555
+ lbl_std_bound = np.round(sp.stats.norm.ppf(1.0 - self.warn_lbl_outlier/2, loc=0, scale=1), 2)
556
+ for i in range(est_labels_num.shape[1]):
557
+ outlier_fail = np.abs(est_labels_num[:, i]) > lbl_std_bound
558
+ mu = self.train_labels_num_mean_sd[0][i]
559
+ sd = self.train_labels_num_mean_sd[1][i]
560
+ raw_lower = "{:.2e}".format(mu - lbl_std_bound * sd)
561
+ raw_upper = "{:.2e}".format(mu + lbl_std_bound * sd)
562
+ percent = 100*(1.0 - self.warn_lbl_outlier)
563
+ outlier_idx = np.where(outlier_fail)[0]
564
+ outliers = self.est_labels_num_raw[outlier_fail, i]
565
+ if outliers.shape[0] > 0:
566
+ util.print_warn(f'Outlier(s) detected in empirical labels: {self.label_num_names[i]}')
567
+ # util.print_str(f' Values outside {(1.0 - self.warn_lbl_outlier*100)}% interval of [{raw_lower}, {raw_upper}]')
568
+ util.print_str(f' - Values outside ± {lbl_std_bound}sd ({percent}%) interval of [{raw_lower}, {raw_upper}]')
569
+ util.print_str(f' - Detected outlier(s):')
570
+ for j in range(outliers.shape[0]):
571
+ util.print_str(f' index {outlier_idx[j]} : value {outliers[j]}')
572
+
502
573
  ##################################################