import numpy as np
import pandas as pd
import rows2prose.notebook as r2p
import sklearn.datasets
r2p.init_notebook_mode()
df = sklearn.datasets.load_wine(as_frame=True).frame
viz = r2p.DistributionListSnapshot
html = "<strong>Properties of 3 different classes of wine</strong><br/>"
controls = []
for i, name in enumerate(df.columns):
if name != "target":
html += f"""<div style='display:inline-block;margin:10px;'>
{name.replace('_', ' ')}:<br/>
<span data-key='{name}' class='scalar-view{i}'></span>
</div>"""
# Use a different scalar view control for each visualization if you
# want different scales for each.
controls.append(
viz.scalar_view(class_name=f"scalar-view{i}", height=20)
)
r2p.display(df, html, viz(*controls, i_config_column="target"))
df = sklearn.datasets.load_linnerud(as_frame=True).frame
viz = r2p.Timeline
html = """<p><strong>Browse sklearn's toy exercise dataset:</strong><p>
<div class="time-control" style="width:400px"></div>"""
controls = [viz.time_control(class_name="time-control", prefix="Athlete")]
for i, name in enumerate(df.columns):
html += f"""<p>
{name}:
<span data-key='{name}' class='scalar-view{i}'></span>
</p>"""
controls.append(viz.positive_scalar_view(class_name=f"scalar-view{i}"))
df["id"] = np.arange(df.shape[0])
r2p.display(df, html, viz(*controls, i_timestep_column="id"))
Browse sklearn's toy exercise dataset:
Chins:
Situps:
Jumps:
Weight:
Waist:
Pulse: