Skip to content

edsteva.viz.plots.probe.fitted_probe

fitted_probe_line

fitted_probe_line(
    predictor: pd.DataFrame,
    indexes: List[Dict[str, str]],
    legend_predictor: str,
    legend_model: str,
    x_axis_title: str,
    y_axis_title: str,
    main_chart_config: Dict[str, float],
    model_line_config: Dict[str, str],
    probe_line_config: Dict[str, str],
)

Script to be used by plot_probe()

PARAMETER DESCRIPTION
predictor

\(c(t)\) computed in the Probe with its prediction \(\hat{c}(t)\)

TYPE: pd.DataFrame

indexes

Variable from which data is grouped

TYPE: List[str]

legend_predictor

Label name for the predictor legend.

TYPE: str

legend_model

Label name for the model legend.

TYPE: str

x_axis_title

Label name for the x axis.

TYPE: str

y_axis_title

Label name for the y axis.

TYPE: str

main_chart_config

If not None, configuration used to construct the top main chart.

TYPE: Dict[str, float]

model_line_config

If not None, configuration used to construct the model line.

TYPE: Dict[str, str]

probe_line_config

If not None, configuration used to construct the probe line.

TYPE: Dict[str, str]

Source code in edsteva/viz/plots/probe/fitted_probe.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def fitted_probe_line(
    predictor: pd.DataFrame,
    indexes: List[Dict[str, str]],
    legend_predictor: str,
    legend_model: str,
    x_axis_title: str,
    y_axis_title: str,
    main_chart_config: Dict[str, float],
    model_line_config: Dict[str, str],
    probe_line_config: Dict[str, str],
):
    r"""Script to be used by [``plot_probe()``][edsteva.viz.plots.probe.wrapper]

    Parameters
    ----------
    predictor : pd.DataFrame
        $c(t)$ computed in the Probe with its prediction $\hat{c}(t)$
    indexes : List[str]
        Variable from which data is grouped
    legend_predictor: str, optional,
        Label name for the predictor legend.
    legend_model: str, optional,
        Label name for the model legend.
    x_axis_title: str, optional,
        Label name for the x axis.
    y_axis_title: str, optional,
        Label name for the y axis.
    main_chart_config: Dict[str, str], optional
        If not None, configuration used to construct the top main chart.
    model_line_config: Dict[str, str], optional
        If not None, configuration used to construct the model line.
    probe_line_config: Dict[str, str], optional
        If not None, configuration used to construct the probe line.
    """
    predictor["legend_predictor"] = legend_predictor
    predictor["legend_model"] = legend_model

    base = alt.Chart(predictor)

    index_selection, index_fields = create_groupby_selection(
        indexes=indexes,
        predictor=predictor,
    )
    main_chart = generate_main_chart(
        base=base,
        main_chart_config=main_chart_config,
        index_selection=index_selection,
        index_fields=index_fields,
        x_axis_title=x_axis_title,
        y_axis_title=y_axis_title,
    )

    probe_line = generate_probe_line(
        main_chart=main_chart, probe_line_config=probe_line_config
    )

    model_line = generate_model_line(
        main_chart=main_chart, model_line_config=model_line_config
    )

    main_chart = probe_line + model_line
    if index_selection:
        main_chart = main_chart.add_params(index_selection)

    return main_chart