{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Published on July 27, 2023. By Marília Prata, mpwolke.","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-07-27T23:20:13.868238Z","iopub.execute_input":"2023-07-27T23:20:13.868648Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Abdominal Trauma\n\nFrequency, causes and pattern of abdominal trauma: A 4-year descriptive analysis\n\nAuthors: Suresh Arumugam, Ammar Al-Hassani, Ayman El-Menyar, Husham Abdelrahman, Ashok Parchani, Ruben Peralta, Ahmad Zarour, and Hassan Al-Thani\n\nJ Emerg Trauma Shock. 2015 Oct-Dec; 8(4): 193–198.\ndoi: 10.4103/0974-2700.166590\n\n\"A total of 6888 trauma patients were admitted to the hospital, of which 1036 (15%) had abdominal trauma. The mean age was 30.6 ± 13 years and the majority was males (93%). Road traffic accidents (61%) were the most frequent mechanism of injury followed by fall from height (25%) and fall of heavy object (7%). The mean ISS (Injury Severity Score) was 17.9 ± 10. Liver (36%), spleen (32%) and kidney (18%) were most common injured organs.\"\n\n\"The common associated extra-abdominal injuries included chest (35%), musculoskeletal (32%), and head injury (24%). Wound infection (3.8%), pneumonia (3%), and urinary tract infection (1.4%) were the frequently observed complications. The overall mortality was 8.3% and late mortality was observed in 2.3% cases mainly due to severe head injury and sepsis. The predictors of mortality were head injury, ISS (Injury Severity Score), need for blood transfusion, and serum lactate.\"\n\n\"The majority of abdominal injury patients sustained blunt trauma (95%) and only 5% had penetrating injuries. MVCs were the most frequent mechanism of injury (61%) followed by fall from height (25%) and fall of heavy object (7%). The penetrating abdominal trauma was mainly due to stab (4.5%) wounds.\"\n\nhttps://www.ncbi.nlm.nih.gov/pmc/articles/PMC4626935/#:~:text=The%20majority%20of%20abdominal%20injury,to%20stab%20(4.5%25)%20wounds.","metadata":{}},{"cell_type":"markdown","source":"![](https://cochranechild.files.wordpress.com/2016/11/week-13-blogshot.jpg)https://cochranechild.wordpress.com/2016/11/28/emergency-ultrasound-based-algorithms-for-diagnosing-blunt-abdominal-trauma/","metadata":{}},{"cell_type":"code","source":"import seaborn as sns\nfrom sklearn import feature_extraction, linear_model, model_selection, preprocessing\nimport plotly.graph_objs as go\nimport plotly.offline as py\nimport plotly.express as px\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:21:15.460978Z","iopub.execute_input":"2023-07-27T23:21:15.461368Z","iopub.status.idle":"2023-07-27T23:21:17.201618Z","shell.execute_reply.started":"2023-07-27T23:21:15.461336Z","shell.execute_reply":"2023-07-27T23:21:17.200494Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Michael Beregov https://www.kaggle.com/code/boojum/connecting-voxel-spaces\n\nimport os\nimport sys \nfrom tqdm import tqdm\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom PIL import Image\nimport pydicom\n\nimport numpy as np\nimport nibabel as nib\nimport matplotlib.pyplot as plt\nimport SimpleITK as sitk\n\ntrain_path = '../input/rsna-2023-abdominal-trauma-detection/train_images/'","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:21:20.931058Z","iopub.execute_input":"2023-07-27T23:21:20.931418Z","iopub.status.idle":"2023-07-27T23:21:21.618062Z","shell.execute_reply.started":"2023-07-27T23:21:20.931391Z","shell.execute_reply":"2023-07-27T23:21:21.616966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dirs = os.listdir(train_path)","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:21:27.196247Z","iopub.execute_input":"2023-07-27T23:21:27.196635Z","iopub.status.idle":"2023-07-27T23:21:27.296473Z","shell.execute_reply.started":"2023-07-27T23:21:27.196604Z","shell.execute_reply":"2023-07-27T23:21:27.29551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Print the 5 first Dcm filenames","metadata":{}},{"cell_type":"code","source":"# Print out the first 5 file names to verify we're in the right folder.\nprint (f'Total of {len(train_dirs)} DICOM images.\\nFirst 5 filenames:' )\ntrain_dirs[:5]","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:21:31.580832Z","iopub.execute_input":"2023-07-27T23:21:31.581218Z","iopub.status.idle":"2023-07-27T23:21:31.589591Z","shell.execute_reply.started":"2023-07-27T23:21:31.58119Z","shell.execute_reply":"2023-07-27T23:21:31.588462Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Michael Beregov https://www.kaggle.com/code/boojum/connecting-voxel-spaces\n\nplt.figure(figsize=(14,7))\nplt.subplot(121)\nplt.imshow(pydicom.dcmread(f'{train_path + train_dirs[0]}/22032/12.dcm').pixel_array)\n\nplt.subplot(122)\nplt.imshow(pydicom.dcmread(f'{train_path + train_dirs[0]}/22032/141.dcm').pixel_array);","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:24:48.42392Z","iopub.execute_input":"2023-07-27T23:24:48.424333Z","iopub.status.idle":"2023-07-27T23:24:49.12712Z","shell.execute_reply.started":"2023-07-27T23:24:48.424303Z","shell.execute_reply":"2023-07-27T23:24:49.126204Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/rsna-2023-abdominal-trauma-detection/train.csv\")\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:04:53.971436Z","iopub.execute_input":"2023-07-28T00:04:53.972203Z","iopub.status.idle":"2023-07-28T00:04:53.996804Z","shell.execute_reply.started":"2023-07-28T00:04:53.972168Z","shell.execute_reply":"2023-07-28T00:04:53.995633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels = pd.read_csv(\"/kaggle/input/rsna-2023-abdominal-trauma-detection/image_level_labels.csv\")\nlabels.head()","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:39:30.441259Z","iopub.execute_input":"2023-07-27T23:39:30.442339Z","iopub.status.idle":"2023-07-27T23:39:30.466219Z","shell.execute_reply.started":"2023-07-27T23:39:30.442291Z","shell.execute_reply":"2023-07-27T23:39:30.465382Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels[\"injury_name\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:39:35.732365Z","iopub.execute_input":"2023-07-27T23:39:35.732729Z","iopub.status.idle":"2023-07-27T23:39:35.742115Z","shell.execute_reply.started":"2023-07-27T23:39:35.732702Z","shell.execute_reply":"2023-07-27T23:39:35.740805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"meta = pd.read_csv(\"/kaggle/input/rsna-2023-abdominal-trauma-detection/train_series_meta.csv\")\nmeta.head()","metadata":{"execution":{"iopub.status.busy":"2023-07-27T22:47:26.550535Z","iopub.execute_input":"2023-07-27T22:47:26.551053Z","iopub.status.idle":"2023-07-27T22:47:26.576803Z","shell.execute_reply.started":"2023-07-27T22:47:26.551011Z","shell.execute_reply":"2023-07-27T22:47:26.575544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Parquet ","metadata":{}},{"cell_type":"code","source":"import dask.dataframe as dd\nimport dask.array as da\nfrom dask.diagnostics import ProgressBar","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:25:43.703197Z","iopub.execute_input":"2023-07-27T23:25:43.703631Z","iopub.status.idle":"2023-07-27T23:25:44.209123Z","shell.execute_reply.started":"2023-07-27T23:25:43.7036Z","shell.execute_reply":"2023-07-27T23:25:44.208014Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf = dd.read_parquet(\"/kaggle/input/rsna-2023-abdominal-trauma-detection/train_dicom_tags.parquet\")","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:25:48.235859Z","iopub.execute_input":"2023-07-27T23:25:48.236265Z","iopub.status.idle":"2023-07-27T23:25:48.544836Z","shell.execute_reply.started":"2023-07-27T23:25:48.236232Z","shell.execute_reply":"2023-07-27T23:25:48.543716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nlen(ddf)","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:25:53.54748Z","iopub.execute_input":"2023-07-27T23:25:53.548442Z","iopub.status.idle":"2023-07-27T23:25:53.987951Z","shell.execute_reply.started":"2023-07-27T23:25:53.548404Z","shell.execute_reply":"2023-07-27T23:25:53.987049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf.head()\n#pd.set_option('display.max_columns', None) #I ran with that then comment to get all columns","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:27:31.331076Z","iopub.execute_input":"2023-07-27T23:27:31.33146Z","iopub.status.idle":"2023-07-27T23:27:38.097404Z","shell.execute_reply.started":"2023-07-27T23:27:31.331431Z","shell.execute_reply":"2023-07-27T23:27:38.096291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ddf.WindowCenter.describe().compute()","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:03:30.988085Z","iopub.execute_input":"2023-07-27T23:03:30.988551Z","iopub.status.idle":"2023-07-27T23:03:31.14049Z","shell.execute_reply.started":"2023-07-27T23:03:30.988503Z","shell.execute_reply":"2023-07-27T23:03:31.139174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Rob Mulla https://www.kaggle.com/code/robikscube/sign-language-recognition-eda-twitch-stream\n\nfig, ax = plt.subplots(figsize=(4, 4))\nlabels[\"injury_name\"].value_counts().head(3).sort_values(ascending=True).plot(\n    kind=\"barh\", color='r', ax=ax, title=\"Abdomen Injury Trauma\"\n)\nax.set_xlabel(\"Number of Training Examples\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-27T23:57:34.934077Z","iopub.execute_input":"2023-07-27T23:57:34.934737Z","iopub.status.idle":"2023-07-27T23:57:35.142825Z","shell.execute_reply.started":"2023-07-27T23:57:34.934703Z","shell.execute_reply":"2023-07-27T23:57:35.141623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://www.kaggle.com/code/luxcem/dask-on-large-parquet-dataset/notebook\n\nddf.where(ddf.WindowCenter > 50).visualize()","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:04:39.240611Z","iopub.execute_input":"2023-07-27T23:04:39.241154Z","iopub.status.idle":"2023-07-27T23:04:40.550103Z","shell.execute_reply.started":"2023-07-27T23:04:39.24111Z","shell.execute_reply":"2023-07-27T23:04:40.548824Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://www.kaggle.com/code/luxcem/dask-on-large-parquet-dataset/notebook\n\nh, bins = da.histogram(ddf[[\"WindowCenter\"]].to_dask_array(), bins=(0, 1, 2, 5, 10, 20, 50, 100, 1000))","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:05:34.556106Z","iopub.execute_input":"2023-07-27T23:05:34.556694Z","iopub.status.idle":"2023-07-27T23:05:34.574653Z","shell.execute_reply.started":"2023-07-27T23:05:34.556551Z","shell.execute_reply":"2023-07-27T23:05:34.572844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with ProgressBar():\n    hd = h.compute()\n    bins = bins.compute()","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:05:50.458876Z","iopub.execute_input":"2023-07-27T23:05:50.460127Z","iopub.status.idle":"2023-07-27T23:06:00.046987Z","shell.execute_reply.started":"2023-07-27T23:05:50.460077Z","shell.execute_reply":"2023-07-27T23:06:00.04531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://www.kaggle.com/code/luxcem/dask-on-large-parquet-dataset/notebook\n\nplt.style.use('fivethirtyeight')\n\nsns.barplot(x=bins[1:], y=hd)\nplt.title('WindowCenter');","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:07:33.475962Z","iopub.execute_input":"2023-07-27T23:07:33.476401Z","iopub.status.idle":"2023-07-27T23:07:33.803496Z","shell.execute_reply.started":"2023-07-27T23:07:33.476364Z","shell.execute_reply":"2023-07-27T23:07:33.80198Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#https://www.kaggle.com/code/luxcem/dask-on-large-parquet-dataset/notebook\n\nwith ProgressBar():\n    sns.scatterplot(data=ddf, x=\"ImplementationVersionName\", y=\"PhotometricInterpretation\")\n    plt.ylim(0, 50)","metadata":{"execution":{"iopub.status.busy":"2023-07-27T23:30:22.086204Z","iopub.execute_input":"2023-07-27T23:30:22.087091Z","iopub.status.idle":"2023-07-27T23:30:28.69614Z","shell.execute_reply.started":"2023-07-27T23:30:22.087051Z","shell.execute_reply":"2023-07-27T23:30:28.69501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#UpSetPlot\n\n\"UpSetPlot is another Python implementation of UpSet plots by Lex et al. [Lex2014]. UpSet plots are used to visualise set overlaps; like Venn diagrams but more readable.\"\n\nAlexander Lex, Nils Gehlenborg, Hendrik Strobelt, Romain Vuillemot, Hanspeter Pfister, UpSet: Visualization of Intersecting Sets, IEEE Transactions on Visualization and Computer Graphics (InfoVis ‘14), vol. 20, no. 12, pp. 1983–1992, 2014. doi: doi.org/10.1109/TVCG.2014.2346248\n\nhttps://upsetplot.readthedocs.io.","metadata":{}},{"cell_type":"code","source":"!pip install upsetplot\nimport matplotlib.pyplot as plt\nimport upsetplot as upsplt\n\nplt.style.use(\"fast\")","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:02:38.208539Z","iopub.execute_input":"2023-07-28T00:02:38.208983Z","iopub.status.idle":"2023-07-28T00:02:54.91553Z","shell.execute_reply.started":"2023-07-28T00:02:38.208944Z","shell.execute_reply":"2023-07-28T00:02:54.914305Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Kheirallah Samaha https://www.kaggle.com/code/khsamaha/xgboost-classification-of-machine-failures-py\n\nmean_extravasation = train[[\"extravasation_injury\"]].mean().squeeze()\n\nsns.set_context(\"paper\",font_scale = .8)\nsns.set_style(rc = {'axes.facecolor': '#DFEDEE', \"axes.labelcolor\": \"darkblue\"})\nfig, (ax1, ax2) = plt.subplots(2, figsize=(9, 7))\n\nsns.histplot(\n    data=train, x=\"extravasation_injury\", color=\"#62AAC6\", bins=40, alpha=0.8, lw=0.1, ax=ax1\n)\n\nsns.boxplot(\n    data=train,\n    x=\"extravasation_injury\",\n    color=\"#62AAC6\",\n    linewidth=0.7,\n    flierprops=dict(\n        marker=\"o\", markersize=4, markerfacecolor=\"#107dac\", markeredgecolor=\"#107dac\"\n    ),\n    boxprops=dict(alpha=0.8),\n    ax=ax2,\n)\nax2.set_title(\"\")#It had overlapped with the other title, then don't write it\nax2.set_xlabel(\"extravasation_injury\", fontsize=12)\n\nax1.set_title(\"Extravasation Injury Distribution\", fontsize=12)\nax1.set_xlabel(\"Extravasation Injury\")\n\nax1.axvline(x=mean_extravasation, color=\"darkred\", ls=\"--\", lw=1.5)\nax1.text(\n    mean_extravasation + 1,\n    0.25, #Original was 750 ( y ranges from 0 to 2,) It's 0.25 Not 0,25 string\n    \"Mean Extravasation Injury\" + str(mean_extravasation.round(0)),\n    fontsize=9,\n    color=\"#000000\",\n)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:40:48.493943Z","iopub.execute_input":"2023-07-28T00:40:48.494813Z","iopub.status.idle":"2023-07-28T00:40:48.979089Z","shell.execute_reply.started":"2023-07-28T00:40:48.494778Z","shell.execute_reply":"2023-07-28T00:40:48.978316Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Correlation Matrix","metadata":{}},{"cell_type":"code","source":"#By Kheirallah Samaha https://www.kaggle.com/code/khsamaha/xgboost-classification-of-machine-failures-py\n\n\ncorr = train.corr()\n\ncmap = sns.diverging_palette(230, 20, as_cmap=True)\nf, ax = plt.subplots(figsize=(9, 7))\nsns.heatmap(\n    corr,\n    cmap=cmap,\n    vmax=0.3,\n    cbar=False,\n    center=0,\n    square=True,\n    annot=True,\n    linewidths=0.5,\n    cbar_kws={\"shrink\": 0.8},\n)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:08:10.725567Z","iopub.execute_input":"2023-07-28T00:08:10.726651Z","iopub.status.idle":"2023-07-28T00:08:11.544922Z","shell.execute_reply.started":"2023-07-28T00:08:10.726611Z","shell.execute_reply":"2023-07-28T00:08:11.543982Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Kheirallah Samaha https://www.kaggle.com/code/khsamaha/xgboost-classification-of-machine-failures-py\n\n\ntrain_sample1 = (\n    train[\n        [\n            \"extravasation_healthy\",\n            \"extravasation_injury\",\n            \"kidney_healthy\",\n            \"spleen_healthy\",\n            \"liver_low\",\n            \"any_injury\",\n        ]\n    ]\n    .groupby(\"extravasation_injury\", group_keys=False)\n    .apply(lambda x: x.sample(frac=0.1, replace=True, random_state=234))\n    .copy()\n)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:14:13.71223Z","iopub.execute_input":"2023-07-28T00:14:13.712729Z","iopub.status.idle":"2023-07-28T00:14:13.724527Z","shell.execute_reply.started":"2023-07-28T00:14:13.712689Z","shell.execute_reply":"2023-07-28T00:14:13.72321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Kheirallah Samaha https://www.kaggle.com/code/khsamaha/xgboost-classification-of-machine-failures-py\n\n\nupset_train = train_sample1.iloc[:, :].replace({1: True, 0: False}).value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:20:06.779687Z","iopub.execute_input":"2023-07-28T00:20:06.780127Z","iopub.status.idle":"2023-07-28T00:20:06.792275Z","shell.execute_reply.started":"2023-07-28T00:20:06.780096Z","shell.execute_reply":"2023-07-28T00:20:06.791008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"upsplt.plot(\n    upset_train,\n    show_percentages=True,\n    sort_by=\"cardinality\",\n    facecolor=\"#0D68C3\",\n    shading_color=\"lightgray\",\n    other_dots_color=0.05,\n)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-07-28T00:21:04.607537Z","iopub.execute_input":"2023-07-28T00:21:04.60798Z","iopub.status.idle":"2023-07-28T00:21:05.054267Z","shell.execute_reply.started":"2023-07-28T00:21:04.607946Z","shell.execute_reply":"2023-07-28T00:21:05.05308Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from upsetplot import generate_counts, plot\n\nwith plt.style.context('dark_background'):\n    plot(upset_train, show_counts=True)\n    plt.suptitle('Abdominal Trauma')\n    plt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-28T01:00:49.680317Z","iopub.execute_input":"2023-07-28T01:00:49.680748Z","iopub.status.idle":"2023-07-28T01:00:50.124179Z","shell.execute_reply.started":"2023-07-28T01:00:49.680712Z","shell.execute_reply":"2023-07-28T01:00:50.12288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Kheirallah Samaha https://www.kaggle.com/code/khsamaha/xgboost-classification-of-machine-failures-py\n\nwith plt.style.context('dark_background'):\n    upsplt.plot(upset_train, show_counts=True)\n    plt.suptitle('Abdominal Trauma')\n    plt.show()\n\n\nupsplt.plot( upset_train, min_subset_size=15, show_percentages=True)#Original show_counts=True\nplt.show()\n\nIn[18]\n\nupset = upsplt.UpSet(upset_train, facecolor=\"gray\")\nupset.style_subsets(present=\"extravasation_injury\", label=\"Contains Extravasation Injury\", facecolor=\"blue\")\nupset.style_subsets(present=\"kidney_healthy\", label=\"Contains Kidney Healthy\", hatch=\"xx\")\nupset.style_subsets(present=\"any_injury\", label=\"Contains Any Injury\", edgecolor=\"red\")\n\n# reduce legend size:\nparams = {'legend.fontsize': 8}\nwith plt.rc_context(params):\n     upset.plot()\nplt.suptitle(\"Abdominal Trauma\")\nplt.show()","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2023-07-28T01:00:17.197848Z","iopub.execute_input":"2023-07-28T01:00:17.198316Z","iopub.status.idle":"2023-07-28T01:00:18.469497Z","shell.execute_reply.started":"2023-07-28T01:00:17.198284Z","shell.execute_reply":"2023-07-28T01:00:18.468387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Upset observations about Abdominal Trauma numbers:\n\nThe black points here are representing Ones(1) and the gray-blue points are representing Zeros(0)\n\n92.4% (max) - 7.6% (min) are the rows values\n\n27.9% goes to Any Injury\n\n7.6% goes to Liver Low\n\n7.6% goes to Extravasation injury","metadata":{}},{"cell_type":"markdown","source":"#Acknowledgements:\n\nKheirallah Samaha https://www.kaggle.com/code/khsamaha/xgboost-classification-of-machine-failures-py","metadata":{}}]}