Skip to main content

FHIR Terminology Encoder

This is a scikit-learn compatible encoder that uses a FHIR terminology server to encode ontological features.

It currently supports subsumption relationships and properties.

You supply a scope in the form of a FHIR ValueSet URI, and a FHIR terminology endpoint.

The result is a multi-hot encoded vector delivered as a sparse matrix, suitable for input into most models and estimators.

Installation

pip install fhir-tx-encoder

Usage

from fhir_tx import FhirTerminologyEncoder
import numpy as np

encoder = FhirTerminologyEncoder(
    # Ancestors of the SNOMED CT concept "Malignant neoplastic disease" (363346000)
    scope="http://snomed.info/sct?fhir_vs=ecl/(%3E%3E%20363346000)",
    # Include "Associated morphology" (116676008) as a property
    properties=["116676008"]
)

# Encode two SNOMED CT concepts:
# - "Neoplasm and/or hamartoma" (399981008)
# - "Malignant neoplastic disease" (363346000)
result = encoder.fit_transform(np.array([["399981008", "363346000"]]))

# Print out the result and its shape.
print(f"result.shape: {result.shape}")
print(f"result:\n{result.toarray()}")

# Print out the feature names.
print(f"encoder.feature_names_: {encoder.feature_names_}")

Which would output:

Expanding value set: http://snomed.info/sct?fhir_vs=ecl/(%3E%3E%20363346000)
Expanding (6 items, offset 0, total 6)
Expansion complete
Generating one-hot encoding... (6, 6)
Creating index... 6 items
Applying transitive closure...
Batch 1 of 1, 6 items... 15 pairs added
Subsumption encoding complete: (6, 6)
Encoding properties... (6, 9)
result.shape: (2, 9)
result:
[[1. 1. 0. 1. 0. 1. 0. 0. 1.]
 [1. 1. 1. 1. 1. 1. 0. 1. 0.]]
encoder.feature_names_: ['404684003', '64572001', '363346000', '399981008', '55342001', '138875005', '609096000.116676008=108369006', '609096000.116676008=1240414004', '609096000.116676008=400177003']

Important note

This software is currently in alpha. It is not yet ready for production use.

Copyright © 2023, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. Licensed under the Apache License, version 2.0.

Metadata

Release files for fhir-tx-encoder 1.1.0

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

Source distribution (sdist)

Source distribution for fhir-tx-encoder 1.1.0
File Size Uploaded Provenance Actions
fhir_tx_encoder-1.1.0.tar.gz 10.3 kB Without provenance Details for fhir_tx_encoder-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fhir-tx-encoder 1.1.0
File Interpreter ABI Platform Actions
fhir_tx_encoder-1.1.0-py3-none-any.whl Python 3 none any Details for fhir_tx_encoder-1.1.0-py3-none-any.whl

Total release size: 22.5 kB

Release files / fhir_tx_encoder-1.1.0.tar.gz

Download URL fhir_tx_encoder-1.1.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
623fcad188a489d200635650d6e3a264a7d363fac5f47c36686d40e0cf7f2a85
BLAKE2b-256 checksum
How to use checksums
08adcd90bc48085d090390d3e291918ab403a28818f5a89762d10183fe63cd90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / fhir_tx_encoder-1.1.0-py3-none-any.whl

Download URL fhir_tx_encoder-1.1.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29516429b036336074b99e632203214ad44940c223b85d9d9c38df0f884f4fbb
BLAKE2b-256 checksum
How to use checksums
33a00eb55a7e173a002b812d29c03387c7f14ed1e2e38dbeaeb84c4fa9bfab04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Security for fhir-tx-encoder 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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