Plot the distributions of the selected features by the label class.
Source code in autorad/visualization/plotly_utils.py
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 | def boxplot_by_class(
X: pd.DataFrame,
y: pd.Series,
):
"""
Plot the distributions of the selected features by the label class.
"""
features = X.columns
nrows, ncols, _ = get_subplots_dimensions(len(features))
fig = make_subplots(rows=nrows, cols=ncols)
for i, feature in enumerate(features):
name = feature.replace("_", " ")
fig.add_trace(
go.Box(x=y, y=X[feature], name=name),
row=i // ncols + 1,
col=i % ncols + 1,
)
fig.update_layout(width=1300, height=700)
fig.update_layout(font={"size": 19})
fig.update_layout(
legend=dict(
orientation="h", yanchor="bottom", y=1.03, xanchor="right", x=1
)
)
return fig
|