Create and Visualize Datasets with Line, Scatter and Histogram Plots Using DrawData

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 189
Posts: 5925
Joined: 10 years ago
Location: Tanzania
Contact:

#1

Initially used as embeddable widgets, drawdata is a small Python library that allows users to create datasets interactively within Jupyter notebooks using widgets. This tool is particularly useful for teaching machine learning concepts. It supports integration with Jupyter, VSCode, and Colab, thanks to its use of anywidget.

Installation

  1. python -m pip install drawdata


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

  1. python -m pip install pandas polars


Basic Usage

You can load the scatter widget to start drawing immediately:

  1. from drawdata import ScatterWidget
  2.  
  3. widget = ScatterWidget()
  4. widget


Once you've drawn your data, you can access it as:
  • A list of dictionaries: widget.data
  • A Pandas DataFrame: widget.data_as_pandas
  • A Polars DataFrame: widget.data_as_polars
  • Features and labels for machine learning: X, y = widget.data_as_X_y

The tool recognizes multiple colors for classification tasks, while a single color is used for regression.


Using the Old Feature

To use the old feature in Jupyter, load it within an iframe:

  1. from drawdata import draw_scatter
  2. draw_scatter()


After drawing, copy the data to the clipboard. You can then use pandas to import it into a DataFrame:

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


Additional Information

Originally developed at Calmcode Labs, this library has evolved from using iframes to leveraging anywidget for better integration and usability.

For more details, visit the GitHub repository.
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply

Return to “Technologies for Teaching, Learning, Research, Problem Solving and Business”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests