{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import os\nimport pandas as pd \nimport numpy as np\n\nimport pydicom\n\nimport plotly.express as px\nimport plotly.graph_objs as go\nfrom plotly.offline import iplot\n\nimport matplotlib.pyplot as plt\n%matplotlib inline\n\nimport cufflinks\ncufflinks.go_offline()\ncufflinks.set_config_file(world_readable=True, theme='pearl')\n\nimport seaborn as sns\nsns.set(style=\"whitegrid\")\n\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":"train_df = pd.read_csv('../input/osic-pulmonary-fibrosis-progression/train.csv')\ntest_df = pd.read_csv('../input/osic-pulmonary-fibrosis-progression/test.csv')\nsubmission = pd.read_csv('../input/osic-pulmonary-fibrosis-progression/sample_submission.csv')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Train Data EDA","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.isnull().sum()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"So we have no null values.","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"def uniques(df):\n    print(\"UNIQUE VALUE STATS\")\n    print(f\"{len(df)} Rows\")\n    print(\"Column\\t\\tUniquevalues\")\n    for col in df.columns:\n        print(f\"{col}\\t\\t{len(df[col].unique())}\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"uniques(train_df)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Exploring Age Field","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.histogram(train_df, x=\"Age\")\nfig.update_layout(title_text='Age Distribution')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Exploring Weeks Field","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.histogram(train_df, x=\"Weeks\",marginal=\"rug\")\nfig.update_layout(title_text='Weeks Distribution')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Exploring the Sex Field","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.histogram(train_df, x=\"Sex\")\nfig.update_layout(title_text='Sex Counts')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"3x male data compared to Female","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Exploring SmokingStatus Field","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.histogram(train_df, x=\"SmokingStatus\")\nfig.update_layout(title_text='Smoking Status')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Exploring Relationships","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.scatter(train_df, x=\"FVC\", y=\"Percent\")\nfig.update_layout(title_text='Percent vs FVC')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Somewhat of a linear distribution here between percent and FVC. Makes sense as both terms are proportional.","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.scatter(train_df, x=\"FVC\", y=\"Age\" , color =\"Sex\")\nfig.update_layout(title_text='Age vs FVC in terms of Sex')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Males have Higher FVC irrespective of Age","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.scatter(train_df, x=\"Weeks\", y=\"Percent\" , color =\"Sex\")\nfig.update_layout(title_text='Percent vs Weeks')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"So the percentage doesnt show any specific trend with the weeks passed.","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.scatter(train_df, x=\"Weeks\", y=\"FVC\" , color =\"Sex\")\nfig.update_layout(title_text='FVC vs Weeks')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"No specific trends","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.bar(train_df, y='FVC', x='SmokingStatus')\nfig.update_layout(title = 'FVC based of Smoking Status')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"People with History of smoking clearly show higher FVC levels <br>\nValues cannot be compared with each other as number of datapoints vary ( ie. data is unbalanced )","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.histogram(train_df, x=\"SmokingStatus\", color='Sex')\nfig.update_layout(title_text='Smoking Status')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig = px.histogram(train_df, x=\"Age\", color='Sex')\nfig.update_layout(title_text='Smoking Status')\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Exploring Test Data","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def getHisto(col):\n    fig = px.histogram(test_df, x=col)\n    fig.update_layout(title_text=col + ' Distribution')\n    fig.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"getHisto(\"Weeks\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"getHisto(\"Age\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"getHisto(\"Sex\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"getHisto(\"SmokingStatus\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Exploring Image Data","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"filename = \"/kaggle/input/osic-pulmonary-fibrosis-progression/train/ID00123637202217151272140/137.dcm\"\nds = pydicom.dcmread(filename)\nplt.imshow(ds.pixel_array, cmap=plt.cm.bone) ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.loc[train_df.Patient == 'ID00007637202177411956430']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"os.listdir('/kaggle/input/osic-pulmonary-fibrosis-progression/train/ID00007637202177411956430/')","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}