Skip to main content

SmoothDE

smoothDE is a python library that trains on data samples to learn a probability distribution and then make predictions about the probability of points.

plot

It uses a lattice based approach to estimate the smoothness of a potential probability distribution. Thus, while smoothDE can predict distributions in 1, 2, 3, or more dimensions, as the lattice increases in dimension smoothDE becomes slower.

Module docs: gitlab pages

Installation

The only tricky part of this install seems to be the scikit-sparse library. I suggest installing the fundamental libraries first as this installation gives faster scikit-sparse results:

# mac
brew install suite-sparse

# linux
sudo apt-get install libsuitesparse-dev

these commands were lifted straight from the scikit-sparse installation instructions. The conda installation did not perform operations as quickly as a fresh install of the above system libraries. smoothDE should install scikit-sparse as a pip, but you can install it yourself if the next step doesn't work.

The repositiory is at https://gitlab.com/rhys-m-adams/smoothde, but you don't need to download it to run it. If you download the repository, you should be able to run:

pip install -e <file path>/smoothDE/

The simpler way is to use the internet

pip install smoothDE

The preprint describing this library mathematically can be found and cited at here currently: preprint

Quick usage

To fit a density estimator:

import numpy as np
from smoothDE.estimator import DensityFitter
X = np.array([[3, 1],[2,2],[1, 1],[2,3]]) #observed data points, 3 samples in 2D
box = [[0,4,32],[0,4,32]] # fit field from 0 to 4, with 32 gridpoints in 2 dimensions
dr = DensityFitter(box, dpow=2) # create the smoothDE object
record = dr.fit(X) # fit the data, returns a record of the fit results
phi = dr.predict(X) # predict phi from data, X in this case for conciseness
p = np.exp(-phi) # pdf estimate of X points

If you have many features and want to just calculate the 1 dimensional fields, you can use the make_subfields module:

from smoothDE.make_subfields import MakeSubfields

trf = MakeSubfields([2], [128],n_threads=1, paired=True)
trf.fit(X, np.array([0,0,1, 1]))
sub_fields = trf.predict(X)
print(sub_fields)
sub_field_array = trf.transform(X)
print(sub_field_array)

For 2D fields, the lists need to be length 2 in MakeSubfieds;

from smoothDE.make_subfields import MakeSubfields

trf = MakeSubfields([2, 2], [128, 48],n_threads=1, paired=True)
trf.fit(X, np.array([0,0,1, 1]))
sub_fields = trf.predict(X)
print(sub_fields)
sub_field_array = trf.transform(X)
print(sub_field_array)

Demo also shown at youtube demo

Metadata

Release files for smoothde 1.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smoothde 1.4.3
File Size Uploaded
smoothde-1.4.3.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smoothde 1.4.3
File Interpreter ABI Platform
smoothde-1.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.2 kB

Release files / smoothde-1.4.3.tar.gz

Download URL smoothde-1.4.3.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ea596e445e46f96072d92e016cb98f8e2e81b59845ce16994f62e2340a47b72c
BLAKE2b-256 checksum
How to use checksums
d817765120970bfc9ca8845fe4f80bcbf5222c69ec377283c40275a3485aa5e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / smoothde-1.4.3-py3-none-any.whl

Download URL smoothde-1.4.3-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f231c00518e9c4637eb2e9af120e77814b2ed2202943d09450aaddb2281efebf
BLAKE2b-256 checksum
How to use checksums
331b84be23a492637b0d79ce90ea53ff143aa175133efe2cff6b0d6d196c1d06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

1.4.3 This release

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4

2 release files

1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page