Skip to main content

Sample Things EVENly

Project description

Steven

Steven (Sample Things EVENly) helps you sample your data in nice easy ways, evenly across the range of the data!

How to use Steven

The main method of steven is sample_data_evenly. This takes as input a sequence-liked object such as a list, tuple, np.ndarray or pd.Series, and samples it in such a way that the items returned represent a balanced distribution across the data range.

This is useful for balancing both continuous and discrete data for machine learning applications, among other things!

Here is an example that you can run:

import numpy as np
import matplotlib.pyplot as plt

from steven.sampling import sample_data_evenly

# Create some data...
data = np.exp(np.random.rand(100_000))
plt.hist(data, bins=50, range=[data.min(), data.max()], label='All data')

# Now sample the data...
data_sampled = subset_data_evenly(data, n_bins=50, sample_size=20_000)
plt.hist(data_sampled, bins=50, range=[data.min(), data.max()], label='Sampled')

plt.legend()
plt.show()

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

steven-0.3.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

steven-0.3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file steven-0.3.0.tar.gz.

File metadata

  • Download URL: steven-0.3.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for steven-0.3.0.tar.gz
Algorithm Hash digest
SHA256 21ecfc151e38eb5ea676978fa6fda89461dcf004baac648afd8bf3cddd7b3e28
MD5 cd042cb343a411f60138dd69fe14618a
BLAKE2b-256 bd5504947d06220542a4712cf9ba9726e93fd791c1dbaa9c5c189329ab4ce5b7

See more details on using hashes here.

File details

Details for the file steven-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: steven-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for steven-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba9079f18781645602d655902387a8c947b184b37c1510fb143cf4428b6adbb2
MD5 36596e68a4b4b50931fcc6e93ca7c500
BLAKE2b-256 fa3e9690ef222590c235321d601a1623a5f2eed210ea08b9977d7483379d7819

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