{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":81933,"databundleVersionId":9643020,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"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\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\n\nx = 3","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-10-13T07:54:40.526561Z","iopub.execute_input":"2024-10-13T07:54:40.527014Z","iopub.status.idle":"2024-10-13T07:54:41.209824Z","shell.execute_reply.started":"2024-10-13T07:54:40.526972Z","shell.execute_reply":"2024-10-13T07:54:41.208645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train= pd.read_csv('../input/child-mind-institute-problematic-internet-use/train.csv')\ndictionary= pd.read_csv('../input/child-mind-institute-problematic-internet-use/data_dictionary.csv')\nsample_submission= pd.read_csv('../input/child-mind-institute-problematic-internet-use/sample_submission.csv')\n\n","metadata":{"execution":{"iopub.status.busy":"2024-10-13T08:13:03.980724Z","iopub.execute_input":"2024-10-13T08:13:03.982125Z","iopub.status.idle":"2024-10-13T08:13:04.051597Z","shell.execute_reply.started":"2024-10-13T08:13:03.982056Z","shell.execute_reply":"2024-10-13T08:13:04.050196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if (train.sii is None):\n    pass\n\ntrain.sii.any == 1","metadata":{"execution":{"iopub.status.busy":"2024-10-13T08:27:01.051099Z","iopub.execute_input":"2024-10-13T08:27:01.051528Z","iopub.status.idle":"2024-10-13T08:27:01.058978Z","shell.execute_reply.started":"2024-10-13T08:27:01.051487Z","shell.execute_reply":"2024-10-13T08:27:01.057603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"count = train.sii.value_counts()\ncount_none = train.sii.isna().value_counts()\n\ncount\n\n","metadata":{"execution":{"iopub.status.busy":"2024-10-13T08:52:42.722877Z","iopub.execute_input":"2024-10-13T08:52:42.723305Z","iopub.status.idle":"2024-10-13T08:52:42.73379Z","shell.execute_reply.started":"2024-10-13T08:52:42.72326Z","shell.execute_reply":"2024-10-13T08:52:42.732621Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\ntrain2, test2 = train_test_split(\n    train,\n    1224,\n    2736,\n    train.sii\n)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_null_sii = train[train['sii'].isnull()]\ntrain_non_null = train[train['sii'].notnull()]","metadata":{"execution":{"iopub.status.busy":"2024-10-13T08:45:35.268352Z","iopub.execute_input":"2024-10-13T08:45:35.268845Z","iopub.status.idle":"2024-10-13T08:45:35.278847Z","shell.execute_reply.started":"2024-10-13T08:45:35.268799Z","shell.execute_reply":"2024-10-13T08:45:35.277484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_split, test_split = train_test_split(\n    train_non_null,\n    test_size=0.2,  # Adjust the test size percentage accordingly\n    random_state=1  # Seed for reproducibility\n)\n\n","metadata":{"execution":{"iopub.status.busy":"2024-10-13T08:51:39.901184Z","iopub.execute_input":"2024-10-13T08:51:39.901627Z","iopub.status.idle":"2024-10-13T08:51:39.914785Z","shell.execute_reply.started":"2024-10-13T08:51:39.901584Z","shell.execute_reply":"2024-10-13T08:51:39.913492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_split.sii","metadata":{"execution":{"iopub.status.busy":"2024-10-13T08:52:03.615481Z","iopub.execute_input":"2024-10-13T08:52:03.615915Z","iopub.status.idle":"2024-10-13T08:52:03.625431Z","shell.execute_reply.started":"2024-10-13T08:52:03.615875Z","shell.execute_reply":"2024-10-13T08:52:03.624157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"string_columns = train_split.select_dtypes(include=['object']).columns.tolist()\nprint(\"String columns:\", string_columns)","metadata":{"execution":{"iopub.status.busy":"2024-10-13T09:44:42.110241Z","iopub.execute_input":"2024-10-13T09:44:42.110701Z","iopub.status.idle":"2024-10-13T09:44:42.118796Z","shell.execute_reply.started":"2024-10-13T09:44:42.11066Z","shell.execute_reply":"2024-10-13T09:44:42.11765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\nfrom sklearn.preprocessing import LabelEncoder\n\nlabel_encoder = LabelEncoder()\n\nfor column in string_columns:\n    train_split[column] = LabelEncoder().fit_transform(train_split[column])","metadata":{"execution":{"iopub.status.busy":"2024-10-13T09:47:19.773032Z","iopub.execute_input":"2024-10-13T09:47:19.77345Z","iopub.status.idle":"2024-10-13T09:47:19.795533Z","shell.execute_reply.started":"2024-10-13T09:47:19.773404Z","shell.execute_reply":"2024-10-13T09:47:19.79429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neighbors import KNeighborsClassifier\n\nneighDefault = KNeighborsClassifier(\n    5,\n    weights = 'uniform',\n    algorithm = 'auto'\n    #p = 2,\n    #metric = 'minkowski'\n)\n\na = neighDefault.fit(train_split, train_split.sii)\na\n","metadata":{"execution":{"iopub.status.busy":"2024-10-13T09:48:34.590688Z","iopub.execute_input":"2024-10-13T09:48:34.591112Z","iopub.status.idle":"2024-10-13T09:48:35.350777Z","shell.execute_reply.started":"2024-10-13T09:48:34.591074Z","shell.execute_reply":"2024-10-13T09:48:35.348653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntrain_split","metadata":{"execution":{"iopub.status.busy":"2024-10-13T09:47:31.540592Z","iopub.execute_input":"2024-10-13T09:47:31.54178Z","iopub.status.idle":"2024-10-13T09:47:31.576876Z","shell.execute_reply.started":"2024-10-13T09:47:31.54172Z","shell.execute_reply":"2024-10-13T09:47:31.575667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"l","metadata":{"execution":{"iopub.status.busy":"2024-10-13T09:34:21.135475Z","iopub.execute_input":"2024-10-13T09:34:21.135916Z","iopub.status.idle":"2024-10-13T09:34:21.145441Z","shell.execute_reply.started":"2024-10-13T09:34:21.135875Z","shell.execute_reply":"2024-10-13T09:34:21.144494Z"},"trusted":true},"execution_count":null,"outputs":[]}]}