@@ -112,19 +112,36 @@ def print_coefficients(self, round_to=None) -> None:
112
112
"""
113
113
print ("Model coefficients:" )
114
114
coeffs = az .extract (self .idata .posterior , var_names = "beta" )
115
- # Note: f"{name: <30}" pads the name with spaces so that we have alignment of
116
- # the stats despite variable names of different lengths
115
+
116
+ # Determine the width of the longest label
117
+ max_label_length = max (len (name ) for name in self .labels + ["sigma" ])
118
+
117
119
for name in self .labels :
118
120
coeff_samples = coeffs .sel (coeffs = name )
119
121
print (
120
- f"{ name : <30 } { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
122
+ f" { name : <{ max_label_length } } \t { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
121
123
)
122
- # add coeff for measurement std
124
+
125
+ # Add coefficient for measurement std
123
126
coeff_samples = az .extract (self .model .idata .posterior , var_names = "sigma" )
124
127
name = "sigma"
125
128
print (
126
- f"{ name : <30} { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
127
- )
129
+ f" { name : <{max_label_length }} \t { round_num (coeff_samples .mean ().data , round_to )} , 94% HDI [{ round_num (coeff_samples .quantile (0.03 ).data , round_to )} , { round_num (coeff_samples .quantile (1 - 0.03 ).data , round_to )} ]" # noqa: E501
130
+ )
131
+
132
+ # # Note: f"{name: <30}" pads the name with spaces so that we have alignment of
133
+ # # the stats despite variable names of different lengths
134
+ # for name in self.labels:
135
+ # coeff_samples = coeffs.sel(coeffs=name)
136
+ # print(
137
+ # f"{name: <30}{round_num(coeff_samples.mean().data, round_to)}, 94% HDI [{round_num(coeff_samples.quantile(0.03).data, round_to)}, {round_num(coeff_samples.quantile(1-0.03).data, round_to)}]" # noqa: E501
138
+ # )
139
+ # # add coeff for measurement std
140
+ # coeff_samples = az.extract(self.model.idata.posterior, var_names="sigma")
141
+ # name = "sigma"
142
+ # print(
143
+ # f"{name: <30}{round_num(coeff_samples.mean().data, round_to)}, 94% HDI [{round_num(coeff_samples.quantile(0.03).data, round_to)}, {round_num(coeff_samples.quantile(1-0.03).data, round_to)}]" # noqa: E501
144
+ # )
128
145
129
146
130
147
class PrePostFit (ExperimentalDesign , PrePostFitDataValidator ):
0 commit comments