Skip to main content

medkit

medkit logo

CI docs status pre-commit status test: status
Package PyPI version PyPI Python versions
Project License: MIT Formatter: Ruff Project: Hatch

medkit is a toolkit for a learning health system, developed by the HeKA research team.

This python library aims at:

  1. Facilitating the manipulation of healthcare data of various modalities (e.g., structured, text, audio data) for the extraction of relevant features.

  2. Developing supervised models from these various modalities for decision support in healthcare.

Installation

To install medkit with basic functionalities:

pip install medkit-lib

To install medkit with all its optional features:

pip install 'medkit-lib[all]'

Example

A basic named-entity recognition pipeline using medkit:

# 1. Define individual operations.
from medkit.text.preprocessing import CharReplacer, LIGATURE_RULES, SIGN_RULES
from medkit.text.segmentation import SentenceTokenizer, SyntagmaTokenizer
from medkit.text.context.negation_detector import NegationDetector
from medkit.text.ner.hf_entity_matcher import HFEntityMatcher

# Preprocessing
char_replacer = CharReplacer(rules=LIGATURE_RULES + SIGN_RULES)
# Segmentation
sent_tokenizer = SentenceTokenizer(output_label="sentence")
synt_tokenizer = SyntagmaTokenizer(output_label="syntagma")
# Negation detection
neg_detector = NegationDetector(output_label="is_negated")
# Entity recognition
entity_matcher = HFEntityMatcher(model="my-BERT-model", attrs_to_copy=["is_negated"])

# 2. Combine operations into a pipeline.
from medkit.core.pipeline import Pipeline, PipelineStep

ner_pipeline = Pipeline(
    input_keys=["full_text"],
    output_keys=["entities"],
    steps=[
        PipelineStep(char_replacer, input_keys=["full_text"], output_keys=["clean_text"]),
        PipelineStep(sent_tokenizer, input_keys=["clean_text"], output_keys=["sentences"]),
        PipelineStep(synt_tokenizer, input_keys=["sentences"], output_keys=["syntagmas"]),
        PipelineStep(neg_detector, input_keys=["syntagmas"], output_keys=[]),
        PipelineStep(entity_matcher, input_keys=["syntagmas"], output_keys=["entities"]),
    ],
)

# 3. Run the NER pipeline on a BRAT document.
from medkit.io import BratInputConverter

docs = BratInputConverter().load(path="/path/to/dataset/")
entities = ner_pipeline.run([doc.raw_segment for doc in docs])

Getting started

To get started with medkit, please checkout our documentation.

This documentation also contains tutorials and examples showcasing the use of medkit for different tasks.

Contributing

Thank you for your interest into medkit !

We'll be happy to get your inputs !

If your problem has not been reported by another user, please open an issue, whether it's for:

  • reporting a bug,
  • discussing the current state of the code,
  • submitting a fix,
  • proposing new features,
  • or contributing to documentation, ...

If you want to propose a pull request, you can read CONTRIBUTING.md.

Contact

Feel free to contact us by sending an email to medkit-maintainers@inria.fr.

Metadata

Release files for medkit-lib 0.17.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 medkit-lib 0.17.0
File Size Uploaded
medkit_lib-0.17.0.tar.gz 6.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for medkit-lib 0.17.0
File Interpreter ABI Platform
medkit_lib-0.17.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 MB

Release files / medkit_lib-0.17.0.tar.gz

Download URL medkit_lib-0.17.0.tar.gz
Size 6.3 MB
Tags Source
SHA-256 checksum
How to use checksums
ae8a256e7f9f4d9e135e2e2e7bc31f7baf7f8ecb05488440d83c5ccb1bd04ec5
BLAKE2b-256 checksum
How to use checksums
d83a1a2a4e97b4145553a663def10394ca3e07a104346e94b28a6394f05d1c06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2025.

Transparency log

Release files / medkit_lib-0.17.0-py3-none-any.whl

Download URL medkit_lib-0.17.0-py3-none-any.whl
Size 286.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cedc75e900731fda7b83cd048b6ee0508f5e296a5720cd41647f0f22a5347ad2
BLAKE2b-256 checksum
How to use checksums
7a49d2987379e77f0447070bedc8342870fc751ae0bba25a870e6aaf79b7791c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.17.0 This release

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.1

2 release files

0.12.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

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