Skip to content

edsteva.viz.dashboards.probe.fitted_probe

fitted_probe_dashboard

fitted_probe_dashboard(
    predictor: pd.DataFrame,
    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],
    vertical_bar_charts_config: Dict[str, str],
    horizontal_bar_charts_config: Dict[str, str],
    time_line_config: Dict[str, str],
    chart_style: Dict[str, float],
)

Script to be used by predictor_dashboard()

PARAMETER DESCRIPTION
predictor

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

TYPE: pd.DataFrame

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

Configuration used to construct the top main chart.

TYPE: Dict[str, float]

model_line_config

Configuration used to construct the model line.

TYPE: Dict[str, str]

probe_line_config

Configuration used to construct the probe line.

TYPE: Dict[str, str]

vertical_bar_charts_config

Configuration used to construct the vertical bar charts.

TYPE: Dict[str, str]

horizontal_bar_charts_config

Configuration used to construct the horizontal bar charts.

TYPE: Dict[str, str]

time_line_config

Configuration used to construct the time line.

TYPE: Dict[str, str]

chart_style

Configuration used to configure the chart style. EXAMPLE: {"labelFontSize": 13, "titleFontSize": 14}

TYPE: Dict[str, float]

Source code in edsteva/viz/dashboards/probe/fitted_probe.py
 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
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def fitted_probe_dashboard(
    predictor: pd.DataFrame,
    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],
    vertical_bar_charts_config: Dict[str, str],
    horizontal_bar_charts_config: Dict[str, str],
    time_line_config: Dict[str, str],
    chart_style: Dict[str, float],
):
    r"""Script to be used by [``predictor_dashboard()``][edsteva.viz.dashboards.probe.wrapper]

    Parameters
    ----------
    predictor : pd.DataFrame
        $c(t)$ computed in the Probe with its prediction $\hat{c}(t)$
    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
        Configuration used to construct the top main chart.
    model_line_config: Dict[str, str], optional
        Configuration used to construct the model line.
    probe_line_config: Dict[str, str], optional
        Configuration used to construct the probe line.
    vertical_bar_charts_config: Dict[str, str], optional
        Configuration used to construct the vertical bar charts.
    horizontal_bar_charts_config: Dict[str, str], optional
        Configuration used to construct the horizontal bar charts.
    time_line_config: Dict[str, str], optional
        Configuration used to construct the time line.
    chart_style: Dict[str, float], optional
        Configuration used to configure the chart style.
        **EXAMPLE**: `{"labelFontSize": 13, "titleFontSize": 14}`
    """
    predictor["legend_predictor"] = legend_predictor
    predictor["legend_model"] = legend_model

    base = alt.Chart(predictor)
    time_line, time_selection = generate_time_line(
        base=base,
        time_line_config=time_line_config,
    )
    horizontal_bar_charts, y_variables_selections = generate_horizontal_bar_charts(
        base=base,
        horizontal_bar_charts_config=horizontal_bar_charts_config,
        predictor=predictor,
    )
    vertical_bar_charts, x_variables_selections = generate_vertical_bar_charts(
        base=base,
        vertical_bar_charts_config=vertical_bar_charts_config,
        predictor=predictor,
    )

    selections = dict(
        date=time_selection,
        **y_variables_selections,
        **x_variables_selections,
    )
    selection_charts = dict(
        horizontal_bar_charts,
        **vertical_bar_charts,
    )

    base = add_interactive_selection(
        base=base, selection_charts=selection_charts, selections=selections
    )

    index_selection, index_fields = create_groupby_selection(
        indexes=vertical_bar_charts_config["x"] + horizontal_bar_charts_config["y"],
        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)
    chart = concatenate_charts(
        main_chart=main_chart,
        time_line=time_line,
        horizontal_bar_charts=horizontal_bar_charts,
        vertical_bar_charts=vertical_bar_charts,
    )
    return configure_style(chart=chart, chart_style=chart_style)