Skip to main content

[!IMPORTANT] Legal Disclaimer
This open‑source library (RapidSegment) is an independent, community‑driven predictive analytics framework. It is completely unaffiliated with any commercial products, SaaS platforms, or enterprise solutions of the same or similar name. Any overlap in nomenclature is purely coincidental.

adfd9cdf-251f-44e4-af79-20802d4a7a01

🚀 RapidSegment – Strategic Segmentation & Scorecard Engine

PyPI version Python 3.11+ License: MIT

RapidSegment is an industrial‑grade, combinatorial heuristic engine for discovering high‑lift predictive segments and compiling them into transparent, production‑ready scorecards. It bridges the gap between black‑box ML and legacy SQL rules engines.

Rapid Segment Interactive Explainer (Must Try)

Explainer


📘 Full documentation, architecture diagrams, statistical background, configuration reference, and FAQs live in the repo-level README. This page only covers install + a quick usage example.


📦 Installation

pip install rapidsegment

With the optional no-code Web UI:

pip install "rapidsegment[ui]"
rapidsegment-ui          # opens http://localhost:8501

⚡ Quick Start

import numpy as np
import pandas as pd
import duckdb
from rapidsegment import StrategicSegmentBuilder, StrategicSegmentScore
 
# 1. Synthetic data (or use your own)
np.random.seed(42)
n = 50_000
data = pd.DataFrame({
    "cust_id": [f"CUST_{i:05d}" for i in range(n)],
    "max_dpd_12m": np.random.choice([0, 15, 30, 60, 90], n, p=[0.7, 0.15, 0.08, 0.05, 0.02]),
    "utilization_avg_3m": np.random.uniform(0, 1.2, n),
    "risk_segment": np.random.choice(["Low", "Medium", "High"], n, p=[0.6, 0.3, 0.1]),
    "default_flag": np.random.choice([0, 1], n, p=[0.95, 0.05]),
})
 
# 2. Configure and run the builder
builder = StrategicSegmentBuilder(
    target="default_flag",
    top_n_vars=15,
    max_segments=5,
    ignore_features=["cust_id"],
)
segments = builder.extract_segments(data)
print(pd.DataFrame(segments)[["segment_id", "count", "lift", "sql_filter"]])
 
# 3. Build a scorecard
segment_cols = []
scoring_df = data[["cust_id", "default_flag"]].copy()
for seg in segments:
    col = f"SEG_{seg['segment_id']}"
    scoring_df[col] = duckdb.sql(f"SELECT ({seg['sql_filter']}) FROM data").df().astype(int)
    segment_cols.append(col)
 
scorer = StrategicSegmentScore(target_col="default_flag", primary_key="cust_id", segment_cols=segment_cols)
model = scorer.calculate_and_export_weights(scoring_df, "model.json")
print("Deciles:", model["decile_min_thresholds"])

🧩 How It Fits Together

Raw Data → StrategicSegmentBuilder → Segments (SQL rules) → StrategicSegmentScore → JSON Scorecard

StrategicSegmentBuilder finds high‑lift, hierarchical rules on your data; StrategicSegmentScore turns those rules into a weighted, deployable scorecard. UniversalDataLoader and BigQueryFeatureSelector are available for ingestion and feature screening — see the full README for details on every component, the extraction algorithm, statistical foundations, and the complete configuration reference.


📄 License

MIT — see LICENSE.

Built with ❤️ by Bishwarup Biswas. Special thanks to Guillermo Navas Palencia for Optbinning.

👉 For everything else — features, architecture, config reference, FAQs — see the repo README.

Metadata

Release files for rapidsegment 1.3.1.post1

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

Source distribution (sdist)

Source distribution for rapidsegment 1.3.1.post1
File Size Uploaded
rapidsegment-1.3.1.post1.tar.gz 96.0 kB Details

Built distribution (wheel)

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

Total release size: 202.7 kB

Release files / rapidsegment-1.3.1.post1.tar.gz

Download URL rapidsegment-1.3.1.post1.tar.gz
Size 96.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2a4b8412b0fb4d15f5ffdfe03ccf0b3fcc983471b3cdb76831ef561420e8fd8c
BLAKE2b-256 checksum
How to use checksums
7abbc4d552fe0d0e46594e40a1cb34a0374dd854369cfc654024c37deab112ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release files / rapidsegment-1.3.1.post1-py3-none-any.whl

Download URL rapidsegment-1.3.1.post1-py3-none-any.whl
Size 106.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a6f3caa80a7ada00305b7016e71abb76bd0bfdd59999821f07190690525dd22
BLAKE2b-256 checksum
How to use checksums
7538bdf7d86ef82ef3fbe97b7f21281cfb00a86204214d9c296f468e60738ca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1
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