# Predictions sepsis
## Instruction
Predictions sepsis is a module based on pandas, torch, and scikit-learn that allows users to perform simple operations with the MIMIC dataset.
With this module, using just a few functions, you can train your model to predict whether some patients have certain diseases or not.
By default, the module is designed to train and predict sepsis.
The module also allows users to change different names of tables to aggregate data from.
### Installation
To install the module, use the following command:
```bash
pip install predictions-sepsis
```
or
```bash
pip3 install predictions-sepsis
```
### Usage
You can import functions from the module into your Python file to aggregate data from MIMIC,
fill empty spots, compress data between patients, and train your model.
### Examples
#### Aggregate patient diagnoses Data
```python
import predictions_sepsis as ps
ps.get_diagnoses(patient_diagnoses_csv='path_to_patient_diagnoses.csv',
all_diagnoses_csv='path_to_all_diagnoses.csv',
output_file_csv='gottenDiagnoses.csv')
```
#### Aggregate patient ssir Data
```python
import predictions_sepsis as ps
ps.get_ssir(chartevents_csv='chartevents.csv', subject_id_col='subject_id', itemid_col='itemid',
charttime_col='charttime', value_col='value', valuenum_col='valuenum', valueuom_col='valueuom',
itemids=None, rest_columns=None, output_csv='ssir.csv'):
```
#### Combine Diagnoses and SSIR Data
```python
import predictions_sepsis as ps
ps.combine_diagnoses_and_ssir(gotten_diagnoses_csv='gottenDiagnoses.csv',
ssir_csv='path_to_ssir.csv',
output_file='diagnoses_and_ssir.csv')
```
#### Aggregate patient blood analysis data from chartevents.csv and labevents.csv and combine it with diagnoses and SSIR Data
```python
import predictions_sepsis as ps
ps.merge_diagnoses_and_ssir_with_blood(diagnoses_and_ssir_csv='diagnoses_and_ssir.csv',
blood_csv='path_to_blood.csv',
chartevents_csv='path_to_chartevents.csv',
output_csv='merged_data.csv')
)
```
#### Compress Data by patient
```python
import predictions_sepsis as ps
ps.compress(df_to_compress='balanced_data.csv',
output_csv='compressed_data.csv')
```
#### Choose top non-sepsis patients to balance
```python
import predictions_sepsis as ps
ps.choose(compressed_df_csv='compressed_data.csv',
output_file='final_balanced_data.csv')
```
#### Fill missing values with mode
```python
import predictions_sepsis as ps
ps.fill_values(balanced_csv='final_balanced_data.csv',
strategy='most_frequent',
output_csv='filled_data.csv')
```
#### Aggregate patient diagnoses Data
```python
import predictions_sepsis as ps
# Aggregate diagnoses data
ps.get_diagnoses(patient_diagnoses_csv='path_to_patient_diagnoses.csv',
all_diagnoses_csv='path_to_all_diagnoses.csv',
output_file_csv='gottenDiagnoses.csv')
```
#### Train model
```python
import predictions_sepsis as ps
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import MinMaxScaler
model = ps.train_model(df_to_train_csv='filled_data.csv',
categorical_col=['Large Platelets'],
columns_to_train_on=['Amylase'],
model=RandomForestClassifier(),
single_cat_column='White Blood Cells',
has_disease_col='has_sepsis',
subject_id_col='subject_id',
valueuom_col='valueuom',
scaler=MinMaxScaler(),
random_state=42,
test_size=0.2)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/sslavian812/sepsis-predictions.git",
"name": "predictions-sepsis",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "sepsis, predictions, python",
"author": "@Margo78, @akp1n",
"author_email": "timtimk30@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/bb/47/5362654085e6ed91aded7c755c168a387e94bd6c32c02cfa84f7ff5d20b8/predictions_sepsis-1.0.4.tar.gz",
"platform": null,
"description": "# Predictions sepsis\n\n## Instruction\n\nPredictions sepsis is a module based on pandas, torch, and scikit-learn that allows users to perform simple operations with the MIMIC dataset.\nWith this module, using just a few functions, you can train your model to predict whether some patients have certain diseases or not. \nBy default, the module is designed to train and predict sepsis. \nThe module also allows users to change different names of tables to aggregate data from.\n\n### Installation\n\nTo install the module, use the following command:\n\n```bash\npip install predictions-sepsis\n```\nor\n```bash\npip3 install predictions-sepsis\n```\n### Usage\n\nYou can import functions from the module into your Python file to aggregate data from MIMIC, \nfill empty spots, compress data between patients, and train your model.\n\n### Examples\n\n#### Aggregate patient diagnoses Data\n```python\nimport predictions_sepsis as ps\n\nps.get_diagnoses(patient_diagnoses_csv='path_to_patient_diagnoses.csv', \n all_diagnoses_csv='path_to_all_diagnoses.csv',\n output_file_csv='gottenDiagnoses.csv')\n```\n\n#### Aggregate patient ssir Data\n```python\nimport predictions_sepsis as ps\n\nps.get_ssir(chartevents_csv='chartevents.csv', subject_id_col='subject_id', itemid_col='itemid',\n charttime_col='charttime', value_col='value', valuenum_col='valuenum', valueuom_col='valueuom',\n itemids=None, rest_columns=None, output_csv='ssir.csv'):\n```\n\n#### Combine Diagnoses and SSIR Data\n```python\nimport predictions_sepsis as ps\n\nps.combine_diagnoses_and_ssir(gotten_diagnoses_csv='gottenDiagnoses.csv', \n ssir_csv='path_to_ssir.csv',\n output_file='diagnoses_and_ssir.csv')\n```\n\n#### Aggregate patient blood analysis data from chartevents.csv and labevents.csv and combine it with diagnoses and SSIR Data\n```python\nimport predictions_sepsis as ps\n\nps.merge_diagnoses_and_ssir_with_blood(diagnoses_and_ssir_csv='diagnoses_and_ssir.csv', \n blood_csv='path_to_blood.csv',\n chartevents_csv='path_to_chartevents.csv',\n output_csv='merged_data.csv')\n)\n```\n\n#### Compress Data by patient\n```python\nimport predictions_sepsis as ps\n\nps.compress(df_to_compress='balanced_data.csv', \n output_csv='compressed_data.csv')\n\n```\n\n#### Choose top non-sepsis patients to balance\n```python\nimport predictions_sepsis as ps\n\nps.choose(compressed_df_csv='compressed_data.csv', \n output_file='final_balanced_data.csv')\n```\n\n#### Fill missing values with mode\n```python\nimport predictions_sepsis as ps\n\nps.fill_values(balanced_csv='final_balanced_data.csv', \n strategy='most_frequent', \n output_csv='filled_data.csv')\n```\n\n#### Aggregate patient diagnoses Data\n```python\nimport predictions_sepsis as ps\n\n# Aggregate diagnoses data\nps.get_diagnoses(patient_diagnoses_csv='path_to_patient_diagnoses.csv', \n all_diagnoses_csv='path_to_all_diagnoses.csv',\n output_file_csv='gottenDiagnoses.csv')\n```\n\n#### Train model\n```python\nimport predictions_sepsis as ps\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.preprocessing import MinMaxScaler\nmodel = ps.train_model(df_to_train_csv='filled_data.csv', \n categorical_col=['Large Platelets'], \n columns_to_train_on=['Amylase'], \n model=RandomForestClassifier(), \n single_cat_column='White Blood Cells', \n has_disease_col='has_sepsis', \n subject_id_col='subject_id', \n valueuom_col='valueuom', \n scaler=MinMaxScaler(), \n random_state=42, \n test_size=0.2)\n```\n\n\n\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Module for sepsis predictions",
"version": "1.0.4",
"project_urls": {
"Homepage": "https://github.com/sslavian812/sepsis-predictions.git"
},
"split_keywords": [
"sepsis",
" predictions",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "24ae9ea804a537326c7cc1254fe991bd9f4cc388f5b5f3b104d6763d664bf6ed",
"md5": "7ef2649404d781a008f270ada113299d",
"sha256": "cadfe4d0f17ee9eacd1dce2acc34698d02d76a9a20f7cd92fb530b7c63af9737"
},
"downloads": -1,
"filename": "predictions_sepsis-1.0.4-py2-none-any.whl",
"has_sig": false,
"md5_digest": "7ef2649404d781a008f270ada113299d",
"packagetype": "bdist_wheel",
"python_version": "py2",
"requires_python": ">=3.7",
"size": 16914,
"upload_time": "2024-05-31T17:03:25",
"upload_time_iso_8601": "2024-05-31T17:03:25.168252Z",
"url": "https://files.pythonhosted.org/packages/24/ae/9ea804a537326c7cc1254fe991bd9f4cc388f5b5f3b104d6763d664bf6ed/predictions_sepsis-1.0.4-py2-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bb475362654085e6ed91aded7c755c168a387e94bd6c32c02cfa84f7ff5d20b8",
"md5": "0534dafc0eb1a960e0463059b6ad4c70",
"sha256": "857127be7106f7404d50d7e571fad76ded6e4df66faefdabab1cfb86f2ad9d37"
},
"downloads": -1,
"filename": "predictions_sepsis-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "0534dafc0eb1a960e0463059b6ad4c70",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11547,
"upload_time": "2024-05-31T17:03:26",
"upload_time_iso_8601": "2024-05-31T17:03:26.976052Z",
"url": "https://files.pythonhosted.org/packages/bb/47/5362654085e6ed91aded7c755c168a387e94bd6c32c02cfa84f7ff5d20b8/predictions_sepsis-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-31 17:03:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sslavian812",
"github_project": "sepsis-predictions",
"github_not_found": true,
"lcname": "predictions-sepsis"
}