-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- working preprocessing pipeline - working dataloader - trial of gridsearch
- Loading branch information
1 parent
ee85170
commit 7a9d41c
Showing
24 changed files
with
2,147 additions
and
8 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,345 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "initial_id", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:31:38.271391Z", | ||
"start_time": "2024-06-08T09:31:38.269256Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "849a22126f7029aa", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:31:43.483108Z", | ||
"start_time": "2024-06-08T09:31:43.480718Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"path = '/Users/jk1/Library/CloudStorage/OneDrive-unige.ch/stroke_research/geneva_stroke_unit_dataset/data/stroke_registry/post_hoc_modified/stroke_registry_post_hoc_modified.xlsx'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "4b4eb9f80c2168da", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:31:51.642087Z", | ||
"start_time": "2024-06-08T09:31:45.739450Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"df = pd.read_excel(path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "545fc6a9ebaebd43", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:31:51.673951Z", | ||
"start_time": "2024-06-08T09:31:51.644093Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"df.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8d41b4ef12dd5e77", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:32:49.358260Z", | ||
"start_time": "2024-06-08T09:32:49.353614Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"ich_df = df[df['Type of event'] == 'Intracerebral hemorrhage']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6e54c2946daff8b9", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:37:33.621971Z", | ||
"start_time": "2024-06-08T09:37:33.618054Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df = ich_df[(ich_df['GCS on admission'] < 15) & (ich_df['GCS on admission'] > 4) & (ich_df['NIH on admission'] > 5)]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "27ced1a91acbbdbe", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:37:37.180639Z", | ||
"start_time": "2024-06-08T09:37:37.176622Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df.shape" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9e9d1929af575eff", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:39:58.297972Z", | ||
"start_time": "2024-06-08T09:39:58.277700Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "c376e1959b791708", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:43:39.071640Z", | ||
"start_time": "2024-06-08T09:43:39.045643Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"cardiovascular_disease = ['MedHist Hypertension', 'MedHist Atrial Fibr.', 'MedHist CHD', 'MedHist Low ejection fract.', 'MedHist PAD']\n", | ||
"# if any is yes then 1\n", | ||
"restricted_ich_df['Cardiovascular disease'] = restricted_ich_df[cardiovascular_disease].apply(lambda x: 1 if 'yes' in x.str.lower().values else 0, axis=1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1ff6a75647795a2e", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:43:47.655733Z", | ||
"start_time": "2024-06-08T09:43:47.650299Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['Cardiovascular disease'].value_counts(normalize=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8d28806a743c04", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:44:23.163803Z", | ||
"start_time": "2024-06-08T09:44:23.158016Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['MedHist Smoking'].value_counts(normalize=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6d2369e02258a2d8", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:39:15.940176Z", | ||
"start_time": "2024-06-08T09:39:15.935400Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# now with percenteges\n", | ||
"restricted_ich_df['Prestroke disability (Rankin)'].value_counts(normalize=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "43ed70a1cae265ff", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:49:56.235548Z", | ||
"start_time": "2024-06-08T09:49:56.200849Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['onset_date_time'] = pd.to_datetime(restricted_ich_df['Onset date'],\n", | ||
" format='%Y%m%d').dt.strftime('%d.%m.%Y') + ' ' + \\\n", | ||
" pd.to_datetime(restricted_ich_df['Onset time'], format='%H:%M',\n", | ||
" infer_datetime_format=True).dt.strftime('%H:%M')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e3adb50cb03e64df", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:50:38.570257Z", | ||
"start_time": "2024-06-08T09:50:38.560646Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['image_date_time'] = pd.to_datetime(restricted_ich_df['1st brain imaging date'],\n", | ||
" format='%Y%m%d').dt.strftime('%d.%m.%Y') + ' ' + \\\n", | ||
" pd.to_datetime(restricted_ich_df['1st brain imaging time'], format='%H:%M',\n", | ||
" infer_datetime_format=True).dt.strftime('%H:%M')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "996b3fdf5bc7229e", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:50:55.662336Z", | ||
"start_time": "2024-06-08T09:50:55.655262Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['onest_to_image'] = pd.to_datetime(restricted_ich_df['image_date_time'], format='%d.%m.%Y %H:%M') - \\\n", | ||
" pd.to_datetime(restricted_ich_df['onset_date_time'], format='%d.%m.%Y %H:%M')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9e9a7b1c5349f7e9", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:50:59.509073Z", | ||
"start_time": "2024-06-08T09:50:59.500323Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['onest_to_image'].describe()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e2e74ce32473c31e", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:54:06.861381Z", | ||
"start_time": "2024-06-08T09:54:06.855845Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# restricted_ich_df['GCS on admission'] categories into 4-8 and 9-14\n", | ||
"restricted_ich_df['GCS_4_8'] = restricted_ich_df['GCS on admission'].apply(lambda x: 1 if 4 <= x <= 8 else 0)\n", | ||
"restricted_ich_df['GCS_9_14'] = restricted_ich_df['GCS on admission'].apply(lambda x: 1 if 9 <= x <= 14 else 0)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "451f84bb2fe9f6e4", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:54:12.085391Z", | ||
"start_time": "2024-06-08T09:54:12.080386Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['GCS_4_8'].value_counts(normalize=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "54122428c7f5937b", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:54:17.381812Z", | ||
"start_time": "2024-06-08T09:54:17.376348Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['GCS_9_14'].value_counts(normalize=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "cd12e7be02bb5b0", | ||
"metadata": { | ||
"ExecuteTime": { | ||
"end_time": "2024-06-08T09:55:30.013696Z", | ||
"start_time": "2024-06-08T09:55:30.006481Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"restricted_ich_df['NIH on admission'].describe()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b257516d677011ec", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.