koaning / bulk

A Simple Bulk Labelling Tool
MIT License
536 stars 45 forks source link

Next version #66

Closed koaning closed 3 weeks ago

koaning commented 3 months ago

Some notes just for Vincent.

import altair as alt
import pandas as pd
import numpy as np

rand = np.random.RandomState(42)

df = pd.DataFrame({
    'xval': range(100),
    'yval': rand.randn(100).cumsum()
})

slider = alt.binding_range(min=0, max=100, step=1)
brush = alt.selection_interval(
    encodings=["x", "y"],
    on="[mousedown[event.shiftKey], mouseup] > mousemove",
    translate="[mousedown[event.shiftKey], mouseup] > mousemove!",
    zoom="wheel![event.shiftKey]",
)

interaction = alt.selection_interval(
    bind="scales",
    on="[mousedown[!event.shiftKey], mouseup] > mousemove",
    translate="[mousedown[!event.shiftKey], mouseup] > mousemove!",
    zoom="wheel![!event.shiftKey]",
)

chart = alt.Chart(df).mark_point().encode(
    x='xval',
    y='yval',
).add_params(
    interaction, brush
)

jchart = alt.JupyterChart(chart)
jchart
from bulk import SelectionWidget, EmbeddedTextInput, TextPreview, ImagePreview

widget = SelectionWidget(dataf, color)
query = EmbeddedTextInput(embed_func, decomp)
widget.set_preview(text_preview)
widget.set_input(text_input)
from bulk import SubsetSlider

slider = SubsetSlider(jsonl, display_fn, similarity_column)
koaning commented 3 months ago

I guess realistically this library will never really replace something like jscatter/altair now that we have proper widgets in notebooks. So that suggests that bulk should mainly be a thin layer that can combine thing together. I guess we should opt for jscatter for now.

I guess as a next step we should make some views that combine 'em.