bdext 0.1.68__tar.gz → 0.1.70__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.1
2
2
  Name: bdext
3
- Version: 0.1.68
3
+ Version: 0.1.70
4
4
  Summary: Estimation of BDEISS-CT parameters from phylogenetic trees.
5
5
  Home-page: https://github.com/modpath/bdeissct
6
6
  Author: Anna Zhukova
@@ -4,17 +4,9 @@ from tensorflow.python.keras.utils.generic_utils import register_keras_serializa
4
4
  from bdeissct_dl.bdeissct_model import F_S, UPSILON, REPRODUCTIVE_NUMBER, \
5
5
  INFECTION_DURATION, X_S, X_C, RHO, INCUBATION_PERIOD
6
6
 
7
- LEARNING_RATE = 0.001
7
+ from collections import defaultdict
8
8
 
9
- LOSS_WEIGHTS = {
10
- REPRODUCTIVE_NUMBER: 1,
11
- INFECTION_DURATION: 1,
12
- INCUBATION_PERIOD: 1,
13
- F_S: 200, # as it is a value between 0 and 0.5, we multiply by 200 to scale it to [0, 100]
14
- UPSILON: 100,
15
- X_C: 1,
16
- X_S: 1
17
- }
9
+ LEARNING_RATE = 0.001
18
10
 
19
11
  @register_keras_serializable(package="bdeissct_dl", name="half_sigmoid")
20
12
  def half_sigmoid(x):
@@ -26,16 +18,17 @@ def relu_plus_one(x):
26
18
 
27
19
 
28
20
 
29
- LOSS_FUNCTIONS = {
30
- REPRODUCTIVE_NUMBER: "mean_absolute_percentage_error",
31
- INFECTION_DURATION: "mean_absolute_percentage_error",
32
- INCUBATION_PERIOD: "mae",
33
- UPSILON: 'mae',
34
- RHO: 'mean_absolute_percentage_error',
35
- X_C: "mean_absolute_percentage_error",
36
- F_S: 'mae',
37
- X_S: "mean_absolute_percentage_error",
38
- }
21
+ LOSS_FUNCTIONS = defaultdict(lambda: "mean_squared_error")
22
+ LOSS_FUNCTIONS.update({
23
+ REPRODUCTIVE_NUMBER: "mean_squared_error",
24
+ INFECTION_DURATION: "mean_squared_error",
25
+ INCUBATION_PERIOD: "mean_squared_error",
26
+ UPSILON: 'mean_squared_error',
27
+ RHO: 'mean_squared_error',
28
+ X_C: "mean_squared_error",
29
+ F_S: 'mean_squared_error',
30
+ X_S: "mean_squared_error",
31
+ })
39
32
 
40
33
 
41
34
  def build_model(target_columns, n_x, optimizer=None, metrics=None):
@@ -63,11 +56,11 @@ def build_model(target_columns, n_x, optimizer=None, metrics=None):
63
56
  outputs = {}
64
57
 
65
58
  if REPRODUCTIVE_NUMBER in target_columns:
66
- outputs[REPRODUCTIVE_NUMBER] = tf.keras.layers.Dense(1, activation="softplus", name=REPRODUCTIVE_NUMBER)(x) # positive values only
59
+ outputs[REPRODUCTIVE_NUMBER] = tf.keras.layers.Dense(1, activation="relu", name=REPRODUCTIVE_NUMBER)(x) # positive values only
67
60
  if INFECTION_DURATION in target_columns:
68
- outputs[INFECTION_DURATION] = tf.keras.layers.Dense(1, activation="softplus", name=INFECTION_DURATION)(x) # positive values only
61
+ outputs[INFECTION_DURATION] = tf.keras.layers.Dense(1, activation="relu", name=INFECTION_DURATION)(x) # positive values only
69
62
  if INCUBATION_PERIOD in target_columns:
70
- outputs[INCUBATION_PERIOD] = tf.keras.layers.Dense(1, activation="softplus", name=INCUBATION_PERIOD)(x) # positive values only
63
+ outputs[INCUBATION_PERIOD] = tf.keras.layers.Dense(1, activation="relu", name=INCUBATION_PERIOD)(x) # positive values only
71
64
  if F_S in target_columns:
72
65
  outputs[F_S] = tf.keras.layers.Dense(1, activation=half_sigmoid, name="FS_logits")(x)
73
66
  if X_S in target_columns:
@@ -84,6 +77,5 @@ def build_model(target_columns, n_x, optimizer=None, metrics=None):
84
77
 
85
78
  model.compile(optimizer=optimizer,
86
79
  loss={col: LOSS_FUNCTIONS[col] for col in outputs.keys()},
87
- loss_weights={col: LOSS_WEIGHTS[col] for col in outputs.keys()},
88
80
  metrics=metrics)
89
81
  return model
@@ -38,30 +38,30 @@ def get_write_handle(path, temp_suffix=''):
38
38
  def scale(Y, SF):
39
39
  for col in (Y.keys() if type(Y) == dict else Y.columns):
40
40
  for rate in RATE_PARAMETERS:
41
- if col.startswith(rate):
41
+ if col == rate:
42
42
  Y[col] *= SF
43
43
  for time in TIME_PARAMETERS:
44
- if col.startswith(time):
44
+ if col == time:
45
45
  Y[col] /= SF
46
46
 
47
47
 
48
48
  def scale_back(Y, SF):
49
49
  for col in (Y.keys() if type(Y) == dict else Y.columns):
50
50
  for rate in RATE_PARAMETERS:
51
- if col.startswith(rate):
51
+ if col == rate:
52
52
  Y[col] /= SF
53
53
  for time in TIME_PARAMETERS:
54
- if col.startswith(time):
54
+ if col == time:
55
55
  Y[col] *= SF
56
56
 
57
57
 
58
58
  def scale_back_array(Y, SF, columns):
59
59
  for i, col in enumerate(columns):
60
60
  for rate in RATE_PARAMETERS:
61
- if col.startswith(rate):
61
+ if col == rate:
62
62
  Y[:, i] /= SF
63
63
  for time in TIME_PARAMETERS:
64
- if col.startswith(time):
64
+ if col == time:
65
65
  Y[:, i] *= SF
66
66
 
67
67
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bdext
3
- Version: 0.1.68
3
+ Version: 0.1.70
4
4
  Summary: Estimation of BDEISS-CT parameters from phylogenetic trees.
5
5
  Home-page: https://github.com/modpath/bdeissct
6
6
  Author: Anna Zhukova
@@ -21,7 +21,7 @@ setup(
21
21
  'Topic :: Software Development',
22
22
  'Topic :: Software Development :: Libraries :: Python Modules',
23
23
  ],
24
- version='0.1.68',
24
+ version='0.1.70',
25
25
  description='Estimation of BDEISS-CT parameters from phylogenetic trees.',
26
26
  author='Anna Zhukova',
27
27
  author_email='anna.zhukova@pasteur.fr',
File without changes
File without changes
File without changes
File without changes
File without changes