Skip to main content

draw a dataset from inside Jupyter

Project description

drawdata

"Just draw some data and get on with your day."

This small Python library contains Jupyter widgets that allow you to draw a dataset in a Jupyter notebook. This should be very useful when teaching machine learning algorithms.

The project uses anywidget under the hood so our tools should work in Jupyter, VSCode and Colab. That also means that you get a proper widget that can interact with ipywidgets natively. Here is an example where updating a drawing triggers a new scikit-learn model to train (code).

You can really get creative with this in a notebook, so feel free to give it a spin!

Installation

Installation occurs via pip.

python -m pip install drawdata

To read the data, polars is useful, but this library also suppots pandas:

python -m pip install pandas polars

Usage

You can load the scatter widget to start drawing immediately.

from drawdata import ScatterWidget

widget = ScatterWidget()
widget

If you want to use the dataset that you've just drawn you can do so via:

# Get the drawn data as a list of dictionaries
widget.data

# Get the drawn data as a dataframe
widget.data_as_pandas
widget.data_as_polars

If you're eager to do scikit-learn stuff with your drawn data you may appreciate this property instead:

X, y = widget.data_as_X_y

The assumption for this property is that if you've used multiple colors that you're interested in doing classification and if you've only drawn one color you're interested in regression. In the case of regression y will refer to the y-axis.

Shoutout

This project was originally part of my work over at calmcode labs but my employer probabl has been very supportive and has allowed me to work on this project during my working hours. This was super cool and I wanted to make sure I recognise them for it.





Old Features

The original implementation of our widget would use an iframe to load a site in order to be able to draw from a Jupyter notebook. This works, but requires more manual effort, only works with pandas via the clipboard feature and needs an internet connection. Here's what that widget looks like:

It will be kept around, but the way forward for this library is to build on top of anywidget.

Old Feature Usage

When you run this from jupyter, you should load in an iframe.

from drawdata import draw_scatter

draw_scatter()

Once you're done drawing you can copy the data to the clipboard. After this you can use pandas to read the clipboard to get your drawn data into a dataframe.

import pandas as pd 
pd.read_clipboard(sep=",")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drawdata-0.3.6.tar.gz (233.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drawdata-0.3.6-py2.py3-none-any.whl (234.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file drawdata-0.3.6.tar.gz.

File metadata

  • Download URL: drawdata-0.3.6.tar.gz
  • Upload date:
  • Size: 233.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for drawdata-0.3.6.tar.gz
Algorithm Hash digest
SHA256 c224c36c689d7d658a5177eeb335d374446cd218f46ee8f4d1c4e6d205bbe36d
MD5 da9a26a4d5a158b91f6bc5163270b12e
BLAKE2b-256 2516bd64251c452fd2dd15a0d50cf8c3d9f5ff9704140d8e079ffe88d83ccf9b

See more details on using hashes here.

File details

Details for the file drawdata-0.3.6-py2.py3-none-any.whl.

File metadata

  • Download URL: drawdata-0.3.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 234.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for drawdata-0.3.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c55828e82a3c60d5e96ce3e058b1fd1a2e60df5988a49174c9880ff72efc7070
MD5 137b43ae2c5b9f26e9d92f72d9b4f055
BLAKE2b-256 8a34279191f4651ac412d23db113407fe3464014863a93ec11bd427b6f8f0b2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page