{"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":30775,"isInternetEnabled":false,"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)'\npd.set_option('display.max_columns', 500)\npd.set_option('display.max_rows', 500)\n\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\nimport os\n\nfrom pyarrow.parquet import ParquetFile\nimport pyarrow as pa\n\nimport xgboost\nfrom xgboost import XGBRegressor,XGBClassifier\n\nfrom sklearn.model_selection import train_test_split,RandomizedSearchCV\nfrom sklearn.impute import KNNImputer\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.utils import class_weight\nfrom sklearn.metrics import confusion_matrix,ConfusionMatrixDisplay\n\nimport matplotlib.pyplot as plt\nimport matplotlib\n\nimport seaborn as sns\n# for dirname, _, filenames in os.walk('/kaggle/input'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\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","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","scrolled":true,"execution":{"iopub.status.busy":"2024-10-21T08:19:30.363704Z","iopub.execute_input":"2024-10-21T08:19:30.364269Z","iopub.status.idle":"2024-10-21T08:19:30.376412Z","shell.execute_reply.started":"2024-10-21T08:19:30.364212Z","shell.execute_reply":"2024-10-21T08:19:30.375028Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# EDA:","metadata":{}},{"cell_type":"code","source":"raw_data=pd.read_csv('/kaggle/input/child-mind-institute-problematic-internet-use/train.csv')\nraw_data.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-21T07:57:56.281670Z","iopub.execute_input":"2024-10-21T07:57:56.282284Z","iopub.status.idle":"2024-10-21T07:57:56.380435Z","shell.execute_reply.started":"2024-10-21T07:57:56.282240Z","shell.execute_reply":"2024-10-21T07:57:56.379147Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"raw_data.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-21T07:57:57.844447Z","iopub.execute_input":"2024-10-21T07:57:57.844878Z","iopub.status.idle":"2024-10-21T07:57:57.950799Z","shell.execute_reply.started":"2024-10-21T07:57:57.844838Z","shell.execute_reply":"2024-10-21T07:57:57.949327Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"raw_data.isna().sum(axis=0).sort_values(ascending=False)/raw_data.shape[0]","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2024-10-21T07:57:59.781961Z","iopub.execute_input":"2024-10-21T07:57:59.782475Z","iopub.status.idle":"2024-10-21T07:57:59.806122Z","shell.execute_reply.started":"2024-10-21T07:57:59.782432Z","shell.execute_reply":"2024-10-21T07:57:59.804881Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(raw_data.sii.isna().sum()/raw_data.shape[0])\nprint(raw_data['PCIAT-PCIAT_Total'].isna().sum()/raw_data.shape[0])","metadata":{"execution":{"iopub.status.busy":"2024-10-21T07:58:03.943175Z","iopub.execute_input":"2024-10-21T07:58:03.943733Z","iopub.status.idle":"2024-10-21T07:58:03.952861Z","shell.execute_reply.started":"2024-10-21T07:58:03.943676Z","shell.execute_reply":"2024-10-21T07:58:03.951442Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"raw_data.sii.value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-10-21T07:58:05.080094Z","iopub.execute_input":"2024-10-21T07:58:05.081081Z","iopub.status.idle":"2024-10-21T07:58:05.095392Z","shell.execute_reply.started":"2024-10-21T07:58:05.081036Z","shell.execute_reply":"2024-10-21T07:58:05.094197Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"raw_data.dtypes","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T04:54:17.484042Z","iopub.execute_input":"2024-10-21T04:54:17.484541Z","iopub.status.idle":"2024-10-21T04:54:17.499388Z","shell.execute_reply.started":"2024-10-21T04:54:17.484490Z","shell.execute_reply":"2024-10-21T04:54:17.497954Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"numerical=raw_data.select_dtypes(exclude='object')\nnumerical.corr()\nsns.heatmap(numerical.corr())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:06.800738Z","iopub.execute_input":"2024-10-21T07:58:06.801211Z","iopub.status.idle":"2024-10-21T07:58:07.826112Z","shell.execute_reply.started":"2024-10-21T07:58:06.801171Z","shell.execute_reply":"2024-10-21T07:58:07.824733Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"numerical.corr()['sii'].sort_values()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:10.134466Z","iopub.execute_input":"2024-10-21T07:58:10.134978Z","iopub.status.idle":"2024-10-21T07:58:10.222243Z","shell.execute_reply.started":"2024-10-21T07:58:10.134936Z","shell.execute_reply":"2024-10-21T07:58:10.220699Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"list(raw_data.columns)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:14.545922Z","iopub.execute_input":"2024-10-21T07:58:14.546490Z","iopub.status.idle":"2024-10-21T07:58:14.556057Z","shell.execute_reply.started":"2024-10-21T07:58:14.546442Z","shell.execute_reply":"2024-10-21T07:58:14.554909Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Preprocess:","metadata":{}},{"cell_type":"code","source":"cleaned=raw_data.copy()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:17.528880Z","iopub.execute_input":"2024-10-21T07:58:17.529805Z","iopub.status.idle":"2024-10-21T07:58:17.536749Z","shell.execute_reply.started":"2024-10-21T07:58:17.529754Z","shell.execute_reply":"2024-10-21T07:58:17.535233Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"PCIAT_cols=[\n    'PCIAT-PCIAT_01',\n 'PCIAT-PCIAT_02',\n 'PCIAT-PCIAT_03',\n 'PCIAT-PCIAT_04',\n 'PCIAT-PCIAT_05',\n 'PCIAT-PCIAT_06',\n 'PCIAT-PCIAT_07',\n 'PCIAT-PCIAT_08',\n 'PCIAT-PCIAT_09',\n 'PCIAT-PCIAT_10',\n 'PCIAT-PCIAT_11',\n 'PCIAT-PCIAT_12',\n 'PCIAT-PCIAT_13',\n 'PCIAT-PCIAT_14',\n 'PCIAT-PCIAT_15',\n 'PCIAT-PCIAT_16',\n 'PCIAT-PCIAT_17',\n 'PCIAT-PCIAT_18',\n 'PCIAT-PCIAT_19',\n 'PCIAT-PCIAT_20',\n'PCIAT-PCIAT_Total',\n'PCIAT-Season',\n]\n\n# raw_data[PCIAT_cols]\ncleaned=raw_data.drop(PCIAT_cols,axis=1)\n# cleanaed.drop')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:18.422716Z","iopub.execute_input":"2024-10-21T07:58:18.423216Z","iopub.status.idle":"2024-10-21T07:58:18.435798Z","shell.execute_reply.started":"2024-10-21T07:58:18.423169Z","shell.execute_reply":"2024-10-21T07:58:18.434687Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# cleaned=cleaned[cleaned.sii.notna()]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T04:54:36.819368Z","iopub.execute_input":"2024-10-21T04:54:36.819839Z","iopub.status.idle":"2024-10-21T04:54:36.829132Z","shell.execute_reply.started":"2024-10-21T04:54:36.819795Z","shell.execute_reply":"2024-10-21T04:54:36.827606Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for col in cleaned.columns:\n    if cleaned[col].dtype=='object':\n        cleaned[col]=cleaned[col].astype('category')\n# cleaned.sii=cleaned.sii.astype('category')\ncleaned.dtypes\ncleaned=cleaned.drop('id',axis=1)","metadata":{"execution":{"iopub.status.busy":"2024-10-21T07:58:20.183423Z","iopub.execute_input":"2024-10-21T07:58:20.184496Z","iopub.status.idle":"2024-10-21T07:58:20.229351Z","shell.execute_reply.started":"2024-10-21T07:58:20.184398Z","shell.execute_reply":"2024-10-21T07:58:20.227954Z"},"trusted":true,"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cleaned.dtypes","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:22.966021Z","iopub.execute_input":"2024-10-21T07:58:22.966545Z","iopub.status.idle":"2024-10-21T07:58:22.979263Z","shell.execute_reply.started":"2024-10-21T07:58:22.966499Z","shell.execute_reply":"2024-10-21T07:58:22.978000Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cleaned.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:26.000998Z","iopub.execute_input":"2024-10-21T07:58:26.001553Z","iopub.status.idle":"2024-10-21T07:58:26.076911Z","shell.execute_reply.started":"2024-10-21T07:58:26.001506Z","shell.execute_reply":"2024-10-21T07:58:26.075631Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"list(cleaned.select_dtypes(exclude='category').columns)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T06:29:10.095604Z","iopub.execute_input":"2024-10-21T06:29:10.096839Z","iopub.status.idle":"2024-10-21T06:29:10.108058Z","shell.execute_reply.started":"2024-10-21T06:29:10.096771Z","shell.execute_reply":"2024-10-21T06:29:10.106767Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ct=ColumnTransformer(\n    [\n        ('imputer',KNNImputer(),cleaned.select_dtypes(exclude='category').columns)\n    ],\n    remainder='passthrough',\n    verbose_feature_names_out=False\n)\nct.set_output(transform=\"pandas\")\ntransformed=ct.fit_transform(cleaned)\ntransformed.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:31.545797Z","iopub.execute_input":"2024-10-21T07:58:31.547062Z","iopub.status.idle":"2024-10-21T07:58:37.555971Z","shell.execute_reply.started":"2024-10-21T07:58:31.547004Z","shell.execute_reply":"2024-10-21T07:58:37.554635Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"transformed.sii=transformed.sii.round().astype('category')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:37.558476Z","iopub.execute_input":"2024-10-21T07:58:37.558972Z","iopub.status.idle":"2024-10-21T07:58:37.567513Z","shell.execute_reply.started":"2024-10-21T07:58:37.558915Z","shell.execute_reply":"2024-10-21T07:58:37.566285Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"transformed.sii.value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T07:58:37.568981Z","iopub.execute_input":"2024-10-21T07:58:37.569449Z","iopub.status.idle":"2024-10-21T07:58:37.585996Z","shell.execute_reply.started":"2024-10-21T07:58:37.569396Z","shell.execute_reply":"2024-10-21T07:58:37.584440Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Xgb model:","metadata":{}},{"cell_type":"code","source":"train,val=train_test_split(transformed,test_size=0.1,stratify=transformed.sii)\nprint(train.shape)\nprint(val.shape)","metadata":{"execution":{"iopub.status.busy":"2024-10-21T07:58:37.588565Z","iopub.execute_input":"2024-10-21T07:58:37.589048Z","iopub.status.idle":"2024-10-21T07:58:37.604514Z","shell.execute_reply.started":"2024-10-21T07:58:37.588992Z","shell.execute_reply":"2024-10-21T07:58:37.603220Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample_weights = class_weight.compute_sample_weight(\n    class_weight='balanced',\n    y=train['sii']\n)\nsample_weights\n# sample_weights=train.sii.apply(lambda x:class_weights[x]).astype('float')\n# sample_weights","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T08:30:55.228301Z","iopub.execute_input":"2024-10-21T08:30:55.229058Z","iopub.status.idle":"2024-10-21T08:30:55.239823Z","shell.execute_reply.started":"2024-10-21T08:30:55.229013Z","shell.execute_reply":"2024-10-21T08:30:55.238649Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X=train.drop('sii',axis=1)\ny=train.sii\n\nX_val=val.drop('sii',axis=1)\ny_val=val.sii","metadata":{"execution":{"iopub.status.busy":"2024-10-21T08:05:27.592112Z","iopub.execute_input":"2024-10-21T08:05:27.592601Z","iopub.status.idle":"2024-10-21T08:05:27.602256Z","shell.execute_reply.started":"2024-10-21T08:05:27.592559Z","shell.execute_reply":"2024-10-21T08:05:27.600892Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"XGB_Params = {\n    'learning_rate': 0.01, # 0.05\n    'max_depth': 10, # 6 -> 7\n    'n_estimators': 1000, # 200\n    'subsample': 0.8,\n    'colsample_bytree': 0.8,\n    'reg_alpha': 2, \n    'reg_lambda': 3, # 3\n}\n\nmodel=XGBClassifier(enable_categorical=True,**XGB_Params)\nmodel.fit(X,y,eval_set=[[X_val,y_val]],sample_weight=sample_weights,eval_metric='aucpr')","metadata":{"execution":{"iopub.status.busy":"2024-10-21T08:31:01.876440Z","iopub.execute_input":"2024-10-21T08:31:01.876977Z","iopub.status.idle":"2024-10-21T08:31:42.837774Z","shell.execute_reply.started":"2024-10-21T08:31:01.876927Z","shell.execute_reply":"2024-10-21T08:31:42.836458Z"},"scrolled":true,"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"val_preds=model.predict(X_val)\n(val_preds==y_val).sum()/X_val.shape[0]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T08:31:45.262127Z","iopub.execute_input":"2024-10-21T08:31:45.262625Z","iopub.status.idle":"2024-10-21T08:31:45.349660Z","shell.execute_reply.started":"2024-10-21T08:31:45.262578Z","shell.execute_reply":"2024-10-21T08:31:45.348646Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cm=confusion_matrix(y_val,val_preds)\nConfusionMatrixDisplay(cm).plot()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T08:31:49.453468Z","iopub.execute_input":"2024-10-21T08:31:49.454009Z","iopub.status.idle":"2024-10-21T08:31:49.744146Z","shell.execute_reply.started":"2024-10-21T08:31:49.453959Z","shell.execute_reply":"2024-10-21T08:31:49.742889Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Accelometer EDA:","metadata":{}},{"cell_type":"code","source":"raw_data[raw_data.sii==3].head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T04:54:44.012618Z","iopub.execute_input":"2024-10-21T04:54:44.013409Z","iopub.status.idle":"2024-10-21T04:54:44.118348Z","shell.execute_reply.started":"2024-10-21T04:54:44.013347Z","shell.execute_reply":"2024-10-21T04:54:44.117006Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_pq=pd.Series(os.listdir('/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet'))\ntrain_pq=train_pq.apply(lambda x:x[3:])\n# raw_data[raw_data.id.apply(lambda x:x in train_pq)]\ntrain_pq","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T04:59:39.812685Z","iopub.execute_input":"2024-10-21T04:59:39.813201Z","iopub.status.idle":"2024-10-21T04:59:39.829026Z","shell.execute_reply.started":"2024-10-21T04:59:39.813153Z","shell.execute_reply":"2024-10-21T04:59:39.827278Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for id in train_pq:\n    data=raw_data[raw_data.id==id]\n    if(data.sii.iloc[0]==0):\n        print(id)\n        break","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T05:31:18.094835Z","iopub.execute_input":"2024-10-21T05:31:18.095251Z","iopub.status.idle":"2024-10-21T05:31:18.106547Z","shell.execute_reply.started":"2024-10-21T05:31:18.095212Z","shell.execute_reply":"2024-10-21T05:31:18.105153Z"},"scrolled":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## SII=0","metadata":{}},{"cell_type":"code","source":"pq=pd.read_parquet('/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet/id=eaab7a96/part-0.parquet')\npq.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-21T05:31:24.801577Z","iopub.execute_input":"2024-10-21T05:31:24.802005Z","iopub.status.idle":"2024-10-21T05:31:24.983981Z","shell.execute_reply.started":"2024-10-21T05:31:24.801967Z","shell.execute_reply":"2024-10-21T05:31:24.982775Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.plot(pq.X)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T05:31:26.354823Z","iopub.execute_input":"2024-10-21T05:31:26.355278Z","iopub.status.idle":"2024-10-21T05:31:27.014019Z","shell.execute_reply.started":"2024-10-21T05:31:26.355233Z","shell.execute_reply":"2024-10-21T05:31:27.012675Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## SII=1","metadata":{}},{"cell_type":"code","source":"pq=pd.read_parquet('/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet/id=0745c390/part-0.parquet')\npq.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-21T05:31:31.050138Z","iopub.execute_input":"2024-10-21T05:31:31.050732Z","iopub.status.idle":"2024-10-21T05:31:31.073616Z","shell.execute_reply.started":"2024-10-21T05:31:31.050653Z","shell.execute_reply":"2024-10-21T05:31:31.072264Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.plot(pq.X)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T05:31:34.550962Z","iopub.execute_input":"2024-10-21T05:31:34.551382Z","iopub.status.idle":"2024-10-21T05:31:34.900455Z","shell.execute_reply.started":"2024-10-21T05:31:34.551335Z","shell.execute_reply":"2024-10-21T05:31:34.899234Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## SII=2","metadata":{}},{"cell_type":"code","source":"pq=pd.read_parquet('/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet/id=7b8842c3/part-0.parquet')\npq.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-21T05:31:40.645599Z","iopub.execute_input":"2024-10-21T05:31:40.646040Z","iopub.status.idle":"2024-10-21T05:31:40.661527Z","shell.execute_reply.started":"2024-10-21T05:31:40.645999Z","shell.execute_reply":"2024-10-21T05:31:40.659913Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.plot(pq.X)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T05:31:42.915369Z","iopub.execute_input":"2024-10-21T05:31:42.915862Z","iopub.status.idle":"2024-10-21T05:31:43.234839Z","shell.execute_reply.started":"2024-10-21T05:31:42.915817Z","shell.execute_reply":"2024-10-21T05:31:43.233461Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## SII=3","metadata":{}},{"cell_type":"code","source":"pq=pd.read_parquet('/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet/id=bc4eaf77/part-0.parquet')\npq.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-21T05:32:31.923509Z","iopub.execute_input":"2024-10-21T05:32:31.923961Z","iopub.status.idle":"2024-10-21T05:32:32.020838Z","shell.execute_reply.started":"2024-10-21T05:32:31.923916Z","shell.execute_reply":"2024-10-21T05:32:32.017746Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.plot(pq.X)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T05:32:45.730314Z","iopub.execute_input":"2024-10-21T05:32:45.730797Z","iopub.status.idle":"2024-10-21T05:32:46.138855Z","shell.execute_reply.started":"2024-10-21T05:32:45.730739Z","shell.execute_reply":"2024-10-21T05:32:46.137548Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pq.describe()","metadata":{"execution":{"iopub.status.busy":"2024-10-21T05:32:59.994265Z","iopub.execute_input":"2024-10-21T05:32:59.994730Z","iopub.status.idle":"2024-10-21T05:33:00.183629Z","shell.execute_reply.started":"2024-10-21T05:32:59.994666Z","shell.execute_reply":"2024-10-21T05:33:00.182280Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pq.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-21T05:10:58.980395Z","iopub.execute_input":"2024-10-21T05:10:58.980913Z","iopub.status.idle":"2024-10-21T05:10:59.003431Z","shell.execute_reply.started":"2024-10-21T05:10:58.980869Z","shell.execute_reply":"2024-10-21T05:10:59.001978Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pq.tail(2)","metadata":{"execution":{"iopub.status.busy":"2024-10-14T18:36:56.095899Z","iopub.execute_input":"2024-10-14T18:36:56.096389Z","iopub.status.idle":"2024-10-14T18:36:56.118447Z","shell.execute_reply.started":"2024-10-14T18:36:56.096346Z","shell.execute_reply":"2024-10-14T18:36:56.116938Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Prediction:","metadata":{}},{"cell_type":"code","source":"final=pd.read_csv('/kaggle/input/child-mind-institute-problematic-internet-use/test.csv')\nfinal.shape","metadata":{"execution":{"iopub.status.busy":"2024-10-21T06:27:22.459288Z","iopub.execute_input":"2024-10-21T06:27:22.459776Z","iopub.status.idle":"2024-10-21T06:27:22.479597Z","shell.execute_reply.started":"2024-10-21T06:27:22.459731Z","shell.execute_reply":"2024-10-21T06:27:22.478423Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"final.head()","metadata":{"execution":{"iopub.status.busy":"2024-10-21T06:27:24.248155Z","iopub.execute_input":"2024-10-21T06:27:24.249566Z","iopub.status.idle":"2024-10-21T06:27:24.327011Z","shell.execute_reply.started":"2024-10-21T06:27:24.249509Z","shell.execute_reply":"2024-10-21T06:27:24.325574Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for col in final.columns:\n    if final[col].dtype=='object':\n        final[col]=final[col].astype('category')","metadata":{"execution":{"iopub.status.busy":"2024-10-21T06:39:17.593482Z","iopub.execute_input":"2024-10-21T06:39:17.594584Z","iopub.status.idle":"2024-10-21T06:39:17.602073Z","shell.execute_reply.started":"2024-10-21T06:39:17.594512Z","shell.execute_reply":"2024-10-21T06:39:17.600745Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ids=final.id\nfinal=final.drop('id',axis=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T06:39:19.805629Z","iopub.execute_input":"2024-10-21T06:39:19.806663Z","iopub.status.idle":"2024-10-21T06:39:19.843822Z","shell.execute_reply.started":"2024-10-21T06:39:19.806611Z","shell.execute_reply":"2024-10-21T06:39:19.842189Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"final['sii']=np.nan","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T06:40:03.091237Z","iopub.execute_input":"2024-10-21T06:40:03.091713Z","iopub.status.idle":"2024-10-21T06:40:03.098515Z","shell.execute_reply.started":"2024-10-21T06:40:03.091654Z","shell.execute_reply":"2024-10-21T06:40:03.097008Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"final=ct.transform(final)\nfinal.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T06:40:17.276425Z","iopub.execute_input":"2024-10-21T06:40:17.276906Z","iopub.status.idle":"2024-10-21T06:40:17.359662Z","shell.execute_reply.started":"2024-10-21T06:40:17.276860Z","shell.execute_reply":"2024-10-21T06:40:17.358480Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"final=final.drop('sii',axis=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T06:40:41.806685Z","iopub.execute_input":"2024-10-21T06:40:41.807146Z","iopub.status.idle":"2024-10-21T06:40:41.815233Z","shell.execute_reply.started":"2024-10-21T06:40:41.807101Z","shell.execute_reply":"2024-10-21T06:40:41.813521Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"preds=model.predict(final)\npreds","metadata":{"execution":{"iopub.status.busy":"2024-10-21T06:40:45.203173Z","iopub.execute_input":"2024-10-21T06:40:45.203633Z","iopub.status.idle":"2024-10-21T06:40:45.262345Z","shell.execute_reply.started":"2024-10-21T06:40:45.203589Z","shell.execute_reply":"2024-10-21T06:40:45.260972Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission=pd.DataFrame({'id':ids,'sii':preds})\nsubmission.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-21T06:40:48.027957Z","iopub.execute_input":"2024-10-21T06:40:48.028490Z","iopub.status.idle":"2024-10-21T06:40:48.041818Z","shell.execute_reply.started":"2024-10-21T06:40:48.028443Z","shell.execute_reply":"2024-10-21T06:40:48.040398Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission.to_csv('submission.csv',index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-10-20T13:51:03.664922Z","iopub.execute_input":"2024-10-20T13:51:03.665989Z","iopub.status.idle":"2024-10-20T13:51:03.674580Z","shell.execute_reply.started":"2024-10-20T13:51:03.665931Z","shell.execute_reply":"2024-10-20T13:51:03.673442Z"}},"outputs":[],"execution_count":null}]}