{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":3004,"databundleVersionId":861823,"sourceType":"competition"}],"dockerImageVersionId":30587,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport math\n\ndf = pd.read_csv(\"../input/digit-recognizer/train.csv\")\n\ndf.head()","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-11-16T18:49:14.308063Z","iopub.execute_input":"2023-11-16T18:49:14.309332Z","iopub.status.idle":"2023-11-16T18:49:17.617758Z","shell.execute_reply.started":"2023-11-16T18:49:14.309289Z","shell.execute_reply":"2023-11-16T18:49:17.616408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Number of samples ::\", df.shape[0])\nprint(\"Number of dimensions ::\", df.shape[1])","metadata":{"execution":{"iopub.status.busy":"2023-11-16T18:51:07.942152Z","iopub.execute_input":"2023-11-16T18:51:07.942577Z","iopub.status.idle":"2023-11-16T18:51:07.949435Z","shell.execute_reply.started":"2023-11-16T18:51:07.942545Z","shell.execute_reply":"2023-11-16T18:51:07.947768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Any Null Values ::\",df.isnull().values.any())","metadata":{"execution":{"iopub.status.busy":"2023-11-16T18:49:45.483862Z","iopub.execute_input":"2023-11-16T18:49:45.484331Z","iopub.status.idle":"2023-11-16T18:49:45.505821Z","shell.execute_reply.started":"2023-11-16T18:49:45.484297Z","shell.execute_reply":"2023-11-16T18:49:45.504373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels = sorted(df[\"label\"].unique())\nprint(labels)","metadata":{"execution":{"iopub.status.busy":"2023-11-16T18:54:58.764078Z","iopub.execute_input":"2023-11-16T18:54:58.764566Z","iopub.status.idle":"2023-11-16T18:54:58.771463Z","shell.execute_reply.started":"2023-11-16T18:54:58.764533Z","shell.execute_reply":"2023-11-16T18:54:58.77028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for label in labels:\n    print(\"Percentage of labels with\",label,\"=\",round((df[df['label']==label].shape[0]/df.shape[0])*100,5),\"%\")","metadata":{"execution":{"iopub.status.busy":"2023-11-16T18:58:14.92876Z","iopub.execute_input":"2023-11-16T18:58:14.929268Z","iopub.status.idle":"2023-11-16T18:58:15.323269Z","shell.execute_reply.started":"2023-11-16T18:58:14.92923Z","shell.execute_reply":"2023-11-16T18:58:15.32213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"The dataset is balanced with every class almost having sample weightage of 10%","metadata":{}},{"cell_type":"code","source":"sns.set(style=\"whitegrid\")\n\nfor label in labels:\n    # Plotting density plot for Class 0\n    sns.kdeplot(data=df[df['label']==label], label=\"Number \"+str(label), fill=True)\n\n# Adding labels and title\nplt.xlabel('Time')\nplt.ylabel('Density')\nplt.title('Density Plot of Time for Class 0 and Class 1')\n\n# Display the plot\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-16T19:00:03.98304Z","iopub.execute_input":"2023-11-16T19:00:03.984475Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}