Skip to main content

naampy

PyPI CI Docs Python

Naampy estimates population-level patterns in Indian first names. It returns a calibrated score or an exact aggregate lookup, together with abstention status, script support, and immutable artifact provenance.

Naampy does not observe or assign a person's gender. Do not use its output for individual classification or consequential decisions.

Install

pip install naampy

Naampy downloads its model and lookup artifacts from Hugging Face at revisions pinned by the package. The wheel contains code, not model weights or source tables.

Choose the operation that matches the question

Question Function Result
What female source-label share is associated with this first-name pattern? estimate_first_name_pattern() Calibrated nullable score from 0 to 1
What female and male source-label counts were released for this exact first name? lookup_first_name_composition() Exact nullable counts and shares

The lookup never falls back to the model. The model never returns a hard gender label.

Estimate a name pattern

from naampy import estimate_first_name_pattern

estimates = estimate_first_name_pattern(["Priya", "Rahul", "देव", None])
print(
    estimates[
        [
            "input_name",
            "female_label_score",
            "abstained",
            "abstention_reason",
            "script_supported",
            "model_revision",
            "model_bundle_sha256",
        ]
    ]
)

female_label_score estimates the female share among the female and male electoral-roll source labels associated with a first-name pattern. It is not a confidence score and does not measure a person's identity. An ineligible input has a missing score and an explicit abstention_reason.

Look up exact aggregate composition

from naampy import lookup_first_name_composition

composition = lookup_first_name_composition(["Priya", "Rahul", "unknown"])
print(
    composition[
        [
            "input_name",
            "female_label_record_count",
            "male_label_record_count",
            "female_label_share_among_binary_labels",
            "lookup_status",
            "lookup_reason",
            "lookup_artifact_revision",
        ]
    ]
)

The public lookup contains one global row per released name. It combines states and birth years, excludes the sparse third-gender source-label field, and keeps only names with at least 1,000 represented female plus male label records. A not-released result means only that the normalized name is absent from this released table.

Input contract

Both functions accept one string, a sequence containing strings or missing values, or a pandas Series. Both return a new pandas DataFrame in input order.

Naampy applies Unicode NFC normalization, removes surrounding whitespace, and case-folds the input. It does not delete punctuation, remove diacritics, transliterate, reorder tokens, or truncate names. A name outside an artifact's documented domain produces an abstention instead of a guess.

The learned model supports one Latin first name containing 3 to 19 ASCII letters a through z, with no character repeated three times in a row. The exact lookup supports the lowercase ASCII keys published in its manifest.

Held-out evidence

On 12,445 test names representing 46,517,339 female plus male source-label records, the calibrated v0.11 model has record-weighted expected binary log loss 0.3788, Brier score 0.1223, expected accuracy 0.8117, and expected female F1 0.8041. The 95% name-cluster bootstrap interval for log loss is 0.3486 to 0.4116. See the model card for name-weighted results, intervals, calibration diagnostics, and the exact evidence hashes.

Responsible use

The source labels come from historical Indian electoral-roll records. They are binary because of the retained source target, not because identity is binary. Coverage, spelling, romanization, geography, time, and administrative practices can all change the score or lookup composition.

Use Naampy only for aggregate research where a name-pattern estimate is an appropriate and validated measurement. Do not use it to classify a person or to make decisions about employment, credit, housing, health care, policing, immigration, voting, advertising, access to services, or any other consequential outcome.

Artifact controls

Set NAAMPY_MODEL_DIR to a directory containing the complete model bundle for an offline or controlled deployment. Set NAAMPY_LOOKUP_TABLE_DIR to a directory containing the complete lookup bundle. Naampy verifies the artifact schemas and SHA-256 hashes before use.

The model and lookup manifests record their targets, reference populations, label sources, supported inputs, versions, and content hashes. The package pins the Hugging Face repository revision separately. Every model result also includes model_bundle_sha256, a stable fingerprint of the validated weights, architecture, target, and calibration contract. For a local override, the repository and revision fields both report local-artifact-directory; the fingerprint identifies the validated model bundle. See the model card and data contract for the evidence and data contracts.

Development

git clone https://github.com/appeler/naampy.git
cd naampy
uv sync --all-groups
make test
make lint
make docs
make build

Naampy is released under the MIT license. The data and artifact manifests state their separate source terms and provenance.

Download files

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

Source Distribution

naampy-0.11.0.tar.gz (85.9 kB view details)

Uploaded Source

Built Distribution

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

naampy-0.11.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file naampy-0.11.0.tar.gz.

File metadata

  • Download URL: naampy-0.11.0.tar.gz
  • Upload date:
  • Size: 85.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for naampy-0.11.0.tar.gz
Algorithm Hash digest
SHA256 2e3c90920210a057d68fc7e23aad66071c6d7b9b4c3a4355b149a3deb6a473d4
MD5 9f171f2c3523b9f49e35e94bf2d37358
BLAKE2b-256 c70ca43f44c7124c02b21f125fe77973b624117df87aa8e179aab57d88fcf77f

See more details on using hashes here.

Provenance

The following attestation bundles were made for naampy-0.11.0.tar.gz:

Publisher: release.yml on appeler/naampy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file naampy-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: naampy-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for naampy-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df1cfced124382ab247dd96cfc55c9ab9e5ca0ba8718a17a2f8d975befee1b8
MD5 dc3e979cbaa20f087a9b6b70e9f478a8
BLAKE2b-256 daa7d562025f649e5ad839d09da67a50e0def47ca5f06f6f72117d24cbdbb09d

See more details on using hashes here.

Provenance

The following attestation bundles were made for naampy-0.11.0-py3-none-any.whl:

Publisher: release.yml on appeler/naampy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 files

0.8.0

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.2

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page