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

Release files for bj 0.0.7

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

Source distribution (sdist)

Source distribution for bj 0.0.7
File Size Uploaded
bj-0.0.7.tar.gz 7.9 kB Details

Built distribution (wheel)

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

Total release size: 15.6 kB

Release files / bj-0.0.7.tar.gz

Download URL bj-0.0.7.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
34adc510cb6e5c43977b2ab361aabb15d9792ecd64a9e7088ef002df9552e31e
BLAKE2b-256 checksum
How to use checksums
353e8be3bba0b61b504e921c5fa0b35feff6b84f87139789afaba48a4387e5dd
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / bj-0.0.7-py3-none-any.whl

Download URL bj-0.0.7-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f06b109533a691e1ea40f0336522600f4df4bf21473f2a3deaa280c33d5494d6
BLAKE2b-256 checksum
How to use checksums
e32b26e85ace8761b940e4009a56fe27d7019ceb1c45beee10dd3cec8365d9af
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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