{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sn\n# Input data files are available in the read-only \"../input/\" director\n\n# You can write up to 5GB 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","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/osic-pulmonary-fibrosis-progression/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/osic-pulmonary-fibrosis-progression/test.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.shape,test.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train[\"Patient\"].unique().shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(\"Mean of age: \",train[\"Age\"].mean())\n\nplt.figure(figsize=(10,6))\nsn.distplot(train[\"Age\"])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(\"Number of Male: \", train[train[\"Sex\"]==\"Male\"].shape[0])\nprint(\"Number of female: \",train[train[\"Sex\"]==\"Female\"].shape[0])\nplt.figure(figsize=(10,6))\nsn.countplot(train[\"Sex\"])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train[\"SmokingStatus\"].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(\"Number of Ex-smoker: \",train[train[\"SmokingStatus\"]==\"Ex-smoker\"].shape[0])\nprint(\"Number of Never a smoker: \",train[train[\"SmokingStatus\"]==\"Never smoked\"].shape[0])\nprint(\"Number of Currently smokes: \",train[train['SmokingStatus']==\"Currently smokes\"].shape[0])\n\nplt.figure(figsize=(10,6))\nsn.countplot(train[\"SmokingStatus\"])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(10,6))\nsn.boxplot(x=\"SmokingStatus\",y=\"FVC\",data=train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train[\"normal_person\"] = train[\"FVC\"]+(train[\"FVC\"]*train[\"Percent\"]/100)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"patients = train[\"Patient\"][:3]\n\nplt.figure(figsize=(16,4))\n\nfor k,patient in enumerate(patients):\n    \n    plt.suptitle(f\"FVC vs Week\", fontsize = 16)\n    ax = plt.subplot(1, 3, k+1)\n    ax.set_title(f\"FVC vs Week for {patient}\")\n    sn.lineplot(x=\"Weeks\",y=\"FVC\",data=train[train[\"Patient\"]==patient],ax=ax)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(10,6))\nsn.lineplot(x=\"Weeks\",y=\"FVC\",data=train[train[\"Patient\"]==patients[0]])","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Checking for some Correlations..","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"g = sn.pairplot(train[['FVC', 'Weeks', 'Percent', 'Age', 'SmokingStatus']], hue='SmokingStatus', aspect=1.4, height=5, diag_kind='kde', kind='reg')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**only FVC and Percent have some obvious linear relationship between all.**","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"import pydicom","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\n\npath= \"/kaggle/input/osic-pulmonary-fibrosis-progression/train/ID00007637202177411956430/\"\nexa_img = list(os.listdir(path))[:5]\n\nfor k,img in enumerate(exa_img):\n    plt.figure(figsize=(25,20))\n    plt.subplot(1,5,k+1)\n    img = pydicom.read_file(path+img)\n    img = img.pixel_array\n    plt.imshow(img)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"path= \"/kaggle/input/osic-pulmonary-fibrosis-progression/train/ID00007637202177411956430/\"\nexa_img = list(os.listdir(path))[:5]\n\nfor k,img in enumerate(exa_img):\n    plt.figure(figsize=(25,15))\n    plt.subplot(1,5,k+1)\n    img = pydicom.read_file(path+img)\n\n    img = img.pixel_array\n    plt.imshow(img,cmap=\"gray\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"path= \"/kaggle/input/osic-pulmonary-fibrosis-progression/train/ID00007637202177411956430/\"\nexa_img = list(os.listdir(path))[:5]\n\nfor k,img in enumerate(exa_img):\n    plt.figure(figsize=(25,15))\n    plt.subplot(1,5,k+1)\n    img = pydicom.read_file(path+img)\n\n    img = img.pixel_array\n    plt.imshow(img,cmap=plt.cm.bone)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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}