Diagnostipy
Table of Contents
About The Project
Diagnostipy is a open-source, Python library for rule-based diagnosis and evaluation. It allows users to define rules with conditions and weights, manage rulesets, and evaluate input data using customizable scoring and confidence functions.
Features
- Define rules using
SymptomRulewith customizable conditions, weights, and criticality. - Manage collections of rules via
SymptomRuleset. - Evaluate data using built-in or custom scoring and confidence functions with
Evaluator. - Flexible and extensible API.
When Should I Use Diagnostipy?
- When interpretability is more important than accuracy, and you need a clear, rules-based system to explain decision-making
- If you lack access to large datasets for training machine learning models but still require a structured evaluation or diagnostic tool
- When collaborating with domain experts to formalize diagnostic or evaluation criteria without a data-driven approach
- When working in regulated industries or domains where decisions must be auditable and transparent
- For quick prototyping of logic-based systems without the overhead of complex data pipelines
Getting Started
To get a local copy up and running, follow these steps.
Prerequisites
- Python 3.10 or later
Installation
Install Diagnostipy using pip:
pip install diagnostipy
Usage
Define Rules
from diagnostipy.core.models.symptom_rule import SymptomRule
rule_high_fever = SymptomRule(
name="High Fever",
weight=6.0,
critical=True,
apply_condition=lambda data: data.get("temperature", 0) >= 39,
)
rule_cough = SymptomRule(
name="Persistent Cough",
weight=4.0,
critical=False,
apply_condition=lambda data: data.get("cough", False),
)
rule_sore_throat = SymptomRule(
name="Sore Throat",
weight=5.0,
critical=True,
apply_condition=lambda data: data.get("sore_throat", False),
)
Create Ruleset
from diagnostipy import SymptomRuleset
ruleset = SymptomRuleset([rule_high_fever, rule_cough, rule_sore_throat])
Evaluate data
from diagnostipy import Evaluator
data = {
"temperature": 39.5,
"cough": True,
"sore_throat": False,
}
evaluator = Evaluator(ruleset)
results = evaluator.run(data=data)
print(results)
total_score=10.0 label='High' confidence=0.8333333333333334 metadata=None
Explanation of Output:
-
total_score: Sum of weights from applicable rules based on the input data. Here,6.0 (High Fever)+4.0 (Persistent Cough)=10.0. -
label: Categorical result based on total_score (e.g., 'Low', 'High'). Determined by the evaluation function used. -
confidence: A measure of certainty about the evaluation result, computed based on the logic defined in theconfidence_functionparameter when creating theEvaluator
Roadmap
- Add support for more built-in confidence functions.
- Improve error handling.
- Expand the API to include more user-friendly options.
Contributing
We are open to, and grateful for, any contributions made by the community.
A huge thank you to all the contributors.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/some-feature) - Commit your Changes (
git commit -m 'Add some feature') - Push to the Branch (
git push origin feature/some-feature) - Open a Pull Request
Top contributors:
License
Diagnostipy is distributed under the MIT License.
Metadata
Release files for diagnostipy 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diagnostipy-0.1.2.tar.gz | 11.8 kB | Without provenance | Details for diagnostipy-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diagnostipy-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for diagnostipy-0.1.2-py3-none-any.whl |
Total release size: 25.7 kB
Release files / diagnostipy-0.1.2.tar.gz
| Download URL | diagnostipy-0.1.2.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93b55ee9cbb31332fb4a62fd8febcc81c584da7e8de683c2c8b72781089d60cc
|
|
BLAKE2b-256 checksum How to use checksums |
efabe950abcf947c57ba98b4b5cf65df520def1c0bd5ebd34ecc5bc3104c8f1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-47-generic
|
Release files / diagnostipy-0.1.2-py3-none-any.whl
| Download URL | diagnostipy-0.1.2-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30dce613fa2a07c0a58c9b2cf9fb272e89b866239cdfddb8ffa82e1af9959b88
|
|
BLAKE2b-256 checksum How to use checksums |
e2a6684818d82aca4615c38a859f3494073cd0ebfecd8ff792528f3a892e2431
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-47-generic
|
Security for diagnostipy 0.1.2
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.