Exemplo n.º 1
0
def plot_forces(variables: pd.DataFrame) -> None:
    forces = variables.drop(["Height", "Weight"], axis=1).melt()
    forces[["type", "variable"]] = forces["variable"].str.split(expand=True)

    tables.describe_table(forces,
                          groupby=["variable", "type"],
                          description="variables")
    row_kwargs = dict(shorthand="variable", title=None, sort=forces_order)
    column = alt.Column("type", title=None)

    forces_plot = (plot_kde().facet(
        data=forces.query("type != 'Imb'"),
        row=alt.Row(header=alt.Header(labelAngle=0, labelAlign="left"),
                    **row_kwargs),
        column=column,
    ).resolve_scale(y="independent").properties(bounds="flush"))

    imb_plot = (plot_kde().facet(
        data=forces.query("type == 'Imb'"),
        row=alt.Row(header=alt.Header(labelFontSize=0), **row_kwargs),
        column=column,
    ).resolve_scale(y="independent").properties(bounds="flush"))

    plots = (forces_plot | imb_plot).configure_facet(spacing=5)
    st.altair_chart(plots)
Exemplo n.º 2
0
def plot_anthropometry(variables: pd.DataFrame) -> None:
    anthropo = variables[["Height", "Weight"]].melt()

    tables.describe_table(anthropo, description="variables")

    plots = (plot_kde().facet(data=anthropo,
                              column=alt.Column("variable",
                                                title=None)).resolve_scale(
                                                    x="independent",
                                                    y="independent"))
    st.altair_chart(plots, use_container_width=True)
Exemplo n.º 3
0
def plot_targets(targets: pd.DataFrame) -> None:
    targets_melted = targets.melt()

    tables.describe_table(targets_melted, description="targets")

    dist_plot = (plot_kde().facet(
        data=targets_melted,
        row=alt.Row(
            "variable",
            title=None,
            header=alt.Header(labelAngle=0, labelAlign="left"),
        ),
    ).configure_facet(spacing=5).resolve_scale(y="independent").properties(
        bounds="flush"))
    st.altair_chart(dist_plot)
Exemplo n.º 4
0
def plot_error_dist(predictions: pd.DataFrame) -> None:
    predictions_melted = predictions.melt(id_vars="target",
                                          value_vars=["MAE", "MAPE"])
    tables.describe_table(predictions_melted, groupby=["target", "variable"])

    row_kwargs = dict(shorthand="target", title=None, sort=forces_order)
    column = alt.Column("variable", title=None)

    mae = (plot_kde().facet(
        data=predictions_melted.query("variable == 'MAE'"),
        row=alt.Row(header=alt.Header(labelAngle=0, labelAlign="left"),
                    **row_kwargs),
        column=column,
    ).resolve_scale(y="independent").properties(bounds="flush"))

    mape = (plot_kde().facet(
        data=predictions_melted.query("variable == 'MAPE'"),
        row=alt.Row(header=alt.Header(labelFontSize=0), **row_kwargs),
        column=column,
    ).resolve_scale(y="independent").properties(bounds="flush"))

    plots = (mae | mape).configure_facet(spacing=5)
    st.altair_chart(plots)