Skip to content

Commit cfdfed6

Browse files
committed
Fix n_bins to num_bins
1 parent d795788 commit cfdfed6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

bayesflow/diagnostics/plots/calibration_histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def calibration_histogram(
102102
"Confidence intervals might be unreliable!"
103103
)
104104

105-
# Set n_bins automatically, if nothing provided
105+
# Set num_bins automatically, if nothing provided
106106
if num_bins is None:
107107
num_bins = int(ratio / 2)
108108
# Attempt a fix if a single bin is determined so plot still makes sense

bayesflow/diagnostics/plots/mc_calibration.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def mc_calibration(
1818
pred_models: dict[str, np.ndarray] | np.ndarray,
1919
true_models: dict[str, np.ndarray] | np.ndarray,
2020
model_names: Sequence[str] = None,
21-
n_bins: int = 10,
21+
num_bins: int = 10,
2222
label_fontsize: int = 16,
2323
title_fontsize: int = 18,
2424
metric_fontsize: int = 14,
@@ -41,12 +41,12 @@ def mc_calibration(
4141
The one-hot-encoded true model indices per data set.
4242
model_names : list or None, optional, default: None
4343
The model names for nice plot titles. Inferred if None.
44-
n_bins : int, optional, default: 10
44+
num_bins : int, optional, default: 10
4545
The number of bins to use for the calibration curves (and marginal histograms).
4646
label_fontsize : int, optional, default: 16
4747
The font size of the y-label and y-label texts
48-
legend_fontsize : int, optional, default: 14
49-
The font size of the legend text (ECE value)
48+
metric_fontsize : int, optional, default: 14
49+
The font size of the metric (e.g., ECE)
5050
title_fontsize : int, optional, default: 18
5151
The font size of the title text. Only relevant if `stacked=False`
5252
tick_fontsize : int, optional, default: 12
@@ -83,7 +83,7 @@ def mc_calibration(
8383
estimates=pred_models,
8484
targets=true_models,
8585
model_names=plot_data["variable_names"],
86-
n_bins=n_bins,
86+
num_bins=num_bins,
8787
return_probs=True,
8888
)
8989

@@ -92,7 +92,7 @@ def mc_calibration(
9292
ax.plot(ece["probs_pred"][j], ece["probs_true"][j], "o-", color=color)
9393

9494
# Plot PMP distribution over bins
95-
uniform_bins = np.linspace(0.0, 1.0, n_bins + 1)
95+
uniform_bins = np.linspace(0.0, 1.0, num_bins + 1)
9696
norm_weights = np.ones_like(plot_data["estimates"]) / len(plot_data["estimates"])
9797
ax.hist(plot_data["estimates"][:, j], bins=uniform_bins, weights=norm_weights[:, j], color="grey", alpha=0.3)
9898

bayesflow/utils/classification/calibration_curve.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def calibration_curve(
2727
num_bins : int, default=5
2828
Number of bins to discretize the [0, 1] interval. A bigger number
2929
requires more data. Bins with no samples (i.e. without
30-
corresponding values in `y_prob`) will not be returned, thus the
31-
returned arrays may have less than `n_bins` values.
30+
corresponding values in `estimates`) will not be returned, thus the
31+
returned arrays may have less than `num_bins` values.
3232
strategy : {'uniform', 'quantile'}, default='uniform'
3333
Strategy used to define the widths of the bins.
3434
@@ -39,11 +39,11 @@ def calibration_curve(
3939
4040
Returns
4141
-------
42-
prob_true : ndarray of shape (n_bins,) or smaller
42+
prob_true : ndarray of shape (num_bins,) or smaller
4343
The proportion of samples whose class is the positive class, in each
4444
bin (fraction of positives).
4545
46-
prob_pred : ndarray of shape (n_bins,) or smaller
46+
prob_pred : ndarray of shape (num_bins,) or smaller
4747
The mean estimated probability in each bin.
4848
4949
References

0 commit comments

Comments
 (0)