probabilistic-symptom-graph


Nameprobabilistic-symptom-graph JSON
Version 1.0.3 PyPI version JSON
download
home_page
SummaryUsing a bipartite graph of medical conditions and symptoms with relative weighted edges, gives the estimated probability of having each illness given a list of symptoms
upload_time2023-11-15 01:29:46
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2022 Bart Gebka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords graph medicine healthcare prediction probability
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Probabilistic Symptom Graph

```bash
pip install probabilistic-symptom-graph
```

```py
from src.ProbabilisticSymptomGraph import ProbabilisticSymptomConditionGraph

import networkx as nx
import numpy as np

medical_condition_gexf = "./data/medical-condition-symptom-graph.gexf"
graph = nx.read_gexf(medical_condition_gexf)
sim_matrix = np.load('./data/md-symptom-sim-mat.npy')

symptom_names = []
for node_id, tpe in graph.nodes(data="type"):
    if tpe == "Symptom":
        symptom_names.append(node_id)
symptom_names = sorted(symptom_names)

condition_names = []
for node_id, tpe in graph.nodes(data="type"):
    if tpe == "MedicalCondition":
        condition_names.append(node_id)
condition_names = sorted(condition_names)

probabilistic_graph = ProbabilisticSymptomConditionGraph(condition_names, symptom_names, graph, sim_matrix)
print(" | ".join(probabilistic_graph.get_all_symptoms()[:10]))
probabilistic_graph.get_condition_probs(["acne"])[:5]
```

## Graph Image
Red nodes represent medical conditions and green nodes represent symptoms.
![image](https://github.com/bart1259/ProbabilisticSymptomGraph/assets/21147581/1f693ddf-20d8-4320-9265-a84a3403a5eb)
This graph data was gathered by mining Wikipedia "Medical Condition (New)" infoboxes and extracting medical condition <=> Symptom pairs. Post processing was done using ChatGPT.

## Data Mining
See `./data/WikipediaSymptomExtractor.ipynb`

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "probabilistic-symptom-graph",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "graph,medicine,healthcare,prediction,probability",
    "author": "",
    "author_email": "Bart Gebka <bartg1259@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8d/45/b7542d976f10ce4a17d285e3b1e432580f0115807a37688e321fa17e91f7/probabilistic-symptom-graph-1.0.3.tar.gz",
    "platform": null,
    "description": "# Probabilistic Symptom Graph\r\n\r\n```bash\r\npip install probabilistic-symptom-graph\r\n```\r\n\r\n```py\r\nfrom src.ProbabilisticSymptomGraph import ProbabilisticSymptomConditionGraph\r\n\r\nimport networkx as nx\r\nimport numpy as np\r\n\r\nmedical_condition_gexf = \"./data/medical-condition-symptom-graph.gexf\"\r\ngraph = nx.read_gexf(medical_condition_gexf)\r\nsim_matrix = np.load('./data/md-symptom-sim-mat.npy')\r\n\r\nsymptom_names = []\r\nfor node_id, tpe in graph.nodes(data=\"type\"):\r\n    if tpe == \"Symptom\":\r\n        symptom_names.append(node_id)\r\nsymptom_names = sorted(symptom_names)\r\n\r\ncondition_names = []\r\nfor node_id, tpe in graph.nodes(data=\"type\"):\r\n    if tpe == \"MedicalCondition\":\r\n        condition_names.append(node_id)\r\ncondition_names = sorted(condition_names)\r\n\r\nprobabilistic_graph = ProbabilisticSymptomConditionGraph(condition_names, symptom_names, graph, sim_matrix)\r\nprint(\" | \".join(probabilistic_graph.get_all_symptoms()[:10]))\r\nprobabilistic_graph.get_condition_probs([\"acne\"])[:5]\r\n```\r\n\r\n## Graph Image\r\nRed nodes represent medical conditions and green nodes represent symptoms.\r\n![image](https://github.com/bart1259/ProbabilisticSymptomGraph/assets/21147581/1f693ddf-20d8-4320-9265-a84a3403a5eb)\r\nThis graph data was gathered by mining Wikipedia \"Medical Condition (New)\" infoboxes and extracting medical condition <=> Symptom pairs. Post processing was done using ChatGPT.\r\n\r\n## Data Mining\r\nSee `./data/WikipediaSymptomExtractor.ipynb`\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Bart Gebka  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Using a bipartite graph of medical conditions and symptoms with relative weighted edges, gives the estimated probability of having each illness given a list of symptoms",
    "version": "1.0.3",
    "project_urls": null,
    "split_keywords": [
        "graph",
        "medicine",
        "healthcare",
        "prediction",
        "probability"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0c09bcaff60982a33defaedc871d813279feea1c2f3f2a24179c3b751caea16",
                "md5": "222c45ebd799b9a913fd5000564b4d5a",
                "sha256": "b18d9c6da5d3c1ae11ac5f07877ea42a114d14055af7546e6157a70ee42d5881"
            },
            "downloads": -1,
            "filename": "probabilistic_symptom_graph-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "222c45ebd799b9a913fd5000564b4d5a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4962,
            "upload_time": "2023-11-15T01:29:43",
            "upload_time_iso_8601": "2023-11-15T01:29:43.878481Z",
            "url": "https://files.pythonhosted.org/packages/f0/c0/9bcaff60982a33defaedc871d813279feea1c2f3f2a24179c3b751caea16/probabilistic_symptom_graph-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d45b7542d976f10ce4a17d285e3b1e432580f0115807a37688e321fa17e91f7",
                "md5": "34db3c15af82277f808edb1269163cb4",
                "sha256": "8ae051f049796daede0327cb3235fe0e1c4a03296843e1ee027aa24848888ac3"
            },
            "downloads": -1,
            "filename": "probabilistic-symptom-graph-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "34db3c15af82277f808edb1269163cb4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3861,
            "upload_time": "2023-11-15T01:29:46",
            "upload_time_iso_8601": "2023-11-15T01:29:46.257810Z",
            "url": "https://files.pythonhosted.org/packages/8d/45/b7542d976f10ce4a17d285e3b1e432580f0115807a37688e321fa17e91f7/probabilistic-symptom-graph-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-15 01:29:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "probabilistic-symptom-graph"
}
        
Elapsed time: 0.13952s