Skip to main content

bj

Generating hierarchical data for machine learning and data science applications

Installation

pip install bj

Description

bj is a Python package that provides tools for generating synthetic hierarchical cluster data. It extends scikit-learn's make_blobs function to create nested, hierarchical blob clusters useful for:

  • Testing hierarchical clustering algorithms
  • Evaluating dimensionality reduction techniques
  • Creating visualization examples for nested data structures
  • Benchmarking clustering algorithms on hierarchical data

Usage

The main function is make_hblobs, which generates hierarchical blob clusters with configurable depth and branching.

from bj import make_hblobs
import matplotlib.pyplot as plt

# Generate a simple two-level hierarchy:
# 2 main clusters, each with 3 sub-clusters
X, y = make_hblobs(n_samples=300, centers=[2, 3])

# Plot the result
plt.figure(figsize=(10, 6))
plt.scatter(X[:, 0], X[:, 1], c=y, cmap='viridis', alpha=0.8)
plt.title('Hierarchical Blob Clusters (2x3)')
plt.show()

# Create a more complex three-level hierarchy with varying cluster spreads:
# 2 main clusters, each with 3 sub-clusters, each with 4 sub-sub-clusters
X_complex, y_complex = make_hblobs(
    n_samples=500, 
    centers=[2, 3, 4],
    cluster_std=[1.0, 0.5, 0.2]  # Decreasing spread at each level
)

Parameters

The make_hblobs function supports:

  • n_samples: Total number of points to generate
  • n_features: Number of features for each sample
  • centers: Integer or list of integers representing the hierarchy structure
  • cluster_std: Float or list of floats controlling the spread at each level
  • center_box: Bounding box for cluster centers
  • shuffle: Whether to shuffle the samples
  • random_state: For reproducibility

Examples

Simple Two-Level Hierarchy

from bj import make_hblobs

# Create a two-level hierarchy with 2 main clusters, each with 3 sub-clusters
X, y = make_hblobs(n_samples=200, centers=[2, 3])

Complex Multi-Level Hierarchy

# Create a three-level hierarchy with varying cluster spread
X, y = make_hblobs(
    n_samples=500,
    centers=[2, 3, 4],  # 2 main clusters -> 3 sub-clusters -> 4 sub-sub-clusters
    cluster_std=[1.0, 0.5, 0.3]  # Decreasing spread at each level
)

License

MIT

Download files

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

Source Distribution

bj-0.0.7.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.

bj-0.0.7-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file bj-0.0.7.tar.gz.

File metadata

  • Download URL: bj-0.0.7.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bj-0.0.7.tar.gz
Algorithm Hash digest
SHA256 34adc510cb6e5c43977b2ab361aabb15d9792ecd64a9e7088ef002df9552e31e
MD5 3b43cf7a46515e61a84b0dbe9763536b
BLAKE2b-256 353e8be3bba0b61b504e921c5fa0b35feff6b84f87139789afaba48a4387e5dd

See more details on using hashes here.

File details

Details for the file bj-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: bj-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bj-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f06b109533a691e1ea40f0336522600f4df4bf21473f2a3deaa280c33d5494d6
MD5 6b9a5b1141c11d06269b0da611f792dc
BLAKE2b-256 e32b26e85ace8761b940e4009a56fe27d7019ceb1c45beee10dd3cec8365d9af

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 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