Skip to main content

Sketchable function and density simulations for data science

Project description

Sketulate

Sketulate is a Python package for interactive function, surface, and density simulation directly in Jupyter notebooks. Draw functions, surfaces, or densities with your mouse, convert them into callable functions or density distributions, and simulate data for experiments, modeling, or teaching.

Features

  • Sketch univariate functions interactively (Sketulate)
  • Sketch 2D surfaces / interactions effects (SketulateInteraction)
  • Sketch density distributions
  • Generates easy to use functions and sampleable density distributions
  • Works seamlessly in Jupyter Notebook
  • Easy integration for synthetic data generation

Installation

pip install sketulate

Quick Example

from sketulate import Sketulate, SketulateInteraction

Draw a univariate function

f1 = Sketulate() f1.sketch()



![Sketch a Function](examples/images/draw_a_function.png)

```python
# F1 is a now a ready to use function via:
f1.f
# f takes the form of a sklearn pipeline object,so you need to call predict on new data:
import numpy as np
x = np.linspace(0,1,100)
f1.f.predict(x.reshape(-1,1))
# Or a custom density distribution (selected in the canvas dropdown) via:
f1.g
# Draw 100 samples from g  by calling:
f1.g(100)

Sketch a Density

# Draw an interaction surface
f3 = SketulateInteraction(x_range=(0,10), y_range=(0,10), z_range=(-5,5), grid_size=5)
f3.sketch()  # Interactive surface with sliders

Sketch Interaction Surface via Sliders

Put it all together and easily simulate some data

Sketch a Function

Saving and loading state

You can save a Sketulate (or SketulateInteraction) state to a dictionary and persist it as JSON, then restore it later.

1. Save the state from your sketulate object:

from sketulate import Sketulate
import json

sk = Sketulate()
sk.sketch()
# ... draw and accept a function or density ...

state = sk.save_state()

2. Write the state to a JSON file:

with open("sketulate_state.json", "w") as f:
    json.dump(state, f, indent=2)

3. Load the state from JSON (e.g. in a new session or notebook):

with open("sketulate_state.json", "r") as f:
    state = json.load(f)

4. Load the state into a Sketulate object and restore the fitted function or density:

sk_restored = Sketulate()
sk_restored.load_state(state)
# sk_restored.f (function) or sk_restored.g (density) is now available

Technical Note

For this version the sketches are modelled via piecewise linear basis functions using sklearn. Interaction surfaces are modelled using the LinearND interpolator from scipy. In addition, linear extrapolation is, by default, provided outside of the given ranges. Careful!

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

sketulate-1.0.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

sketulate-1.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file sketulate-1.0.0.tar.gz.

File metadata

  • Download URL: sketulate-1.0.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for sketulate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1cbfe8bb3f0e3d65eceee2a2cac829abef6adfca0349aee246dec09a4b637765
MD5 0f78260bed3e718d35a72fb71273c438
BLAKE2b-256 2a83160ae73a87a55785606d065b5f75f3dea9d46889605eb90e323b7ddbd01a

See more details on using hashes here.

File details

Details for the file sketulate-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sketulate-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for sketulate-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61fee94018712017bed2bf315f639f4cccfa935280060fa2cad6c2fff4e8e174
MD5 96fbc54370246ff445f05dd118ff924d
BLAKE2b-256 8594ce5bbf5b3ad2b70adeb323e26af30f8ee6f9e0f5e67b421973fa431847f3

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