{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Importing libraries","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:16:57.819637Z","iopub.execute_input":"2022-08-11T19:16:57.820275Z","iopub.status.idle":"2022-08-11T19:16:58.968516Z","shell.execute_reply.started":"2022-08-11T19:16:57.820182Z","shell.execute_reply":"2022-08-11T19:16:58.967391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Importing data's","metadata":{}},{"cell_type":"code","source":"train_df=pd.read_csv('../input/autism-prediction/Autism-prediction/train.csv')\ntest_df=pd.read_csv('../input/autism-prediction/Autism-prediction/test.csv')\nsub_df=pd.read_csv('../input/autism-prediction/Autism-prediction/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:16:58.970629Z","iopub.execute_input":"2022-08-11T19:16:58.971069Z","iopub.status.idle":"2022-08-11T19:16:59.001117Z","shell.execute_reply.started":"2022-08-11T19:16:58.971028Z","shell.execute_reply":"2022-08-11T19:16:59.000084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.set_option('Display.max_columns',None)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:16:59.002553Z","iopub.execute_input":"2022-08-11T19:16:59.002914Z","iopub.status.idle":"2022-08-11T19:16:59.008799Z","shell.execute_reply.started":"2022-08-11T19:16:59.002880Z","shell.execute_reply":"2022-08-11T19:16:59.007770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:16:59.011318Z","iopub.execute_input":"2022-08-11T19:16:59.011977Z","iopub.status.idle":"2022-08-11T19:16:59.057923Z","shell.execute_reply.started":"2022-08-11T19:16:59.011931Z","shell.execute_reply":"2022-08-11T19:16:59.056774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(train_df.columns)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:16:59.061339Z","iopub.execute_input":"2022-08-11T19:16:59.062346Z","iopub.status.idle":"2022-08-11T19:16:59.073166Z","shell.execute_reply.started":"2022-08-11T19:16:59.062311Z","shell.execute_reply":"2022-08-11T19:16:59.072048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.drop(columns='ID',axis=1,inplace=True)\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:18:25.222191Z","iopub.execute_input":"2022-08-11T19:18:25.222658Z","iopub.status.idle":"2022-08-11T19:18:25.259880Z","shell.execute_reply.started":"2022-08-11T19:18:25.222616Z","shell.execute_reply":"2022-08-11T19:18:25.258787Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.isnull().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:18:47.140594Z","iopub.execute_input":"2022-08-11T19:18:47.141006Z","iopub.status.idle":"2022-08-11T19:18:47.151829Z","shell.execute_reply.started":"2022-08-11T19:18:47.140959Z","shell.execute_reply":"2022-08-11T19:18:47.150893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:26:51.636193Z","iopub.execute_input":"2022-08-11T19:26:51.636656Z","iopub.status.idle":"2022-08-11T19:26:51.658755Z","shell.execute_reply.started":"2022-08-11T19:26:51.636615Z","shell.execute_reply":"2022-08-11T19:26:51.657665Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_train_df=train_df.select_dtypes(include=['object'])\ncat_train_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:30:46.887233Z","iopub.execute_input":"2022-08-11T19:30:46.887594Z","iopub.status.idle":"2022-08-11T19:30:46.905484Z","shell.execute_reply.started":"2022-08-11T19:30:46.887562Z","shell.execute_reply":"2022-08-11T19:30:46.904261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=train_df.drop(columns='Class/ASD',axis=1)\ny=train_df['Class/ASD']","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:32:26.217310Z","iopub.execute_input":"2022-08-11T19:32:26.218045Z","iopub.status.idle":"2022-08-11T19:32:26.224639Z","shell.execute_reply.started":"2022-08-11T19:32:26.217957Z","shell.execute_reply":"2022-08-11T19:32:26.223649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:32:29.292517Z","iopub.execute_input":"2022-08-11T19:32:29.292884Z","iopub.status.idle":"2022-08-11T19:32:29.321149Z","shell.execute_reply.started":"2022-08-11T19:32:29.292852Z","shell.execute_reply":"2022-08-11T19:32:29.320213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:32:41.515383Z","iopub.execute_input":"2022-08-11T19:32:41.515778Z","iopub.status.idle":"2022-08-11T19:32:41.525006Z","shell.execute_reply.started":"2022-08-11T19:32:41.515741Z","shell.execute_reply":"2022-08-11T19:32:41.523597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.value_counts(normalize=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:33:04.481674Z","iopub.execute_input":"2022-08-11T19:33:04.482064Z","iopub.status.idle":"2022-08-11T19:33:04.491242Z","shell.execute_reply.started":"2022-08-11T19:33:04.482033Z","shell.execute_reply":"2022-08-11T19:33:04.490058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_features=[11,12,13,14,15,16,18,19]","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:58:18.292502Z","iopub.execute_input":"2022-08-11T19:58:18.292882Z","iopub.status.idle":"2022-08-11T19:58:18.297763Z","shell.execute_reply.started":"2022-08-11T19:58:18.292851Z","shell.execute_reply":"2022-08-11T19:58:18.296829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from catboost import CatBoostClassifier\ncat=CatBoostClassifier(cat_features=cat_features)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:58:20.325667Z","iopub.execute_input":"2022-08-11T19:58:20.326057Z","iopub.status.idle":"2022-08-11T19:58:20.331004Z","shell.execute_reply.started":"2022-08-11T19:58:20.326026Z","shell.execute_reply":"2022-08-11T19:58:20.330053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"param_grid={'iterations':[450,1100,2500],\n            'depth':[8,11],\n            'learning_rate':[0.001,0.01],\n            'simple_ctr': ['Borders:TargetBorderType=Uniform', 'Borders:TargetBorderCount=50']\n            \n          }\nprint(param_grid)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:58:28.265845Z","iopub.execute_input":"2022-08-11T19:58:28.266256Z","iopub.status.idle":"2022-08-11T19:58:28.273143Z","shell.execute_reply.started":"2022-08-11T19:58:28.266222Z","shell.execute_reply":"2022-08-11T19:58:28.272145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import GridSearchCV\ncat_grid=GridSearchCV(estimator=cat,param_grid=param_grid,cv=3)\ncat_grid.fit(X,y)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T19:58:42.090735Z","iopub.execute_input":"2022-08-11T19:58:42.091102Z","iopub.status.idle":"2022-08-11T20:13:50.648632Z","shell.execute_reply.started":"2022-08-11T19:58:42.091069Z","shell.execute_reply":"2022-08-11T20:13:50.647613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_grid.best_score_","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:22:21.911872Z","iopub.execute_input":"2022-08-11T20:22:21.912785Z","iopub.status.idle":"2022-08-11T20:22:21.920796Z","shell.execute_reply.started":"2022-08-11T20:22:21.912739Z","shell.execute_reply":"2022-08-11T20:22:21.919773Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"best_grid=cat_grid.best_estimator_\nbest_grid","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:22:31.945213Z","iopub.execute_input":"2022-08-11T20:22:31.945575Z","iopub.status.idle":"2022-08-11T20:22:31.952569Z","shell.execute_reply.started":"2022-08-11T20:22:31.945543Z","shell.execute_reply":"2022-08-11T20:22:31.951376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.drop(columns='ID',axis=1,inplace=True)\ntest_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:22:34.835562Z","iopub.execute_input":"2022-08-11T20:22:34.836166Z","iopub.status.idle":"2022-08-11T20:22:34.866769Z","shell.execute_reply.started":"2022-08-11T20:22:34.836128Z","shell.execute_reply":"2022-08-11T20:22:34.865608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred=best_grid.predict(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:22:53.711807Z","iopub.execute_input":"2022-08-11T20:22:53.712385Z","iopub.status.idle":"2022-08-11T20:22:53.727053Z","shell.execute_reply.started":"2022-08-11T20:22:53.712350Z","shell.execute_reply":"2022-08-11T20:22:53.726000Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:22:57.901236Z","iopub.execute_input":"2022-08-11T20:22:57.901598Z","iopub.status.idle":"2022-08-11T20:22:57.908977Z","shell.execute_reply.started":"2022-08-11T20:22:57.901567Z","shell.execute_reply":"2022-08-11T20:22:57.907823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:24:23.551227Z","iopub.execute_input":"2022-08-11T20:24:23.551599Z","iopub.status.idle":"2022-08-11T20:24:23.563254Z","shell.execute_reply.started":"2022-08-11T20:24:23.551568Z","shell.execute_reply":"2022-08-11T20:24:23.562134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission=pd.DataFrame({'ID':sub_df['ID'],'Class/ASD':y_pred})","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:24:40.417073Z","iopub.execute_input":"2022-08-11T20:24:40.418404Z","iopub.status.idle":"2022-08-11T20:24:40.424636Z","shell.execute_reply.started":"2022-08-11T20:24:40.418361Z","shell.execute_reply":"2022-08-11T20:24:40.423498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('autism_pred.csv',index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:24:42.885701Z","iopub.execute_input":"2022-08-11T20:24:42.886180Z","iopub.status.idle":"2022-08-11T20:24:42.898530Z","shell.execute_reply.started":"2022-08-11T20:24:42.886139Z","shell.execute_reply":"2022-08-11T20:24:42.897242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.count()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:39:09.797767Z","iopub.execute_input":"2022-08-11T20:39:09.798226Z","iopub.status.idle":"2022-08-11T20:39:09.817622Z","shell.execute_reply.started":"2022-08-11T20:39:09.798190Z","shell.execute_reply":"2022-08-11T20:39:09.816736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def feature_count(data):\n    # missing values\n    total_missing = data.isnull().sum().sort_values(ascending = False)\n    percent_missing = (data.isnull().sum()/data.shape[0]*100).sort_values(ascending = False)\n    missing = pd.concat([total_missing, percent_missing], axis=1, keys=['Total', 'Percent'])\n    \n    #unique values \n    total_data = data.count()\n    tt = pd.DataFrame(total_data)\n    tt.columns = ['Total']\n    uniques = []\n    for col in data.columns:\n        unique = data[col].nunique()\n        uniques.append(unique)\n    tt['Uniques'] = uniques\n    unique = tt \n    return pd.concat([missing, unique], axis=1, keys=['Missing', 'UNIQUE'])","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:40:08.299322Z","iopub.execute_input":"2022-08-11T20:40:08.299698Z","iopub.status.idle":"2022-08-11T20:40:08.310024Z","shell.execute_reply.started":"2022-08-11T20:40:08.299666Z","shell.execute_reply":"2022-08-11T20:40:08.308832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"feature_count(train_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:40:21.497801Z","iopub.execute_input":"2022-08-11T20:40:21.498193Z","iopub.status.idle":"2022-08-11T20:40:21.526489Z","shell.execute_reply.started":"2022-08-11T20:40:21.498149Z","shell.execute_reply":"2022-08-11T20:40:21.525434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"feature_count(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:42:50.989355Z","iopub.execute_input":"2022-08-11T20:42:50.989723Z","iopub.status.idle":"2022-08-11T20:42:51.015683Z","shell.execute_reply.started":"2022-08-11T20:42:50.989677Z","shell.execute_reply":"2022-08-11T20:42:51.014552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def cat_num(data):\n    num = list(data._get_numeric_data().columns)\n    cat = [cat for cat in  data.columns if cat not in (num)]\n    print(f\"numerical features : {num}\\ntotal numerical : {len(num)}\\n\\ncategorical features : {cat}\\n total categorical: {len(cat)}\")","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:56:09.427684Z","iopub.execute_input":"2022-08-11T20:56:09.428367Z","iopub.status.idle":"2022-08-11T20:56:09.433824Z","shell.execute_reply.started":"2022-08-11T20:56:09.428332Z","shell.execute_reply":"2022-08-11T20:56:09.432531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_num(train_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T20:56:11.336220Z","iopub.execute_input":"2022-08-11T20:56:11.336780Z","iopub.status.idle":"2022-08-11T20:56:11.343962Z","shell.execute_reply.started":"2022-08-11T20:56:11.336743Z","shell.execute_reply":"2022-08-11T20:56:11.342770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nfrom collections import defaultdict\nd= defaultdict(LabelEncoder)         \nx = train_df[['gender', 'ethnicity', 'jaundice', 'austim', 'contry_of_res', 'used_app_before', 'age_desc', 'relation']]\n\nx=x.apply(lambda x: d[x.name].fit_transform(x))\nx.head()\ntrain_df[['gender', 'ethnicity', 'jaundice', 'austim', 'contry_of_res', 'used_app_before', 'age_desc', 'relation']]=x\ntrain_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:01:13.230866Z","iopub.execute_input":"2022-08-11T21:01:13.231237Z","iopub.status.idle":"2022-08-11T21:01:13.266568Z","shell.execute_reply.started":"2022-08-11T21:01:13.231204Z","shell.execute_reply":"2022-08-11T21:01:13.265507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=train_df.drop(columns='Class/ASD',axis=1)\ny=train_df['Class/ASD']","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:11:40.482617Z","iopub.execute_input":"2022-08-11T21:11:40.483564Z","iopub.status.idle":"2022-08-11T21:11:40.490139Z","shell.execute_reply.started":"2022-08-11T21:11:40.483528Z","shell.execute_reply":"2022-08-11T21:11:40.488989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:04:25.733815Z","iopub.execute_input":"2022-08-11T21:04:25.734790Z","iopub.status.idle":"2022-08-11T21:04:25.763050Z","shell.execute_reply.started":"2022-08-11T21:04:25.734747Z","shell.execute_reply":"2022-08-11T21:04:25.761878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d= defaultdict(LabelEncoder)         \nx = test_df[['gender', 'ethnicity', 'jaundice', 'austim', 'contry_of_res', 'used_app_before', 'age_desc', 'relation']]\n\nx=x.apply(lambda x: d[x.name].fit_transform(x))\nx.head()\ntest_df[['gender', 'ethnicity', 'jaundice', 'austim', 'contry_of_res', 'used_app_before', 'age_desc', 'relation']]=x\ntest_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:04:56.171109Z","iopub.execute_input":"2022-08-11T21:04:56.171461Z","iopub.status.idle":"2022-08-11T21:04:56.201800Z","shell.execute_reply.started":"2022-08-11T21:04:56.171431Z","shell.execute_reply":"2022-08-11T21:04:56.200785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lgbm_params={'boosting_type': 'gbdt',\n 'lambda_l1': 1.4679791331431786,\n 'lambda_l2': 0.008403131421304244,\n 'colsample_bytree': 1.0,\n 'bagging_fraction': 0.6,\n 'feature_fraction': 0.6,\n 'learning_rate': 0.015584305322779072,\n 'max_depth': 7,\n 'num_leaves': 88,\n 'min_child_samples': 56}","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:06:36.740535Z","iopub.execute_input":"2022-08-11T21:06:36.740956Z","iopub.status.idle":"2022-08-11T21:06:36.748798Z","shell.execute_reply.started":"2022-08-11T21:06:36.740921Z","shell.execute_reply":"2022-08-11T21:06:36.747033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(lgbm_params)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:06:47.411936Z","iopub.execute_input":"2022-08-11T21:06:47.412863Z","iopub.status.idle":"2022-08-11T21:06:47.418043Z","shell.execute_reply.started":"2022-08-11T21:06:47.412826Z","shell.execute_reply":"2022-08-11T21:06:47.416188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from lightgbm import LGBMClassifier\nlight=LGBMClassifier(boosting_type='gbdt',\n lambda_l1= 1.4679791331431786,\n lambda_l2= 0.008403131421304244,\n colsample_bytree= 1.0,\n bagging_fraction=0.6,\n feature_fraction= 0.6,\n learning_rate= 0.015584305322779072,\n max_depth= 7,\n num_leaves= 88,\n min_child_samples=56)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:12:05.823535Z","iopub.execute_input":"2022-08-11T21:12:05.824793Z","iopub.status.idle":"2022-08-11T21:12:05.831648Z","shell.execute_reply.started":"2022-08-11T21:12:05.824743Z","shell.execute_reply":"2022-08-11T21:12:05.830052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"light.fit(X,y)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:12:08.860317Z","iopub.execute_input":"2022-08-11T21:12:08.860686Z","iopub.status.idle":"2022-08-11T21:12:08.906380Z","shell.execute_reply.started":"2022-08-11T21:12:08.860654Z","shell.execute_reply":"2022-08-11T21:12:08.905667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred2=light.predict(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:12:25.872133Z","iopub.execute_input":"2022-08-11T21:12:25.872489Z","iopub.status.idle":"2022-08-11T21:12:25.884313Z","shell.execute_reply.started":"2022-08-11T21:12:25.872459Z","shell.execute_reply":"2022-08-11T21:12:25.883424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission2=pd.DataFrame({'ID':sub_df['ID'],'Class/ASD':y_pred2})\nsubmission2.to_csv('austism_pred_2.csv',index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:13:34.886739Z","iopub.execute_input":"2022-08-11T21:13:34.887823Z","iopub.status.idle":"2022-08-11T21:13:34.896086Z","shell.execute_reply.started":"2022-08-11T21:13:34.887776Z","shell.execute_reply":"2022-08-11T21:13:34.894890Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(action='ignore')\nfrom sklearn.preprocessing import PowerTransformer,StandardScaler\ntransformer=PowerTransformer()\nscale=StandardScaler()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:20:13.090445Z","iopub.execute_input":"2022-08-11T21:20:13.090827Z","iopub.status.idle":"2022-08-11T21:20:13.096638Z","shell.execute_reply.started":"2022-08-11T21:20:13.090795Z","shell.execute_reply":"2022-08-11T21:20:13.095578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def transformation(data):\n    data_transform=transformer.fit_transform(data)\n    data=pd.DataFrame(data_transform,columns=data.columns)\n    data_scale=scale.fit_transform(data)\n    data=pd.DataFrame(data_scale,columns=data.columns)\n    return data","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:20:15.898539Z","iopub.execute_input":"2022-08-11T21:20:15.899159Z","iopub.status.idle":"2022-08-11T21:20:15.904757Z","shell.execute_reply.started":"2022-08-11T21:20:15.899123Z","shell.execute_reply":"2022-08-11T21:20:15.903690Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=transformation(X)\nX","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:20:25.639539Z","iopub.execute_input":"2022-08-11T21:20:25.639901Z","iopub.status.idle":"2022-08-11T21:20:25.733044Z","shell.execute_reply.started":"2022-08-11T21:20:25.639869Z","shell.execute_reply":"2022-08-11T21:20:25.731759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df=transformation(test_df)\ntest_df","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:20:52.638903Z","iopub.execute_input":"2022-08-11T21:20:52.639597Z","iopub.status.idle":"2022-08-11T21:20:52.757765Z","shell.execute_reply.started":"2022-08-11T21:20:52.639552Z","shell.execute_reply":"2022-08-11T21:20:52.756690Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"light.fit(X,y)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:21:54.471414Z","iopub.execute_input":"2022-08-11T21:21:54.471823Z","iopub.status.idle":"2022-08-11T21:21:54.517523Z","shell.execute_reply.started":"2022-08-11T21:21:54.471790Z","shell.execute_reply":"2022-08-11T21:21:54.516766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred3=light.predict(test_df)\nsubmission3=pd.DataFrame({'ID':sub_df['ID'],'Class/ASD':y_pred3})\nsubmission3.to_csv('austism_pred_3.csv',index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:22:54.550372Z","iopub.execute_input":"2022-08-11T21:22:54.550753Z","iopub.status.idle":"2022-08-11T21:22:54.564533Z","shell.execute_reply.started":"2022-08-11T21:22:54.550701Z","shell.execute_reply":"2022-08-11T21:22:54.563657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from imblearn.over_sampling import SMOTE\nsmote=SMOTE()\nX_sm,y_sm=smote.fit_resample(X,y)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:23:53.228423Z","iopub.execute_input":"2022-08-11T21:23:53.228837Z","iopub.status.idle":"2022-08-11T21:23:53.256029Z","shell.execute_reply.started":"2022-08-11T21:23:53.228802Z","shell.execute_reply":"2022-08-11T21:23:53.254547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"light.fit(X_sm,y_sm)\ny_pred4=light.predict(test_df)\nsubmission4=pd.DataFrame({'ID':sub_df['ID'],'Class/ASD':y_pred4})\nsubmission4.to_csv('autism_pred_4.csv',index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:26:26.415164Z","iopub.execute_input":"2022-08-11T21:26:26.415535Z","iopub.status.idle":"2022-08-11T21:26:26.473475Z","shell.execute_reply.started":"2022-08-11T21:26:26.415503Z","shell.execute_reply":"2022-08-11T21:26:26.472768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier\nrfg=RandomForestClassifier()\n\nparam_grid={'n_estimators':[650,2000],\n            'criterion':['gini','entropy'],\n            'max_features':[0.76,0.90],\n            'max_depth':[8,11],\n            'max_samples':[0.78,0.92]\n    \n    \n}","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:46:27.839982Z","iopub.execute_input":"2022-08-11T21:46:27.841328Z","iopub.status.idle":"2022-08-11T21:46:27.848802Z","shell.execute_reply.started":"2022-08-11T21:46:27.841281Z","shell.execute_reply":"2022-08-11T21:46:27.847704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import GridSearchCV\nrfg_grid=GridSearchCV(estimator=rfg,param_grid=param_grid,cv=4)\nrfg_grid.fit(X_sm,y_sm)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:46:32.050126Z","iopub.execute_input":"2022-08-11T21:46:32.050501Z","iopub.status.idle":"2022-08-11T21:55:07.345754Z","shell.execute_reply.started":"2022-08-11T21:46:32.050468Z","shell.execute_reply":"2022-08-11T21:55:07.344648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rfg_grid.best_score_","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:55:46.383949Z","iopub.execute_input":"2022-08-11T21:55:46.384305Z","iopub.status.idle":"2022-08-11T21:55:46.391045Z","shell.execute_reply.started":"2022-08-11T21:55:46.384272Z","shell.execute_reply":"2022-08-11T21:55:46.389917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"best_grid=rfg_grid.best_estimator_\nbest_grid","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:55:48.821649Z","iopub.execute_input":"2022-08-11T21:55:48.822333Z","iopub.status.idle":"2022-08-11T21:55:48.829779Z","shell.execute_reply.started":"2022-08-11T21:55:48.822297Z","shell.execute_reply":"2022-08-11T21:55:48.828342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred5=best_grid.predict(test_df)\nsubmission5=pd.DataFrame({'ID':sub_df['ID'],'Class/ASD':y_pred5})\nsubmission5.to_csv('austism_pred_5.csv',index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T21:55:53.111409Z","iopub.execute_input":"2022-08-11T21:55:53.111798Z","iopub.status.idle":"2022-08-11T21:55:53.372912Z","shell.execute_reply.started":"2022-08-11T21:55:53.111758Z","shell.execute_reply":"2022-08-11T21:55:53.371846Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}