You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bayesflow/adapters/transforms/standardize.py
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,13 +16,42 @@ class Standardize(ElementwiseTransform):
16
16
17
17
z = (x - mean(x))/std(x)
18
18
19
+
Important to note that when specifying a mean and sd user should be careful to specify which variables should be standardized. Please see examples.
20
+
19
21
Parameters:
20
22
mean: integer or float used to specify a mean if known but will be estimated from data when not provided
21
23
std: integer or float used to specify a standard devation if known but will be estimated from data when not provided
22
24
axis: integer representing a specific axis along which standardization should take place. By default
23
25
standardization happens individually for each dimension
24
26
momentum: float in (0,1) specifying the momentum during training
25
27
28
+
Examples:
29
+
30
+
1) Standardize all variables using estimated mean and standard deviation
31
+
32
+
adapter = (
33
+
bf.adapters.Adapter()
34
+
.standardize()
35
+
)
36
+
37
+
38
+
2) Standardize all with same known mean and standard deviation. In this example all data is drawn from a standard normal
39
+
40
+
adapter = (
41
+
bf.adapters.Adapter()
42
+
.standardize(mean = 1, sd = 0)
43
+
)
44
+
45
+
46
+
3) Mix of specified and auto-computed means/sds. Suppose we have priors for "beta" and "sigma" where we know the mean and standard deviations. However for our simulated data "x" and "y" the mean and standard deviations are unknown. Then standardize should be used in several stages specifying which variables to include or exclude.
47
+
48
+
adapter = (
49
+
bf.adapters.Adapter()
50
+
.standardize(include = "beta", mean = 1) # specify only mean/sd
51
+
.standardize(include = "sigma", mean = 0.6, sd = 1) # specify both mean and sd
52
+
.standardize(exclude = ["beta", "sigma"]) # specify neither mean nor sd
0 commit comments