{"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":"code","source":"import numpy as np \nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings('ignore')\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.ensemble import RandomForestClassifier\n%matplotlib inline\nimport seaborn as sns\nimport os\nfrom termcolor import colored\nfrom sklearn.preprocessing import LabelEncoder, MinMaxScaler\nfrom sklearn.linear_model import LogisticRegression, SGDClassifier\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.discriminant_analysis import LinearDiscriminantAnalysis\nfrom sklearn.svm import SVC\nfrom sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier\nfrom xgboost import XGBClassifier\nfrom sklearn.model_selection import GridSearchCV as gscv\nfrom sklearn.gaussian_process import GaussianProcessClassifier\nfrom sklearn.gaussian_process.kernels import RBF\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.ensemble import AdaBoostClassifier\nfrom lightgbm import LGBMClassifier\nfrom sklearn.ensemble import VotingClassifier","metadata":{"id":"xhtZIgqlGptU","execution":{"iopub.status.busy":"2022-07-05T09:29:06.427832Z","iopub.execute_input":"2022-07-05T09:29:06.428308Z","iopub.status.idle":"2022-07-05T09:29:06.44636Z","shell.execute_reply.started":"2022-07-05T09:29:06.428271Z","shell.execute_reply":"2022-07-05T09:29:06.444968Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1 = pd.read_csv('../input/spaceship-titanic/train.csv')\ndf1","metadata":{"id":"hsMNnm_TG7WS","outputId":"ef1e9a33-9b4c-43a4-f53a-52b86367d74f","execution":{"iopub.status.busy":"2022-07-05T09:29:06.47184Z","iopub.execute_input":"2022-07-05T09:29:06.473316Z","iopub.status.idle":"2022-07-05T09:29:06.548666Z","shell.execute_reply.started":"2022-07-05T09:29:06.473244Z","shell.execute_reply":"2022-07-05T09:29:06.547797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df2 = pd.read_csv('../input/spaceship-titanic/test.csv')\ndf2","metadata":{"id":"5rfW2oqdG7bQ","outputId":"ca823b35-42bf-44dc-ceb2-b85c4fb9a20a","execution":{"iopub.status.busy":"2022-07-05T09:29:06.55031Z","iopub.execute_input":"2022-07-05T09:29:06.551125Z","iopub.status.idle":"2022-07-05T09:29:06.605227Z","shell.execute_reply.started":"2022-07-05T09:29:06.551092Z","shell.execute_reply":"2022-07-05T09:29:06.603942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Exploratary Data Analysis","metadata":{"id":"_9EGg4zzH02A"}},{"cell_type":"code","source":"df1.head()","metadata":{"id":"VQ69hAxUG7hg","outputId":"d2808078-8888-483a-beb6-b20ef26c423a","execution":{"iopub.status.busy":"2022-07-05T09:29:06.606915Z","iopub.execute_input":"2022-07-05T09:29:06.607702Z","iopub.status.idle":"2022-07-05T09:29:06.633528Z","shell.execute_reply.started":"2022-07-05T09:29:06.607654Z","shell.execute_reply":"2022-07-05T09:29:06.631928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.tail()","metadata":{"id":"EcXGWRojG7lZ","outputId":"5caad219-32d4-4d22-a032-d89866c38263","execution":{"iopub.status.busy":"2022-07-05T09:29:06.635984Z","iopub.execute_input":"2022-07-05T09:29:06.636363Z","iopub.status.idle":"2022-07-05T09:29:06.661218Z","shell.execute_reply.started":"2022-07-05T09:29:06.636333Z","shell.execute_reply":"2022-07-05T09:29:06.659839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.info()","metadata":{"id":"RsUeIqfPH9mE","outputId":"8b2c6daa-2e7e-4f28-8373-3477373e30f9","execution":{"iopub.status.busy":"2022-07-05T09:29:06.662769Z","iopub.execute_input":"2022-07-05T09:29:06.663821Z","iopub.status.idle":"2022-07-05T09:29:06.686433Z","shell.execute_reply.started":"2022-07-05T09:29:06.663768Z","shell.execute_reply":"2022-07-05T09:29:06.684766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.columns","metadata":{"id":"s1ifFlBvIDkn","outputId":"ebc36fcf-42be-4d50-d4e6-aa46355690f1","execution":{"iopub.status.busy":"2022-07-05T09:29:06.688636Z","iopub.execute_input":"2022-07-05T09:29:06.689374Z","iopub.status.idle":"2022-07-05T09:29:06.69537Z","shell.execute_reply.started":"2022-07-05T09:29:06.689338Z","shell.execute_reply":"2022-07-05T09:29:06.694501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.dtypes","metadata":{"id":"_nC_edf2IFzB","outputId":"65f86ece-abaf-4540-fe85-6aa039b10abf","execution":{"iopub.status.busy":"2022-07-05T09:29:06.696955Z","iopub.execute_input":"2022-07-05T09:29:06.697311Z","iopub.status.idle":"2022-07-05T09:29:06.709103Z","shell.execute_reply.started":"2022-07-05T09:29:06.697281Z","shell.execute_reply":"2022-07-05T09:29:06.707894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.describe()","metadata":{"id":"OHNKADRgIHW8","outputId":"8e21713d-41a9-454d-ea24-6b05ffb5bb5f","execution":{"iopub.status.busy":"2022-07-05T09:29:06.720608Z","iopub.execute_input":"2022-07-05T09:29:06.721026Z","iopub.status.idle":"2022-07-05T09:29:06.759476Z","shell.execute_reply.started":"2022-07-05T09:29:06.720991Z","shell.execute_reply":"2022-07-05T09:29:06.758569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.shape","metadata":{"id":"te1LrhclIJTa","outputId":"27fa85a8-6dbc-4119-9acc-2122fe1e3424","execution":{"iopub.status.busy":"2022-07-05T09:29:06.760932Z","iopub.execute_input":"2022-07-05T09:29:06.761579Z","iopub.status.idle":"2022-07-05T09:29:06.768473Z","shell.execute_reply.started":"2022-07-05T09:29:06.761543Z","shell.execute_reply":"2022-07-05T09:29:06.767338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.size","metadata":{"id":"qvdnSOKVIRGV","outputId":"3e380b36-4f11-4a85-9499-5d6f3dd50271","execution":{"iopub.status.busy":"2022-07-05T09:29:06.783271Z","iopub.execute_input":"2022-07-05T09:29:06.783891Z","iopub.status.idle":"2022-07-05T09:29:06.790119Z","shell.execute_reply.started":"2022-07-05T09:29:06.783844Z","shell.execute_reply":"2022-07-05T09:29:06.7887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.ndim","metadata":{"id":"Lvgu28AfIS17","outputId":"0bb76ceb-8c1d-4acf-8344-c454865dd4a6","execution":{"iopub.status.busy":"2022-07-05T09:29:06.808092Z","iopub.execute_input":"2022-07-05T09:29:06.808782Z","iopub.status.idle":"2022-07-05T09:29:06.817197Z","shell.execute_reply.started":"2022-07-05T09:29:06.808732Z","shell.execute_reply":"2022-07-05T09:29:06.815864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Unique Values","metadata":{"id":"NVscI9zUVrqF"}},{"cell_type":"code","source":" for i in df1.columns:\n    print('colum_name',i)\n    print('unique',df1[i].unique())\n    print('\\n')","metadata":{"id":"laASLyR7IU1S","outputId":"c32419ff-bcdc-4dec-b6ca-2d85ead22ad8","execution":{"iopub.status.busy":"2022-07-05T09:29:06.836791Z","iopub.execute_input":"2022-07-05T09:29:06.838256Z","iopub.status.idle":"2022-07-05T09:29:06.861773Z","shell.execute_reply.started":"2022-07-05T09:29:06.838211Z","shell.execute_reply":"2022-07-05T09:29:06.86072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" for i in df1.columns:\n    print('colum_name',i)\n    print('unique',df1[i].nunique())\n    print('\\n')","metadata":{"id":"n-7K7GpNIvgM","outputId":"9b309e5e-adea-4257-ddfd-345db3e081d6","execution":{"iopub.status.busy":"2022-07-05T09:29:06.867843Z","iopub.execute_input":"2022-07-05T09:29:06.869016Z","iopub.status.idle":"2022-07-05T09:29:06.889991Z","shell.execute_reply.started":"2022-07-05T09:29:06.868974Z","shell.execute_reply":"2022-07-05T09:29:06.888682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#value_count\nfor i in df1.columns:\n    print('colum_name',i)\n    print('value_counts',df1[i].value_counts())\n    print(df1[i].to_string())\n    print('\\n')","metadata":{"id":"FpT6Mqh6I4QE","outputId":"ae0f738c-d534-496b-8f99-7a413fa48af2","execution":{"iopub.status.busy":"2022-07-05T09:29:06.945896Z","iopub.execute_input":"2022-07-05T09:29:06.946285Z","iopub.status.idle":"2022-07-05T09:29:09.890992Z","shell.execute_reply.started":"2022-07-05T09:29:06.946253Z","shell.execute_reply":"2022-07-05T09:29:09.88969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.drop(\"Name\",axis=1,inplace = True)","metadata":{"id":"4awogJrvJCsf","execution":{"iopub.status.busy":"2022-07-05T09:29:09.893567Z","iopub.execute_input":"2022-07-05T09:29:09.894206Z","iopub.status.idle":"2022-07-05T09:29:09.902346Z","shell.execute_reply.started":"2022-07-05T09:29:09.89417Z","shell.execute_reply":"2022-07-05T09:29:09.90098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.shape","metadata":{"id":"bZUBUUv8JLGP","outputId":"6ca1f19b-cbab-4b14-a648-1c979cafba28","execution":{"iopub.status.busy":"2022-07-05T09:29:09.904041Z","iopub.execute_input":"2022-07-05T09:29:09.904456Z","iopub.status.idle":"2022-07-05T09:29:09.916242Z","shell.execute_reply.started":"2022-07-05T09:29:09.904413Z","shell.execute_reply":"2022-07-05T09:29:09.915405Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.duplicated().value_counts()","metadata":{"id":"WUxwu129JM2v","outputId":"64703a4b-3c8f-43f1-d23a-a89af8d4d487","execution":{"iopub.status.busy":"2022-07-05T09:29:09.918951Z","iopub.execute_input":"2022-07-05T09:29:09.919311Z","iopub.status.idle":"2022-07-05T09:29:09.945273Z","shell.execute_reply.started":"2022-07-05T09:29:09.91928Z","shell.execute_reply":"2022-07-05T09:29:09.944307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Missing Numbers","metadata":{"id":"e5oFhmSYJVPw"}},{"cell_type":"code","source":"def missing (df1):\n    missing_number = df1.isnull().sum().sort_values(ascending=False)\n    missing_percent = ((df1.isnull().sum()/df1.isnull().count())*100).sort_values(ascending=False)\n    missing_values = pd.concat([missing_number, missing_percent], axis=1, keys=['Missing_Number', 'Missing_Percent'])\n    return missing_values","metadata":{"id":"ZTVV6YcWJQp_","execution":{"iopub.status.busy":"2022-07-05T09:29:09.946734Z","iopub.execute_input":"2022-07-05T09:29:09.94728Z","iopub.status.idle":"2022-07-05T09:29:09.953906Z","shell.execute_reply.started":"2022-07-05T09:29:09.947247Z","shell.execute_reply":"2022-07-05T09:29:09.952842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing (df1)","metadata":{"id":"Joo7TuNFJaL4","outputId":"8695e5fd-29f8-4f31-e73c-ac46229c38e4","execution":{"iopub.status.busy":"2022-07-05T09:29:09.955314Z","iopub.execute_input":"2022-07-05T09:29:09.955939Z","iopub.status.idle":"2022-07-05T09:29:10.007635Z","shell.execute_reply.started":"2022-07-05T09:29:09.955895Z","shell.execute_reply":"2022-07-05T09:29:10.006346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.columns","metadata":{"id":"YZV6fZLGJeB6","outputId":"56d8f5c3-7a7e-42e8-df7e-62119934b3d3","execution":{"iopub.status.busy":"2022-07-05T09:29:10.009618Z","iopub.execute_input":"2022-07-05T09:29:10.010597Z","iopub.status.idle":"2022-07-05T09:29:10.019246Z","shell.execute_reply.started":"2022-07-05T09:29:10.010545Z","shell.execute_reply":"2022-07-05T09:29:10.018029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Cont Plot for Train Data","metadata":{"id":"MIw33CUzJrKY"}},{"cell_type":"code","source":"sns.countplot(df1.dtypes.map(str))\nplt.show()","metadata":{"id":"afuU4kZSJjiN","outputId":"ea594aa8-6977-4331-cc43-a9ad31c02862","execution":{"iopub.status.busy":"2022-07-05T09:29:10.021537Z","iopub.execute_input":"2022-07-05T09:29:10.022504Z","iopub.status.idle":"2022-07-05T09:29:10.221636Z","shell.execute_reply.started":"2022-07-05T09:29:10.022453Z","shell.execute_reply":"2022-07-05T09:29:10.220415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# fill null values with mean,median ,mode","metadata":{"id":"0kRxchjBKafW"}},{"cell_type":"code","source":"df1.isnull().sum()","metadata":{"id":"MRDFn5k2KS4e","outputId":"d1698ea2-d1a3-4f5c-f6d7-e05102c02f65","execution":{"iopub.status.busy":"2022-07-05T09:29:10.223095Z","iopub.execute_input":"2022-07-05T09:29:10.223463Z","iopub.status.idle":"2022-07-05T09:29:10.239403Z","shell.execute_reply.started":"2022-07-05T09:29:10.223428Z","shell.execute_reply":"2022-07-05T09:29:10.2384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#fill null values with mean,median ,mode\nfor i in df1.columns:\n    if df1[i].dtypes == 'object':\n        df1[i].fillna(df1[i].mode()[0], inplace=True)\n    else:\n        df1[i].fillna(df1[i].median(), inplace=True)\nprint(df1)","metadata":{"id":"BKahrGw0KMCB","outputId":"a0582ddf-1176-45e9-e8d8-231c70888ccd","execution":{"iopub.status.busy":"2022-07-05T09:29:10.243673Z","iopub.execute_input":"2022-07-05T09:29:10.244425Z","iopub.status.idle":"2022-07-05T09:29:10.297874Z","shell.execute_reply.started":"2022-07-05T09:29:10.244365Z","shell.execute_reply":"2022-07-05T09:29:10.2967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#for loop for unique values.\nfor i in df1.columns:\n    print('\\n',i,'\\n',df1[i].unique())","metadata":{"id":"oSzYXqLAeDsp","outputId":"45d63538-e276-4d15-cf04-a0a89f8ad31c","execution":{"iopub.status.busy":"2022-07-05T09:29:10.299335Z","iopub.execute_input":"2022-07-05T09:29:10.29993Z","iopub.status.idle":"2022-07-05T09:29:10.314995Z","shell.execute_reply.started":"2022-07-05T09:29:10.299896Z","shell.execute_reply":"2022-07-05T09:29:10.313855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.dtypes","metadata":{"id":"QE3PVYl5KoYa","outputId":"54b5a423-f2ec-4d33-c05a-bdf40890b810","execution":{"iopub.status.busy":"2022-07-05T09:29:10.316762Z","iopub.execute_input":"2022-07-05T09:29:10.317296Z","iopub.status.idle":"2022-07-05T09:29:10.326909Z","shell.execute_reply.started":"2022-07-05T09:29:10.317263Z","shell.execute_reply":"2022-07-05T09:29:10.325702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install autoviz","metadata":{"id":"BQqShTFqLHDf","outputId":"b844c509-0021-4a33-8dd4-d9f179f6856f","execution":{"iopub.status.busy":"2022-07-05T09:29:10.3286Z","iopub.execute_input":"2022-07-05T09:29:10.32924Z","iopub.status.idle":"2022-07-05T09:29:22.484881Z","shell.execute_reply.started":"2022-07-05T09:29:10.329205Z","shell.execute_reply":"2022-07-05T09:29:22.483767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#importing Autoviz class\nfrom autoviz.AutoViz_Class import AutoViz_Class\nAV = AutoViz_Class()\ndf1_av = AV.AutoViz('../input/spaceship-titanic/train.csv')","metadata":{"id":"6FbfhXpOKt3Z","outputId":"93fffe11-6e00-452f-f1c3-4ced6d9e3a7a","execution":{"iopub.status.busy":"2022-07-05T09:29:22.487234Z","iopub.execute_input":"2022-07-05T09:29:22.488202Z","iopub.status.idle":"2022-07-05T09:29:39.065636Z","shell.execute_reply.started":"2022-07-05T09:29:22.488149Z","shell.execute_reply":"2022-07-05T09:29:39.064525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Splitting numerical data and categorical data in dataset","metadata":{"id":"2o1afy-QMvyF"}},{"cell_type":"code","source":"# finding numerical data and categorical data in dataset\nnumerical= df1.drop(['Transported'], axis=1).select_dtypes('number').columns\n\ncategorical = df1.select_dtypes('object').columns\n\nprint(f'Numerical Columns:  {df1[numerical].columns}')\nprint('\\n')\nprint(f'Categorical Columns: {df1[categorical].columns}')","metadata":{"execution":{"iopub.status.busy":"2022-07-05T09:29:39.067119Z","iopub.execute_input":"2022-07-05T09:29:39.06752Z","iopub.status.idle":"2022-07-05T09:29:39.08473Z","shell.execute_reply.started":"2022-07-05T09:29:39.067487Z","shell.execute_reply":"2022-07-05T09:29:39.083465Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Applying lable encoding New Section","metadata":{"id":"oIdTDJPmLbo8"}},{"cell_type":"code","source":"#Lable Encoding\nle=LabelEncoder()\ndf1['Transported']= le.fit_transform(df1['Transported'])","metadata":{"id":"KNzdo7mLLFKD","execution":{"iopub.status.busy":"2022-07-05T09:29:39.086579Z","iopub.execute_input":"2022-07-05T09:29:39.087317Z","iopub.status.idle":"2022-07-05T09:29:39.097057Z","shell.execute_reply.started":"2022-07-05T09:29:39.087283Z","shell.execute_reply":"2022-07-05T09:29:39.09614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['PassengerId']= le.fit_transform(df1['PassengerId'])","metadata":{"id":"FNUCbHb7eckc","execution":{"iopub.status.busy":"2022-07-05T09:29:39.099123Z","iopub.execute_input":"2022-07-05T09:29:39.09952Z","iopub.status.idle":"2022-07-05T09:29:39.131499Z","shell.execute_reply.started":"2022-07-05T09:29:39.09949Z","shell.execute_reply":"2022-07-05T09:29:39.13022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['HomePlanet'] = le.fit_transform(df1['HomePlanet'])","metadata":{"id":"P6QaGBBvNm8G","execution":{"iopub.status.busy":"2022-07-05T09:29:39.133147Z","iopub.execute_input":"2022-07-05T09:29:39.133511Z","iopub.status.idle":"2022-07-05T09:29:39.142779Z","shell.execute_reply.started":"2022-07-05T09:29:39.133479Z","shell.execute_reply":"2022-07-05T09:29:39.141968Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['Cabin'] = le.fit_transform(df1['Cabin'])","metadata":{"id":"3bXIc7wmNm_8","execution":{"iopub.status.busy":"2022-07-05T09:29:39.144041Z","iopub.execute_input":"2022-07-05T09:29:39.14458Z","iopub.status.idle":"2022-07-05T09:29:39.170591Z","shell.execute_reply.started":"2022-07-05T09:29:39.144546Z","shell.execute_reply":"2022-07-05T09:29:39.169306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['Destination'] =le.fit_transform(df1['Destination'])","metadata":{"id":"9cncwsU1NnDo","execution":{"iopub.status.busy":"2022-07-05T09:29:39.171784Z","iopub.execute_input":"2022-07-05T09:29:39.172704Z","iopub.status.idle":"2022-07-05T09:29:39.185743Z","shell.execute_reply.started":"2022-07-05T09:29:39.172662Z","shell.execute_reply":"2022-07-05T09:29:39.184804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['CryoSleep'] =le.fit_transform(df1['CryoSleep'])","metadata":{"id":"73cUFeq8NnHp","execution":{"iopub.status.busy":"2022-07-05T09:29:39.186988Z","iopub.execute_input":"2022-07-05T09:29:39.187331Z","iopub.status.idle":"2022-07-05T09:29:39.19878Z","shell.execute_reply.started":"2022-07-05T09:29:39.187293Z","shell.execute_reply":"2022-07-05T09:29:39.19775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['VIP'] =le.fit_transform(df1['VIP'])","metadata":{"id":"49zxc9snNnLL","execution":{"iopub.status.busy":"2022-07-05T09:29:39.200172Z","iopub.execute_input":"2022-07-05T09:29:39.20056Z","iopub.status.idle":"2022-07-05T09:29:39.209631Z","shell.execute_reply.started":"2022-07-05T09:29:39.200527Z","shell.execute_reply":"2022-07-05T09:29:39.208486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1","metadata":{"id":"4x-Gsf7BL0Yb","outputId":"13c82cb5-2ede-4892-c04e-6cd69f1f7b52","execution":{"iopub.status.busy":"2022-07-05T09:29:39.211694Z","iopub.execute_input":"2022-07-05T09:29:39.21281Z","iopub.status.idle":"2022-07-05T09:29:39.243554Z","shell.execute_reply.started":"2022-07-05T09:29:39.212767Z","shell.execute_reply":"2022-07-05T09:29:39.242591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Find out statistical values","metadata":{"id":"aFN6TD0WL-0X"}},{"cell_type":"code","source":"for col in df1.columns:\n    if df1[col].dtypes != object:\n        q1 = df1[col].quantile(0.25)\n        q2 = df1[col].quantile(0.50)\n        q3 = df1[col].quantile(0.75)\n        IQR = q3 - q1\n        llp = q1-1.5*IQR\n        ulp = q3+1.5*IQR\n        print('column name',col)\n        print('q1',q1)\n        print('q2',q2)\n        print('q3',q3)\n        print('IQR',IQR)\n        print('llp',llp)\n        print('ulp',ulp)\n        print('mean:',df1[col].mean())\n        print('median:',df1[col].median())\n        print('mode',df1[col].mode()[0])\n        print('skewness:',df1[col].skew())\n        print('kurtosis:',df1[col].kurtosis())\n        print('std',df1[col].std())\n        print('max',df1[col].max())\n        print('min',df1[col].min())\n        print('null_value count:',df1[col].isnull().sum())\n        print('\\n')","metadata":{"id":"s6eMoqDWL2qA","outputId":"9ad79909-26fe-4a3a-fb76-286b8a833d8b","execution":{"iopub.status.busy":"2022-07-05T09:29:39.24505Z","iopub.execute_input":"2022-07-05T09:29:39.245421Z","iopub.status.idle":"2022-07-05T09:29:39.329438Z","shell.execute_reply.started":"2022-07-05T09:29:39.245365Z","shell.execute_reply":"2022-07-05T09:29:39.328321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['Destination'].unique()","metadata":{"id":"v5Z23LBaMExE","outputId":"a33ab6dc-5ae2-4720-a826-45afe19b79bf","execution":{"iopub.status.busy":"2022-07-05T09:29:39.331243Z","iopub.execute_input":"2022-07-05T09:29:39.332207Z","iopub.status.idle":"2022-07-05T09:29:39.339547Z","shell.execute_reply.started":"2022-07-05T09:29:39.332153Z","shell.execute_reply":"2022-07-05T09:29:39.338729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Outliers Count","metadata":{"id":"xhxGQHBKN_E3"}},{"cell_type":"code","source":"Q1 = df1.quantile(0.25)\nQ3 = df1.quantile(0.75)\nIQR = Q3 - Q1\nprint('outliers count of each columns')\n((df1 < (Q1 - 1.5 * IQR)) | (df1 > (Q3 + 1.5 * IQR))).sum()","metadata":{"id":"ZRVaI2A0N7EB","outputId":"b411ef3c-212d-4f1d-d32c-b18d9f8513c4","execution":{"iopub.status.busy":"2022-07-05T09:29:39.340762Z","iopub.execute_input":"2022-07-05T09:29:39.341237Z","iopub.status.idle":"2022-07-05T09:29:39.371342Z","shell.execute_reply.started":"2022-07-05T09:29:39.341208Z","shell.execute_reply":"2022-07-05T09:29:39.370143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Pair Plot","metadata":{"id":"ZhsHw3roOGAg"}},{"cell_type":"code","source":"count=1\nplt.subplots(figsize=(30,25))\nfor i in df1.columns:\n    if df1[i].dtypes!='object':\n        plt.subplot(6,7,count)\n        sns.distplot(df1[i])\n        count+=1\n\nplt.show()","metadata":{"id":"pB3wXfz7OCai","outputId":"0c24f7ce-2ac7-4633-f307-e615707f6065","execution":{"iopub.status.busy":"2022-07-05T09:29:39.372937Z","iopub.execute_input":"2022-07-05T09:29:39.3733Z","iopub.status.idle":"2022-07-05T09:29:42.894509Z","shell.execute_reply.started":"2022-07-05T09:29:39.373269Z","shell.execute_reply":"2022-07-05T09:29:42.893252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"count=1\nplt.subplots(figsize=(30,25))\nfor i in df1.columns:\n    if df1[i].dtypes!='object':\n        plt.subplot(6,7,count)\n        sns.boxplot(df1[i])\n        count+=1\n\nplt.show()","metadata":{"id":"1weHpAWxOI61","outputId":"95ce78b3-d668-4bac-9395-5f005d67d94c","execution":{"iopub.status.busy":"2022-07-05T09:29:42.904077Z","iopub.execute_input":"2022-07-05T09:29:42.90464Z","iopub.status.idle":"2022-07-05T09:29:45.036771Z","shell.execute_reply.started":"2022-07-05T09:29:42.904601Z","shell.execute_reply":"2022-07-05T09:29:45.035397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Correlation","metadata":{"id":"kfkjqX-lObyY"}},{"cell_type":"code","source":"cor = df1.corr()\ncor","metadata":{"id":"mn2_qbTpOYxM","outputId":"85e18ace-fda5-4882-bca3-7d8eb941fd83","execution":{"iopub.status.busy":"2022-07-05T09:29:45.038806Z","iopub.execute_input":"2022-07-05T09:29:45.039282Z","iopub.status.idle":"2022-07-05T09:29:45.070372Z","shell.execute_reply.started":"2022-07-05T09:29:45.039235Z","shell.execute_reply":"2022-07-05T09:29:45.069547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# HeatMap","metadata":{"id":"1IGSWIglOjHP"}},{"cell_type":"code","source":"ax = sns.heatmap(df1.corr(), annot=True)\nplt.show()","metadata":{"id":"t4h2LzRxOf1K","outputId":"fbada63c-c7b4-4725-8a46-b8e3ffe38511","execution":{"iopub.status.busy":"2022-07-05T09:29:45.071627Z","iopub.execute_input":"2022-07-05T09:29:45.072105Z","iopub.status.idle":"2022-07-05T09:29:46.088483Z","shell.execute_reply.started":"2022-07-05T09:29:45.072075Z","shell.execute_reply":"2022-07-05T09:29:46.087328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Feature selection","metadata":{"id":"9SYC-FxwOpAS"}},{"cell_type":"code","source":"X=df1.drop('Transported',axis=1)\ny=df1['Transported']","metadata":{"id":"xxnYjl8_Olja","execution":{"iopub.status.busy":"2022-07-05T09:29:46.090305Z","iopub.execute_input":"2022-07-05T09:29:46.090679Z","iopub.status.idle":"2022-07-05T09:29:46.098771Z","shell.execute_reply.started":"2022-07-05T09:29:46.090647Z","shell.execute_reply":"2022-07-05T09:29:46.097446Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X","metadata":{"id":"lzC6KCO9cyv8","outputId":"34cbf941-a892-4a24-901b-d1b5498bdc0e","execution":{"iopub.status.busy":"2022-07-05T09:29:46.10076Z","iopub.execute_input":"2022-07-05T09:29:46.101259Z","iopub.status.idle":"2022-07-05T09:29:46.131877Z","shell.execute_reply.started":"2022-07-05T09:29:46.101223Z","shell.execute_reply":"2022-07-05T09:29:46.130699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train,Test and Split","metadata":{"id":"ZovChOODOwM1"}},{"cell_type":"code","source":"X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.25,random_state=42)","metadata":{"id":"nBxj8WtfOoKP","execution":{"iopub.status.busy":"2022-07-05T09:29:46.133536Z","iopub.execute_input":"2022-07-05T09:29:46.134002Z","iopub.status.idle":"2022-07-05T09:29:46.143728Z","shell.execute_reply.started":"2022-07-05T09:29:46.133948Z","shell.execute_reply":"2022-07-05T09:29:46.142463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train","metadata":{"id":"F5_26hFAc34h","outputId":"db401f26-6d16-4a92-c4ae-7083e27a2cb6","execution":{"iopub.status.busy":"2022-07-05T09:29:46.145029Z","iopub.execute_input":"2022-07-05T09:29:46.145605Z","iopub.status.idle":"2022-07-05T09:29:46.175424Z","shell.execute_reply.started":"2022-07-05T09:29:46.145562Z","shell.execute_reply":"2022-07-05T09:29:46.174047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define dictionary with model accuracies\nmodel_dict = {}","metadata":{"id":"1gvX8K0OBsa4","execution":{"iopub.status.busy":"2022-07-05T09:29:46.177318Z","iopub.execute_input":"2022-07-05T09:29:46.177969Z","iopub.status.idle":"2022-07-05T09:29:46.183998Z","shell.execute_reply.started":"2022-07-05T09:29:46.177933Z","shell.execute_reply":"2022-07-05T09:29:46.182786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#LGBMClassifier","metadata":{"id":"k9YABjILzhuh","execution":{"iopub.status.busy":"2022-07-05T09:29:46.185458Z","iopub.execute_input":"2022-07-05T09:29:46.185841Z","iopub.status.idle":"2022-07-05T09:29:46.196043Z","shell.execute_reply.started":"2022-07-05T09:29:46.185808Z","shell.execute_reply":"2022-07-05T09:29:46.195186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier_lgbm = LGBMClassifier(random_state=42)\nclassifier_lgbm.fit(X_train, y_train)\ny_pred =classifier_lgbm.predict(X_test)\naccuracy_lgbm = accuracy_score(y_test, y_pred)\nmodel_dict['classifier_lgbm'] = accuracy_lgbm\nprint(accuracy_lgbm)","metadata":{"id":"nNoyk1uHzh2W","outputId":"4e641766-5bd6-4c84-ecad-7a8ea8e7ffe5","execution":{"iopub.status.busy":"2022-07-05T09:29:46.197513Z","iopub.execute_input":"2022-07-05T09:29:46.19797Z","iopub.status.idle":"2022-07-05T09:29:46.412186Z","shell.execute_reply.started":"2022-07-05T09:29:46.197925Z","shell.execute_reply":"2022-07-05T09:29:46.411321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def train_models(X_train, y_train):\n    #use logistic regression\n    from sklearn.linear_model import LogisticRegression\n    log = LogisticRegression(random_state = 0)\n    log.fit(X_train, y_train)\n    y_pred_lr = log.predict(X_test)\n\n\n    #use KNeighbors\n    from sklearn.neighbors import KNeighborsClassifier\n    knn = KNeighborsClassifier(n_neighbors = 5, metric = 'minkowski', p=2)\n    knn.fit(X_train, y_train)\n    y_pred_knn = knn.predict(X_test)\n\n\n    #use SVC (liner kernel)\n    from sklearn.svm import SVC\n    svc_lin = SVC(kernel = 'linear', random_state = 0)\n    svc_lin.fit(X_train, y_train)\n    y_pred_svc_lin = svc_lin.predict(X_test)\n\n\n    #use SVC (RBF kernel)\n    from sklearn.svm import SVC\n    svc_rbf = SVC(kernel = 'rbf', random_state = 0)\n    svc_rbf.fit(X_train, y_train)\n    y_pred_svc_rbf = svc_rbf.predict(X_test)\n\n    #use GaussianNB\n    from sklearn.naive_bayes import GaussianNB\n    gauss = GaussianNB()\n    gauss.fit(X_train, y_train)\n    y_pred_gauss = gauss.predict(X_test)\n    \n\n    #use Decision Tree\n    from sklearn.tree import DecisionTreeClassifier\n    tree = DecisionTreeClassifier(criterion = 'entropy', random_state = 0)\n    tree.fit(X_train, y_train)\n    y_pred_dt = tree.predict(X_test)\n\n    #use the RandomForestClassifier\n    from sklearn.ensemble import RandomForestClassifier\n    forest = RandomForestClassifier(n_estimators = 10, criterion = 'entropy', random_state = 0)\n    forest.fit(X_train, y_train)\n    y_pred_rf = forest.predict(X_test)\n    \n    \n    # build the lightgbm model\n    import lightgbm as lgb\n    clf_lgb = lgb.LGBMClassifier()\n    clf_lgb.fit(X_train, y_train)\n    y_pred_lgbm = clf_lgb.predict(X_test)\n    \n    # use xgbclassifier\n    from xgboost import XGBClassifier\n    xg_clf = XGBClassifier(objective ='reg:linear', colsample_bytree = 0.3, learning_rate = 0.1,\n    max_depth = 5, alpha = 10, n_estimators = 10)\n    xg_clf.fit(X_train,y_train)\n    y_pred_xgb = xg_clf.predict(X_test)\n    \n    #NuSVC\n    from sklearn.svm import NuSVC\n    nsvc=NuSVC()\n    nsvc.fit(X_train, y_train)\n    y_pred_nsvc = nsvc.predict(X_test)\n    \n    #Extra tree classifier\n    from sklearn.ensemble import ExtraTreesClassifier\n    et_clf = ExtraTreesClassifier(n_estimators=100, random_state=0)\n    et_clf.fit(X_train, y_train)\n    y_pred_et = et_clf.predict(X_test)\n    \n    #bagging classifier\n    from sklearn.ensemble import BaggingClassifier\n    bg_clf = BaggingClassifier()\n    bg_clf.fit(X_train,y_train)\n    y_pred_bg=bg_clf.predict(X_test)\n    \n    #label propagation\n    from sklearn.semi_supervised import LabelPropagation\n    lp = LabelPropagation()\n    lp.fit(X_train,y_train)\n    y_pred_lp=lp.predict(X_test)\n    \n    #lebel spreading\n    from sklearn.semi_supervised import LabelSpreading\n    sp = LabelSpreading()\n    sp.fit(X_train,y_train)\n    y_pred_sp=sp.predict(X_test)\n    \n    # calibrated classifier cv\n    from sklearn.calibration import CalibratedClassifierCV\n    base_clf = GaussianNB()\n    calibrated_clf = CalibratedClassifierCV(base_estimator=base_clf, cv=3)\n    calibrated_clf.fit(X_train, y_train)\n    y_pred_clf_cv=calibrated_clf.predict(X_test)\n    \n    #SGD classifier\n    from sklearn.preprocessing import StandardScaler\n    from sklearn.linear_model import SGDClassifier\n    from sklearn.pipeline import make_pipeline\n    clf_sgd = make_pipeline(StandardScaler(),SGDClassifier(max_iter=1000, tol=1e-3))\n    clf_sgd.fit(X_train, y_train)\n    y_pred_sgd=clf_sgd.predict(X_test)\n    \n    \n    \n\n    \n    #print the tranning accurancy of each model\n    from sklearn.metrics import confusion_matrix, accuracy_score\n    print('[0]Logistic Regression Testing Accurancy:', accuracy_score(y_test, y_pred_lr))\n    print('[1]KNeighbors Testing Accurancy: ', accuracy_score(y_test, y_pred_knn))\n    print('[2]SVC (liner kernel) Testing Accurancy: ', accuracy_score(y_test, y_pred_svc_lin))\n    print('[3]SVC (RBF kernel) Testing Accurancy: ', accuracy_score(y_test, y_pred_svc_rbf))\n    print('[4]GaussianNB Testing Accurancy: ', accuracy_score(y_test, y_pred_gauss))\n    print('[5]Decision Tree Testing Accurancy: ', accuracy_score(y_test, y_pred_dt))\n    print('[6]RandomForestClassifier Testing Accurancy: ', accuracy_score(y_test, y_pred_rf))\n    print('[7]LGBMClassifier Testing Accurancy: ', accuracy_score(y_test, y_pred_lgbm))\n    print('[8]XGBClassifier Testing Accurancy: ', accuracy_score(y_test, y_pred_xgb))\n    print('[9]NuSVC Testing Accurancy: ', accuracy_score(y_test, y_pred_nsvc))\n    print('[10]Extra tree classifier Testing Accurancy: ', accuracy_score(y_test, y_pred_et))\n    print('[11]bagging classifier Testing Accurancy: ', accuracy_score(y_test, y_pred_bg))\n    print('[12]label propagation Testing Accurancy: ', accuracy_score(y_test, y_pred_lp))\n    print('[13]lebel spreading Testing Accurancy: ', accuracy_score(y_test, y_pred_sp))\n    print('[14]calibrated classifier cv Testing Accurancy: ', accuracy_score(y_test, y_pred_clf_cv))\n    print('[15]SGD classifier Testing Accurancy: ', accuracy_score(y_test, y_pred_sgd))\n\n\n#    return log, knn, svc_lin, svc_rbf, gauss, tree, forest, clf_lgb, xg_clf, nsvc, et_clf, bg_clf, lp, sp, base_clf, clf_sgd","metadata":{"id":"pqJ_3v-Qe38S","execution":{"iopub.status.busy":"2022-07-05T09:29:46.413496Z","iopub.execute_input":"2022-07-05T09:29:46.414071Z","iopub.status.idle":"2022-07-05T09:29:46.443054Z","shell.execute_reply.started":"2022-07-05T09:29:46.414034Z","shell.execute_reply":"2022-07-05T09:29:46.441829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_models(X_train, y_train)","metadata":{"id":"J1J7L8Xle4Ib","outputId":"c01eeb76-d96b-4364-dc43-66d8c42095bf","execution":{"iopub.status.busy":"2022-07-05T09:29:46.444561Z","iopub.execute_input":"2022-07-05T09:29:46.445288Z","iopub.status.idle":"2022-07-05T09:39:08.935792Z","shell.execute_reply.started":"2022-07-05T09:29:46.445235Z","shell.execute_reply":"2022-07-05T09:39:08.931622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Test Dataset","metadata":{"id":"cWsyUGSQPmnP"}},{"cell_type":"code","source":"a = df2.drop('Name',axis=1)\na.head()","metadata":{"id":"J_JnEx-2cGFb","outputId":"29608f04-6473-44b2-ee7b-5a7822441758","execution":{"iopub.status.busy":"2022-07-05T09:39:08.937562Z","iopub.execute_input":"2022-07-05T09:39:08.938104Z","iopub.status.idle":"2022-07-05T09:39:08.975701Z","shell.execute_reply.started":"2022-07-05T09:39:08.938056Z","shell.execute_reply":"2022-07-05T09:39:08.974531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3 = df2","metadata":{"id":"g_9rMIDvPQPJ","execution":{"iopub.status.busy":"2022-07-05T09:39:08.977483Z","iopub.execute_input":"2022-07-05T09:39:08.978166Z","iopub.status.idle":"2022-07-05T09:39:08.984332Z","shell.execute_reply.started":"2022-07-05T09:39:08.978119Z","shell.execute_reply":"2022-07-05T09:39:08.983244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3","metadata":{"id":"uV58KhV2PFF5","outputId":"e361e2af-7d45-40a3-e476-645d37c3a478","execution":{"iopub.status.busy":"2022-07-05T09:39:08.991459Z","iopub.execute_input":"2022-07-05T09:39:08.995788Z","iopub.status.idle":"2022-07-05T09:39:09.039271Z","shell.execute_reply.started":"2022-07-05T09:39:08.995711Z","shell.execute_reply":"2022-07-05T09:39:09.038278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.shape","metadata":{"id":"K5oQjIF5P58Z","outputId":"f9c6a4d4-3b53-4ae8-fd18-fd9f3fe7f843","execution":{"iopub.status.busy":"2022-07-05T09:39:09.040773Z","iopub.execute_input":"2022-07-05T09:39:09.041853Z","iopub.status.idle":"2022-07-05T09:39:09.04825Z","shell.execute_reply.started":"2022-07-05T09:39:09.041818Z","shell.execute_reply":"2022-07-05T09:39:09.047442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.size","metadata":{"id":"7vBWZbRcP8RF","outputId":"8b23d883-efc3-4bf4-918a-bcfbf129f335","execution":{"iopub.status.busy":"2022-07-05T09:39:09.049482Z","iopub.execute_input":"2022-07-05T09:39:09.050041Z","iopub.status.idle":"2022-07-05T09:39:09.059949Z","shell.execute_reply.started":"2022-07-05T09:39:09.050011Z","shell.execute_reply":"2022-07-05T09:39:09.058679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.dtypes","metadata":{"id":"8gHeTJtEP_0g","outputId":"aa4ac407-f56b-4cac-83f1-dc8b7934e42c","execution":{"iopub.status.busy":"2022-07-05T09:39:09.061525Z","iopub.execute_input":"2022-07-05T09:39:09.061992Z","iopub.status.idle":"2022-07-05T09:39:09.075368Z","shell.execute_reply.started":"2022-07-05T09:39:09.061948Z","shell.execute_reply":"2022-07-05T09:39:09.073809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.nunique()","metadata":{"id":"LAeGPZMUQBTS","outputId":"15a20eb4-1bda-48d4-806d-5547b3258e13","execution":{"iopub.status.busy":"2022-07-05T09:39:09.077301Z","iopub.execute_input":"2022-07-05T09:39:09.078643Z","iopub.status.idle":"2022-07-05T09:39:09.098308Z","shell.execute_reply.started":"2022-07-05T09:39:09.078589Z","shell.execute_reply":"2022-07-05T09:39:09.097001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.isnull().sum()","metadata":{"id":"-KnPaWt9QTL_","outputId":"73e2a636-b770-478c-f27f-7ebdc759e71c","execution":{"iopub.status.busy":"2022-07-05T09:39:09.102363Z","iopub.execute_input":"2022-07-05T09:39:09.102762Z","iopub.status.idle":"2022-07-05T09:39:09.118431Z","shell.execute_reply.started":"2022-07-05T09:39:09.102731Z","shell.execute_reply":"2022-07-05T09:39:09.116797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in df3.columns:\n    if df3[i].dtypes == 'object':\n        df3[i].fillna(df3[i].mode()[0], inplace=True)\n    else:\n        df3[i].fillna(df3[i].mean(), inplace=True)\nprint(df3)","metadata":{"id":"d3vW1j6-Qa8Y","outputId":"0ec8202f-9df8-4f91-9868-cdfc849ad81f","execution":{"iopub.status.busy":"2022-07-05T09:39:09.120282Z","iopub.execute_input":"2022-07-05T09:39:09.121005Z","iopub.status.idle":"2022-07-05T09:39:09.168214Z","shell.execute_reply.started":"2022-07-05T09:39:09.120944Z","shell.execute_reply":"2022-07-05T09:39:09.166778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing(df3)","metadata":{"id":"qlChxiIbQlY2","outputId":"bca42707-0e46-4db8-caa4-1595c60391cb","execution":{"iopub.status.busy":"2022-07-05T09:39:09.170601Z","iopub.execute_input":"2022-07-05T09:39:09.172123Z","iopub.status.idle":"2022-07-05T09:39:09.200428Z","shell.execute_reply.started":"2022-07-05T09:39:09.17207Z","shell.execute_reply":"2022-07-05T09:39:09.198883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.columns","metadata":{"id":"rUe-3NnRQpkl","outputId":"c61ed361-9946-414c-de30-c5359dfacefb","execution":{"iopub.status.busy":"2022-07-05T09:39:09.20197Z","iopub.execute_input":"2022-07-05T09:39:09.202676Z","iopub.status.idle":"2022-07-05T09:39:09.209802Z","shell.execute_reply.started":"2022-07-05T09:39:09.202639Z","shell.execute_reply":"2022-07-05T09:39:09.208792Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3.drop('Name',axis=1,inplace=True)","metadata":{"id":"RY3umzI0a7BK","execution":{"iopub.status.busy":"2022-07-05T09:39:09.212021Z","iopub.execute_input":"2022-07-05T09:39:09.212881Z","iopub.status.idle":"2022-07-05T09:39:09.224821Z","shell.execute_reply.started":"2022-07-05T09:39:09.212832Z","shell.execute_reply":"2022-07-05T09:39:09.223862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Performing Label Encoder","metadata":{"id":"UK9-hX0qQ0XG"}},{"cell_type":"code","source":"#Lable Encoding\nle=LabelEncoder()\ndf3['CryoSleep']= le.fit_transform(df3['CryoSleep'])","metadata":{"id":"CZEInh1hQrQ2","execution":{"iopub.status.busy":"2022-07-05T09:39:09.226218Z","iopub.execute_input":"2022-07-05T09:39:09.226777Z","iopub.status.idle":"2022-07-05T09:39:09.238138Z","shell.execute_reply.started":"2022-07-05T09:39:09.22674Z","shell.execute_reply":"2022-07-05T09:39:09.236908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3['VIP']= le.fit_transform(df3['VIP'])","metadata":{"id":"VvveJidvRBMP","execution":{"iopub.status.busy":"2022-07-05T09:39:09.239853Z","iopub.execute_input":"2022-07-05T09:39:09.240349Z","iopub.status.idle":"2022-07-05T09:39:09.251591Z","shell.execute_reply.started":"2022-07-05T09:39:09.240305Z","shell.execute_reply":"2022-07-05T09:39:09.250479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3['HomePlanet']= le.fit_transform(df3['HomePlanet'])","metadata":{"id":"QxIC0yy-RHdY","execution":{"iopub.status.busy":"2022-07-05T09:39:09.253248Z","iopub.execute_input":"2022-07-05T09:39:09.254081Z","iopub.status.idle":"2022-07-05T09:39:09.2673Z","shell.execute_reply.started":"2022-07-05T09:39:09.254041Z","shell.execute_reply":"2022-07-05T09:39:09.266231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3['Cabin']= le.fit_transform(df3['Cabin'])","metadata":{"id":"SO7IDZVKRHiF","execution":{"iopub.status.busy":"2022-07-05T09:39:09.269072Z","iopub.execute_input":"2022-07-05T09:39:09.270464Z","iopub.status.idle":"2022-07-05T09:39:09.289324Z","shell.execute_reply.started":"2022-07-05T09:39:09.270415Z","shell.execute_reply":"2022-07-05T09:39:09.287829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3['PassengerId']= le.fit_transform(df3['PassengerId'])","metadata":{"id":"YkK9jnXLbKg1","execution":{"iopub.status.busy":"2022-07-05T09:39:09.291594Z","iopub.execute_input":"2022-07-05T09:39:09.292543Z","iopub.status.idle":"2022-07-05T09:39:09.312352Z","shell.execute_reply.started":"2022-07-05T09:39:09.292454Z","shell.execute_reply":"2022-07-05T09:39:09.310892Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3['Destination']= le.fit_transform(df3['Destination'])","metadata":{"id":"ojqx9g-rRHmm","execution":{"iopub.status.busy":"2022-07-05T09:39:09.314415Z","iopub.execute_input":"2022-07-05T09:39:09.315612Z","iopub.status.idle":"2022-07-05T09:39:09.323439Z","shell.execute_reply.started":"2022-07-05T09:39:09.315573Z","shell.execute_reply":"2022-07-05T09:39:09.322215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df3","metadata":{"id":"LYc8wdD6jrbk","outputId":"9a3262ce-fc5e-40cd-8273-14028a58b34a","execution":{"iopub.status.busy":"2022-07-05T09:39:09.324724Z","iopub.execute_input":"2022-07-05T09:39:09.325149Z","iopub.status.idle":"2022-07-05T09:39:09.367164Z","shell.execute_reply.started":"2022-07-05T09:39:09.325112Z","shell.execute_reply":"2022-07-05T09:39:09.365776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Predictions of Test Data","metadata":{"id":"MPE6TPqgRTOZ"}},{"cell_type":"code","source":"valid = classifier_lgbm.predict(df3)","metadata":{"id":"EXX4Ei9SJ8Qo","execution":{"iopub.status.busy":"2022-07-05T09:39:09.369047Z","iopub.execute_input":"2022-07-05T09:39:09.3699Z","iopub.status.idle":"2022-07-05T09:39:09.391453Z","shell.execute_reply.started":"2022-07-05T09:39:09.369843Z","shell.execute_reply":"2022-07-05T09:39:09.390339Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"valid","metadata":{"id":"xjxGfMsORZeY","outputId":"34f8aa2d-8774-46f0-f267-b38f89564ddb","execution":{"iopub.status.busy":"2022-07-05T09:39:09.393157Z","iopub.execute_input":"2022-07-05T09:39:09.393909Z","iopub.status.idle":"2022-07-05T09:39:09.401308Z","shell.execute_reply.started":"2022-07-05T09:39:09.393862Z","shell.execute_reply":"2022-07-05T09:39:09.400434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"k = []\nfor i in range(len(valid)) :\n    if  valid[i] == 1:\n        k.append('True')\n    else :\n        k.append('False')","metadata":{"id":"XvUs9ZRbRdqs","execution":{"iopub.status.busy":"2022-07-05T09:39:09.403422Z","iopub.execute_input":"2022-07-05T09:39:09.404267Z","iopub.status.idle":"2022-07-05T09:39:09.415506Z","shell.execute_reply.started":"2022-07-05T09:39:09.404225Z","shell.execute_reply":"2022-07-05T09:39:09.41448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"k","metadata":{"id":"_B69j4fKRhJV","outputId":"323afb2e-3c88-4fc4-e7f7-ae5f6a0c510a","execution":{"iopub.status.busy":"2022-07-05T09:39:09.417217Z","iopub.execute_input":"2022-07-05T09:39:09.418029Z","iopub.status.idle":"2022-07-05T09:39:09.455847Z","shell.execute_reply.started":"2022-07-05T09:39:09.417984Z","shell.execute_reply":"2022-07-05T09:39:09.454443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d=np.array(k)","metadata":{"id":"tYGkl0-yRjMo","execution":{"iopub.status.busy":"2022-07-05T09:39:09.459218Z","iopub.execute_input":"2022-07-05T09:39:09.459739Z","iopub.status.idle":"2022-07-05T09:39:09.466532Z","shell.execute_reply.started":"2022-07-05T09:39:09.459702Z","shell.execute_reply":"2022-07-05T09:39:09.465192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d","metadata":{"id":"Ndc7wNIiRp14","outputId":"a0261c2e-8968-408f-84b3-21a6288c4ac3","execution":{"iopub.status.busy":"2022-07-05T09:39:09.468174Z","iopub.execute_input":"2022-07-05T09:39:09.46887Z","iopub.status.idle":"2022-07-05T09:39:09.48151Z","shell.execute_reply.started":"2022-07-05T09:39:09.468832Z","shell.execute_reply":"2022-07-05T09:39:09.480211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Find and Check the Output","metadata":{"execution":{"iopub.status.busy":"2022-07-05T09:50:52.148429Z","iopub.execute_input":"2022-07-05T09:50:52.150288Z","iopub.status.idle":"2022-07-05T09:50:52.156153Z","shell.execute_reply.started":"2022-07-05T09:50:52.150205Z","shell.execute_reply":"2022-07-05T09:50:52.155093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame(\n    {'PassengerId':a['PassengerId'] ,\n     'Transported': d},columns=['PassengerId', 'Transported'])","metadata":{"id":"Fr4Kzd1HRtdq","execution":{"iopub.status.busy":"2022-07-05T09:39:09.482931Z","iopub.execute_input":"2022-07-05T09:39:09.484079Z","iopub.status.idle":"2022-07-05T09:39:09.494542Z","shell.execute_reply.started":"2022-07-05T09:39:09.48404Z","shell.execute_reply":"2022-07-05T09:39:09.493146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"id":"aDfyruzhRyLs","outputId":"c2375edb-d4eb-4aee-a671-2b0bf636eda5","execution":{"iopub.status.busy":"2022-07-05T09:39:09.49614Z","iopub.execute_input":"2022-07-05T09:39:09.496775Z","iopub.status.idle":"2022-07-05T09:39:09.519279Z","shell.execute_reply.started":"2022-07-05T09:39:09.496729Z","shell.execute_reply":"2022-07-05T09:39:09.517655Z"},"trusted":true},"execution_count":null,"outputs":[]}]}