{"cells":[{"metadata":{},"cell_type":"markdown","source":"# 🕵 **<strong style=\"color:#8E44AD\"> A Statistical analysis on Pulmonary Fibrosis </strong>** 🕵\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## 🔥**This is my first kernal in the image processing space.** 🔥  \n\n## **Hope you will read something <span style=\"color:#2ECC71\"> new and interesting </span> out here.**  😊😊","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"<div>  \n<img width=\"1000\" height=\"500\" src=\"https://picography.co/wp-content/uploads/2018/09/picography-laptop-tablet-gifts-small-768x512.jpg\">  \n</div>","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## <h2 style=\"color:#F39C12\"> Contents of Kernal <a id=home></a>\n \n(click to navigate)    \n\n\n## [1. Gender distribution](#1)    \n## [2. Age Distribution](#2) \n## [3. Number of Visits](#3) \n## [4. FVC Frequency](#4)    \n## [5. Age Vs FVC](#5) \n## [6. Smoking Status based on sex](#6) \n## [7. Comparing the all the data based on sex](#7)   \n## [8. Age with the smoking status](#8) \n## [9. Distribution of Age with the sex](#9) \n## [10.Heat Map with all the data](#10)    \n\n \n## [Key Take Aways](#takeaways) \n\n\n\n## <span style=\"color:color:#34495E\"> Feel free to comment your thoughts and suggestions are welcomed!! </span>","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Loading libs","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\nimport pandas as pd\n\n#ploting\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport seaborn as sns\nsns.set(style=\"darkgrid\")\n\n#plotly\nimport plotly.express as px\n\n#color\nfrom colorama import Fore, Style,Back\n\n#pydicom\nimport pydicom\n\nplt.style.use(\"seaborn-notebook\")\nplt.show()\n\n\n# Suppress warnings \nimport warnings\nwarnings.filterwarnings('ignore')","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"root_path = '/kaggle/input/osic-pulmonary-fibrosis-progression/'","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Loading files ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train = pd.read_csv(os.path.join(root_path,\"train.csv\"))\ndf_test = pd.read_csv(os.path.join(root_path,\"test.csv\"))\nsubmission = pd.read_csv(os.path.join(root_path,\"sample_submission.csv\"))\ntrain_folder = root_path+'train/'\ntest_folder  = root_path+'train/'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train.head().style.bar(subset=[\"FVC\"],color=['#F7DC6F'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train.info()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Visualization of data     &emsp;  [👆Back](#home)\n<h2 style=\"color:#9B59B6\"> 1. Gender distribution </h2> <a id=\"1\"></a>","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(10,5))\na = sns.countplot(data=df_train,x=\"Sex\",hue=\"Sex\",color=\"blue\",palette=[\"#F5B041\",\"#58D68D\"])\nplt.title(\"Gender Distribution\")\nplt.legend(fontsize=10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">2. Age Distribution </span>    &emsp;  [👆Back](#home) \n<a id=2 ></a>","execution_count":null},{"metadata":{"_kg_hide-input":false,"trusted":true},"cell_type":"code","source":"a = df_train[\"Age\"].plot.hist(colormap=\"jet\",legend=True,color=\"#BB8FCE\")\nplt.xlabel(\"Age\")\nplt.legend(fontsize=10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">3. Number of Visits</span> &emsp;  [👆Back](#home)  \n<a id=3 ></a>","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"a = df_train[\"Patient\"].value_counts().plot.hist(legend=True,color=\"#85C1E9\")\nplt.xlabel(\"no of visits\")\nplt.legend(fontsize=10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">4. FVC Frequency</span> &emsp;  [👆Back](#home) <a id=4 ></a>","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"a = df_train[\"FVC\"].plot.kde(legend=True,color=\"#F8C471\",linewidth=2.8)\nplt.legend(fontsize=10)\nplt.xlabel(\"FVC\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print('The mean value of FCV is',Back.CYAN+Style.BRIGHT+Fore.BLACK, f'{df_train[\"FVC\"].mean()}')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">5. Age Vs FVC</span> &emsp;  [👆Back](#home) <a id=5></a> ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"a = df_train.plot.scatter(x=\"FVC\",y=\"Age\",color=\"#E74C3C\")\nplt.legend(fontsize=10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">6. Smoking Status based on sex</span>  &emsp;  [👆Back](#home) <a id=6 ></a> ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(45,8))\nsns.set(font_scale=1.1)\nax = sns.catplot(x=\"SmokingStatus\", hue=\"Sex\", col=\"Sex\",data=df_train, kind=\"count\",palette=[\"#F8C471\",\"#58D68D\"])\nplt.legend(fontsize=10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">7. Comparing the all the data based on sex</span> &emsp;  [👆Back](#home) <a id=7 ></a> ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.pairplot(df_train, hue=\"Sex\", palette=\"Set2\", diag_kind=\"kde\", height=2.5)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">8. Age with the smoking status</span>  &emsp;  [👆Back](#home) <a id=8></a> ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"# sns.violinplot(x=\"SmokingStatus\", y=\"Age\", data=df_train, size=7,palette=[\"#F5B7B1\",\"#2ECC71\",\"#E74C3C\"])\nfig = px.violin(df_train, y=\"Age\", x=\"SmokingStatus\", color=\"Sex\", box=True, points=\"all\")\nfig.update_layout(\n    autosize=False,\n    width=1200,\n    height=700,)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">9. Distribution of Age with the sex</span> &emsp;  [👆Back](#home) <a id=9></a>  ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.violin(df_train, y=\"Age\", x=\"Sex\", color=\"Sex\", box=True, points=\"all\")\nfig.update_layout(\n    autosize=False,\n    width=1000,\n    height=700,)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# <span style=\"color:#9B59B6\">10. Heat Map with all the data</span> &emsp;  [👆Back](#home)  <a id=10> </a> ","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"df_train_corr = df_train.corr()\nsns.clustermap(df_train_corr, cmap=\"GnBu\",annot=True)\nplt.legend(fontsize=10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"takeaways\" > </a>\n<h2 style=\"color:#8E44AD\"> Key Take aways</h2>\n<h3 style=\"color:#EC7063\"> \n    1. Age ranges from <span style=\"color:#2ECC71\">60 to 75 </span> with FVC from <span style=\"color:#2ECC71\">1500 to 3000</span> <br> <br>\n    2. People have an average of <span style=\"color:#2ECC71\"> 9 visits </span><br> <br>\n    3. Most people are in the age range from <span style=\"color:#2ECC71\"> 65 to 75 </span><br> <br>\n    4. The number of <span style=\"color:#2ECC71\"> male out range female</span> <br><br>\n    5. In both the gender,  the number of <span style=\"color:#2ECC71\">current smokers is less than never smokers </span><br><br>\n    6. Most male smokers are aged between <span style=\"color:#2ECC71\">  65 and 70 </span> <br><br>\n    7. There exists a <span style=\"color:#2ECC71\"> good correlation </span> between the <span style=\"color:#2ECC71\">FVC value and Percent </span><br><br>\n</h3>\n\n<h3 style=\"color:#34495E\"> ✨✨ Thanks for reading out till the end ✨✨ </h3>\n\n<h3 style=\"color:#34495E\"> Let's me know what can be improved in the comments <br><br> If you liked it please do consider <span style=\"color:#2E86C1\">upvoting!!😎 </span> <br><br> Thanks in advance 😊😊 </h3>\n\n#   [👆Back to top 👆](#home)\n\n    \n## ⚙ ToDo ⚙\n## * Image Analysis\n## * Model Building\n## * Model Training\n    \n","execution_count":null}],"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":4,"nbformat_minor":4}