stanbkt.plot.plot_posterior_correctness#

stanbkt.plot.plot_posterior_correctness(posterior_pred_kc, data, kc, grouped=False, type='preds', point_estimate='mean', *, percentiles=(2.5, 97.5), problem_ids=None, trajectory=False, frac=1.0, column_mapping={}, offset=0)#

Plot posterior predictions of correctness for a given KC.

Parameters:
  • posterior_pred_kc (DataFrame) – Posterior predictions for the selected KC.

  • data (DataFrame) – Input data containing student interactions.

  • kc (str) – The KC for which to plot posterior predictions.

  • grouped (bool) – Whether to produce one subplot per group using the group column from column_mapping (or group_id by default). If True, the group column is required in data.

  • type (Literal['probs', 'preds']) – Whether the posterior predictions are probabilities (“probs”) or binary predictions (“preds”).

  • point_estimate (Literal['mean', 'median', 'mode']) – The point estimate to display for each problem. Can be “mean”, “median”, or “mode”.

  • problem_ids (Optional[list[str]]) – List of problem IDs to include in the plot. If None, all problems for the KC

  • trajectory (bool) – Whether to connect the data points with a line to show the trajectory across problems. Default is False.

  • percentiles (tuple[float, float]) – The lower and upper percentiles to display as error bars. Values should be in range [1, 99].

  • frac (float, optional) – Fraction of problems to use for plotting. The problems will be linearly spaced. Useful for large datasets to reduce overplotting.

  • col_mapping (dict, optional) – Mapping of expected column names. Keys should be ‘student_id’, ‘problem_id’, ‘correct’, and ‘kc_id’. If None, default column names are used.

  • offset (float) – Horizontal offset to apply to the posterior predictions for better visibility when plotted alongside data points.

  • column_mapping (Mapping[ColumnNames, str] | Mapping[str, str] | Mapping[ColumnNames | str, str])

Returns:

A single axis for ungrouped data, or an array of subplot axes (one per group) when grouped data is provided.

Return type:

Union[Axes, ndarray[tuple[Any, ...], dtype[object_]]]