{"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 sb\nimport matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:19:59.243647Z","iopub.execute_input":"2022-07-12T12:19:59.244619Z","iopub.status.idle":"2022-07-12T12:20:00.522587Z","shell.execute_reply.started":"2022-07-12T12:19:59.244505Z","shell.execute_reply":"2022-07-12T12:20:00.521213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('../input/spaceship-titanic/train.csv')\ntest = pd.read_csv('../input/spaceship-titanic/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.524646Z","iopub.execute_input":"2022-07-12T12:20:00.525082Z","iopub.status.idle":"2022-07-12T12:20:00.622037Z","shell.execute_reply.started":"2022-07-12T12:20:00.525046Z","shell.execute_reply":"2022-07-12T12:20:00.620499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = train.append(test, ignore_index=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.623946Z","iopub.execute_input":"2022-07-12T12:20:00.624381Z","iopub.status.idle":"2022-07-12T12:20:00.650439Z","shell.execute_reply.started":"2022-07-12T12:20:00.624346Z","shell.execute_reply":"2022-07-12T12:20:00.649311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.653248Z","iopub.execute_input":"2022-07-12T12:20:00.653985Z","iopub.status.idle":"2022-07-12T12:20:00.664221Z","shell.execute_reply.started":"2022-07-12T12:20:00.653947Z","shell.execute_reply":"2022-07-12T12:20:00.662632Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop('Name', axis='columns', inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.666355Z","iopub.execute_input":"2022-07-12T12:20:00.667248Z","iopub.status.idle":"2022-07-12T12:20:00.687353Z","shell.execute_reply.started":"2022-07-12T12:20:00.667203Z","shell.execute_reply":"2022-07-12T12:20:00.685718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Cabin'].str.split('/', expand=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.689347Z","iopub.execute_input":"2022-07-12T12:20:00.689864Z","iopub.status.idle":"2022-07-12T12:20:00.751954Z","shell.execute_reply.started":"2022-07-12T12:20:00.689818Z","shell.execute_reply":"2022-07-12T12:20:00.750782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[['deck', 'num', 'side']] = df['Cabin'].str.split('/', expand=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.753602Z","iopub.execute_input":"2022-07-12T12:20:00.755009Z","iopub.status.idle":"2022-07-12T12:20:00.798699Z","shell.execute_reply.started":"2022-07-12T12:20:00.754931Z","shell.execute_reply":"2022-07-12T12:20:00.797318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.800567Z","iopub.execute_input":"2022-07-12T12:20:00.800922Z","iopub.status.idle":"2022-07-12T12:20:00.836742Z","shell.execute_reply.started":"2022-07-12T12:20:00.800892Z","shell.execute_reply":"2022-07-12T12:20:00.835842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nlabelencoder = LabelEncoder()","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:00.837813Z","iopub.execute_input":"2022-07-12T12:20:00.839027Z","iopub.status.idle":"2022-07-12T12:20:01.017616Z","shell.execute_reply.started":"2022-07-12T12:20:00.838993Z","shell.execute_reply":"2022-07-12T12:20:01.016393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['side'] = labelencoder.fit_transform(df['side'])","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.022061Z","iopub.execute_input":"2022-07-12T12:20:01.023081Z","iopub.status.idle":"2022-07-12T12:20:01.033646Z","shell.execute_reply.started":"2022-07-12T12:20:01.023046Z","shell.execute_reply":"2022-07-12T12:20:01.032271Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['HomePlanet'] = labelencoder.fit_transform(df['HomePlanet'])\ndf['VIP'] = labelencoder.fit_transform(df['VIP'])\ndf['CryoSleep'] = labelencoder.fit_transform(df['CryoSleep'])","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.034955Z","iopub.execute_input":"2022-07-12T12:20:01.035599Z","iopub.status.idle":"2022-07-12T12:20:01.063197Z","shell.execute_reply.started":"2022-07-12T12:20:01.035563Z","shell.execute_reply":"2022-07-12T12:20:01.061481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Destination'] = labelencoder.fit_transform(df['Destination'])","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.065605Z","iopub.execute_input":"2022-07-12T12:20:01.066037Z","iopub.status.idle":"2022-07-12T12:20:01.077548Z","shell.execute_reply.started":"2022-07-12T12:20:01.065999Z","shell.execute_reply":"2022-07-12T12:20:01.076495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"ShoppingMall\"].fillna(value=df['ShoppingMall'].mean(), inplace=True)\ndf[\"Spa\"].fillna(value= df['Spa'].mean(), inplace=True)\ndf[\"FoodCourt\"].fillna(value=df['ShoppingMall'].mean(), inplace=True)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.079244Z","iopub.execute_input":"2022-07-12T12:20:01.080430Z","iopub.status.idle":"2022-07-12T12:20:01.093103Z","shell.execute_reply.started":"2022-07-12T12:20:01.080393Z","shell.execute_reply":"2022-07-12T12:20:01.091778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"VRDeck\"].fillna(value=df['VRDeck'].mean(), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.096143Z","iopub.execute_input":"2022-07-12T12:20:01.097539Z","iopub.status.idle":"2022-07-12T12:20:01.106496Z","shell.execute_reply.started":"2022-07-12T12:20:01.097483Z","shell.execute_reply":"2022-07-12T12:20:01.104880Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"RoomService\"].fillna(value=df['RoomService'].mean(), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.108476Z","iopub.execute_input":"2022-07-12T12:20:01.108931Z","iopub.status.idle":"2022-07-12T12:20:01.120411Z","shell.execute_reply.started":"2022-07-12T12:20:01.108895Z","shell.execute_reply":"2022-07-12T12:20:01.119313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"Age\"].fillna(value=df['Age'].mean(), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.122035Z","iopub.execute_input":"2022-07-12T12:20:01.122525Z","iopub.status.idle":"2022-07-12T12:20:01.132388Z","shell.execute_reply.started":"2022-07-12T12:20:01.122473Z","shell.execute_reply":"2022-07-12T12:20:01.131287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_num = df[['Age', 'RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck', 'Transported']]\ndf_cat = df[['HomePlanet', 'CryoSleep', 'Destination', 'VIP', 'Transported']]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.133980Z","iopub.execute_input":"2022-07-12T12:20:01.134578Z","iopub.status.idle":"2022-07-12T12:20:01.152603Z","shell.execute_reply.started":"2022-07-12T12:20:01.134543Z","shell.execute_reply":"2022-07-12T12:20:01.151135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.154789Z","iopub.execute_input":"2022-07-12T12:20:01.156211Z","iopub.status.idle":"2022-07-12T12:20:01.161814Z","shell.execute_reply.started":"2022-07-12T12:20:01.156159Z","shell.execute_reply":"2022-07-12T12:20:01.160669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(df_num, hue='Transported')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:01.163674Z","iopub.execute_input":"2022-07-12T12:20:01.164451Z","iopub.status.idle":"2022-07-12T12:20:26.487719Z","shell.execute_reply.started":"2022-07-12T12:20:01.164409Z","shell.execute_reply":"2022-07-12T12:20:26.486219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\n%matplotlib inline","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:26.489402Z","iopub.execute_input":"2022-07-12T12:20:26.489789Z","iopub.status.idle":"2022-07-12T12:20:28.016446Z","shell.execute_reply.started":"2022-07-12T12:20:26.489736Z","shell.execute_reply":"2022-07-12T12:20:28.015098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def strip_plot(df, x, y):\n    ax = sns.stripplot(x=df[x], y=df[y])\n    plt.title(str(y),\n          fontsize = 18,\n          fontweight = 'bold',\n          fontfamily = 'serif',\n          loc = 'left')\n    \n    ax.set(xlabel=None, ylabel=None)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.018066Z","iopub.execute_input":"2022-07-12T12:20:28.018522Z","iopub.status.idle":"2022-07-12T12:20:28.026354Z","shell.execute_reply.started":"2022-07-12T12:20:28.018489Z","shell.execute_reply":"2022-07-12T12:20:28.025015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(15, 15))\nplt.subplot(3, 2, 1)\nstrip_plot(train, 'Transported', 'RoomService')\n\nplt.subplot(3, 2, 2)\nstrip_plot(train, 'Transported', 'FoodCourt')\n\nplt.subplot(3, 2, 3)\nstrip_plot(train, 'Transported', 'Spa')\n\nplt.subplot(3, 2, 4)\nstrip_plot(train, 'Transported', 'ShoppingMall')\n\nplt.subplot(3, 2, 5)\nstrip_plot(train, 'Transported', 'VRDeck')","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.028434Z","iopub.execute_input":"2022-07-12T12:20:28.029595Z","iopub.status.idle":"2022-07-12T12:20:28.811945Z","shell.execute_reply.started":"2022-07-12T12:20:28.029540Z","shell.execute_reply":"2022-07-12T12:20:28.810650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Premium'] = df['RoomService'] + df['Spa'] + df['VRDeck']","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.813452Z","iopub.execute_input":"2022-07-12T12:20:28.813844Z","iopub.status.idle":"2022-07-12T12:20:28.822587Z","shell.execute_reply.started":"2022-07-12T12:20:28.813811Z","shell.execute_reply":"2022-07-12T12:20:28.821273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Basic'] = df['FoodCourt'] + df['ShoppingMall']","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.824567Z","iopub.execute_input":"2022-07-12T12:20:28.825073Z","iopub.status.idle":"2022-07-12T12:20:28.835586Z","shell.execute_reply.started":"2022-07-12T12:20:28.825017Z","shell.execute_reply":"2022-07-12T12:20:28.834326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.837220Z","iopub.execute_input":"2022-07-12T12:20:28.837863Z","iopub.status.idle":"2022-07-12T12:20:28.877200Z","shell.execute_reply.started":"2022-07-12T12:20:28.837828Z","shell.execute_reply":"2022-07-12T12:20:28.876340Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.878613Z","iopub.execute_input":"2022-07-12T12:20:28.879191Z","iopub.status.idle":"2022-07-12T12:20:28.898141Z","shell.execute_reply.started":"2022-07-12T12:20:28.879158Z","shell.execute_reply":"2022-07-12T12:20:28.896502Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Destination'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.900151Z","iopub.execute_input":"2022-07-12T12:20:28.900512Z","iopub.status.idle":"2022-07-12T12:20:28.909570Z","shell.execute_reply.started":"2022-07-12T12:20:28.900483Z","shell.execute_reply":"2022-07-12T12:20:28.908595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['deck'].fillna(\"F\", inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.918683Z","iopub.execute_input":"2022-07-12T12:20:28.919590Z","iopub.status.idle":"2022-07-12T12:20:28.929804Z","shell.execute_reply.started":"2022-07-12T12:20:28.919540Z","shell.execute_reply":"2022-07-12T12:20:28.928095Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Destination'].fillna(\"TRAPPIST-1e\", inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.931611Z","iopub.execute_input":"2022-07-12T12:20:28.932209Z","iopub.status.idle":"2022-07-12T12:20:28.940660Z","shell.execute_reply.started":"2022-07-12T12:20:28.932156Z","shell.execute_reply":"2022-07-12T12:20:28.939627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['num'].fillna(\"82\", inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.942886Z","iopub.execute_input":"2022-07-12T12:20:28.943633Z","iopub.status.idle":"2022-07-12T12:20:28.956470Z","shell.execute_reply.started":"2022-07-12T12:20:28.943593Z","shell.execute_reply":"2022-07-12T12:20:28.955060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop('Cabin', axis='columns', inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.957893Z","iopub.execute_input":"2022-07-12T12:20:28.959125Z","iopub.status.idle":"2022-07-12T12:20:28.970082Z","shell.execute_reply.started":"2022-07-12T12:20:28.959068Z","shell.execute_reply":"2022-07-12T12:20:28.968868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop('num', axis='columns', inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.971872Z","iopub.execute_input":"2022-07-12T12:20:28.972511Z","iopub.status.idle":"2022-07-12T12:20:28.979338Z","shell.execute_reply.started":"2022-07-12T12:20:28.972480Z","shell.execute_reply":"2022-07-12T12:20:28.978416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.set_index('PassengerId')","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.980835Z","iopub.execute_input":"2022-07-12T12:20:28.981585Z","iopub.status.idle":"2022-07-12T12:20:28.990921Z","shell.execute_reply.started":"2022-07-12T12:20:28.981550Z","shell.execute_reply":"2022-07-12T12:20:28.989837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Adult'] = (df['Age'] > 18).astype(int)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:28.992671Z","iopub.execute_input":"2022-07-12T12:20:28.993037Z","iopub.status.idle":"2022-07-12T12:20:29.002819Z","shell.execute_reply.started":"2022-07-12T12:20:28.993008Z","shell.execute_reply":"2022-07-12T12:20:29.001852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spending = ['RoomService', 'FoodCourt', 'ShoppingMall', 'VRDeck', 'Spa']\ndf['TotalSpend'] = df[spending].sum(axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.004647Z","iopub.execute_input":"2022-07-12T12:20:29.005449Z","iopub.status.idle":"2022-07-12T12:20:29.018573Z","shell.execute_reply.started":"2022-07-12T12:20:29.005403Z","shell.execute_reply":"2022-07-12T12:20:29.017546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.020417Z","iopub.execute_input":"2022-07-12T12:20:29.021231Z","iopub.status.idle":"2022-07-12T12:20:29.060734Z","shell.execute_reply.started":"2022-07-12T12:20:29.021186Z","shell.execute_reply":"2022-07-12T12:20:29.059649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = df[df.Transported.isna() == False]\ntest_df= df[df.Transported.isna()]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.062285Z","iopub.execute_input":"2022-07-12T12:20:29.062983Z","iopub.status.idle":"2022-07-12T12:20:29.075435Z","shell.execute_reply.started":"2022-07-12T12:20:29.062943Z","shell.execute_reply":"2022-07-12T12:20:29.074194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['Transported']= labelencoder.fit_transform(train_df['Transported'])","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.077254Z","iopub.execute_input":"2022-07-12T12:20:29.077899Z","iopub.status.idle":"2022-07-12T12:20:29.087560Z","shell.execute_reply.started":"2022-07-12T12:20:29.077866Z","shell.execute_reply":"2022-07-12T12:20:29.086370Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df['deck']= labelencoder.fit_transform(train_df['deck'])","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.089483Z","iopub.execute_input":"2022-07-12T12:20:29.090631Z","iopub.status.idle":"2022-07-12T12:20:29.102651Z","shell.execute_reply.started":"2022-07-12T12:20:29.090569Z","shell.execute_reply":"2022-07-12T12:20:29.101173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['deck']= labelencoder.fit_transform(test_df['deck'])","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.104390Z","iopub.execute_input":"2022-07-12T12:20:29.105977Z","iopub.status.idle":"2022-07-12T12:20:29.116298Z","shell.execute_reply.started":"2022-07-12T12:20:29.105919Z","shell.execute_reply":"2022-07-12T12:20:29.115239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.118538Z","iopub.execute_input":"2022-07-12T12:20:29.119096Z","iopub.status.idle":"2022-07-12T12:20:29.158239Z","shell.execute_reply.started":"2022-07-12T12:20:29.119044Z","shell.execute_reply":"2022-07-12T12:20:29.157038Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nsns.set_theme(font_scale=3)\nplt.figure(figsize=(50,50))\nsns.heatmap(df.corr(), annot=True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:29.160336Z","iopub.execute_input":"2022-07-12T12:20:29.161212Z","iopub.status.idle":"2022-07-12T12:20:31.133330Z","shell.execute_reply.started":"2022-07-12T12:20:29.161163Z","shell.execute_reply":"2022-07-12T12:20:31.131842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# LR","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\nfrom sklearn.metrics import confusion_matrix, classification_report\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.135154Z","iopub.execute_input":"2022-07-12T12:20:31.135652Z","iopub.status.idle":"2022-07-12T12:20:31.300475Z","shell.execute_reply.started":"2022-07-12T12:20:31.135600Z","shell.execute_reply":"2022-07-12T12:20:31.299335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X= train_df.drop(labels = 'Transported',axis = 1).values\ny= train_df.Transported","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.301941Z","iopub.execute_input":"2022-07-12T12:20:31.302369Z","iopub.status.idle":"2022-07-12T12:20:31.312931Z","shell.execute_reply.started":"2022-07-12T12:20:31.302334Z","shell.execute_reply":"2022-07-12T12:20:31.311051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.315169Z","iopub.execute_input":"2022-07-12T12:20:31.315588Z","iopub.status.idle":"2022-07-12T12:20:31.328173Z","shell.execute_reply.started":"2022-07-12T12:20:31.315553Z","shell.execute_reply":"2022-07-12T12:20:31.327075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lg = LogisticRegression()\nlg.fit(X_train,y_train)\nlg_pred = lg.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.329829Z","iopub.execute_input":"2022-07-12T12:20:31.331061Z","iopub.status.idle":"2022-07-12T12:20:31.485285Z","shell.execute_reply.started":"2022-07-12T12:20:31.331015Z","shell.execute_reply":"2022-07-12T12:20:31.483790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", lg.score(X_train, y_train))\nprint(\"Testing Accuracy :\", lg.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.487186Z","iopub.execute_input":"2022-07-12T12:20:31.488379Z","iopub.status.idle":"2022-07-12T12:20:31.507244Z","shell.execute_reply.started":"2022-07-12T12:20:31.488321Z","shell.execute_reply":"2022-07-12T12:20:31.505774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testdf= test_df.drop(labels='Transported', axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.509459Z","iopub.execute_input":"2022-07-12T12:20:31.510316Z","iopub.status.idle":"2022-07-12T12:20:31.520269Z","shell.execute_reply.started":"2022-07-12T12:20:31.510262Z","shell.execute_reply":"2022-07-12T12:20:31.518790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_test =lg.predict_proba(test_df.drop('Transported' , axis = 1 ))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.522751Z","iopub.execute_input":"2022-07-12T12:20:31.523397Z","iopub.status.idle":"2022-07-12T12:20:31.541008Z","shell.execute_reply.started":"2022-07-12T12:20:31.523343Z","shell.execute_reply":"2022-07-12T12:20:31.539460Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testdf","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.543355Z","iopub.execute_input":"2022-07-12T12:20:31.544451Z","iopub.status.idle":"2022-07-12T12:20:31.603145Z","shell.execute_reply.started":"2022-07-12T12:20:31.544187Z","shell.execute_reply":"2022-07-12T12:20:31.601774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# GBC","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import GradientBoostingClassifier\nGB=GradientBoostingClassifier(random_state=42, learning_rate=0.1, max_depth=5, max_features=0.7000000000000001,\n                                 min_samples_leaf=18, min_samples_split=11, n_estimators=100, subsample=0.7500000000000001)\nGB.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:31.605331Z","iopub.execute_input":"2022-07-12T12:20:31.606192Z","iopub.status.idle":"2022-07-12T12:20:33.000463Z","shell.execute_reply.started":"2022-07-12T12:20:31.606142Z","shell.execute_reply":"2022-07-12T12:20:32.999381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predtest = GB.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:33.002653Z","iopub.execute_input":"2022-07-12T12:20:33.003537Z","iopub.status.idle":"2022-07-12T12:20:33.024479Z","shell.execute_reply.started":"2022-07-12T12:20:33.003495Z","shell.execute_reply":"2022-07-12T12:20:33.023072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", GB.score(X_train, y_train))\nprint(\"Testing Accuracy :\", GB.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:33.026097Z","iopub.execute_input":"2022-07-12T12:20:33.026483Z","iopub.status.idle":"2022-07-12T12:20:33.065068Z","shell.execute_reply.started":"2022-07-12T12:20:33.026450Z","shell.execute_reply":"2022-07-12T12:20:33.063837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# XGBOOST","metadata":{}},{"cell_type":"code","source":"import xgboost as xgb\nxgb= xgb.XGBClassifier(n_estimators=100, random_state=42, learning_rate=0.05, n_jobs=4 )\nxgb.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:33.066457Z","iopub.execute_input":"2022-07-12T12:20:33.066797Z","iopub.status.idle":"2022-07-12T12:20:34.321059Z","shell.execute_reply.started":"2022-07-12T12:20:33.066742Z","shell.execute_reply":"2022-07-12T12:20:34.320042Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = xgb.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:34.325072Z","iopub.execute_input":"2022-07-12T12:20:34.326374Z","iopub.status.idle":"2022-07-12T12:20:34.339902Z","shell.execute_reply.started":"2022-07-12T12:20:34.326320Z","shell.execute_reply":"2022-07-12T12:20:34.338217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_xgbtest = xgb.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:34.342226Z","iopub.execute_input":"2022-07-12T12:20:34.342728Z","iopub.status.idle":"2022-07-12T12:20:34.360002Z","shell.execute_reply.started":"2022-07-12T12:20:34.342687Z","shell.execute_reply":"2022-07-12T12:20:34.359010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", xgb.score(X_train, y_train))\nprint(\"Testing Accuracy :\", xgb.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:34.361740Z","iopub.execute_input":"2022-07-12T12:20:34.363119Z","iopub.status.idle":"2022-07-12T12:20:34.394334Z","shell.execute_reply.started":"2022-07-12T12:20:34.363072Z","shell.execute_reply":"2022-07-12T12:20:34.393320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# LGBM","metadata":{}},{"cell_type":"code","source":"import lightgbm as ltb\nlgbm = ltb.LGBMClassifier(max_depth=6, random_state=314, silent=True, metric='None', n_jobs=6, n_estimators=100)\n\nlgbm.fit(X_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:34.398463Z","iopub.execute_input":"2022-07-12T12:20:34.401049Z","iopub.status.idle":"2022-07-12T12:20:35.832227Z","shell.execute_reply.started":"2022-07-12T12:20:34.401001Z","shell.execute_reply":"2022-07-12T12:20:35.831001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predlgbm = lgbm.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:35.834970Z","iopub.execute_input":"2022-07-12T12:20:35.835513Z","iopub.status.idle":"2022-07-12T12:20:35.847187Z","shell.execute_reply.started":"2022-07-12T12:20:35.835466Z","shell.execute_reply":"2022-07-12T12:20:35.845331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_lgbmtest = lgbm.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:35.850624Z","iopub.execute_input":"2022-07-12T12:20:35.851932Z","iopub.status.idle":"2022-07-12T12:20:35.871168Z","shell.execute_reply.started":"2022-07-12T12:20:35.851896Z","shell.execute_reply":"2022-07-12T12:20:35.869855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", lgbm.score(X_train, y_train))\nprint(\"Testing Accuracy :\", lgbm.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:35.873886Z","iopub.execute_input":"2022-07-12T12:20:35.874802Z","iopub.status.idle":"2022-07-12T12:20:35.907401Z","shell.execute_reply.started":"2022-07-12T12:20:35.874744Z","shell.execute_reply":"2022-07-12T12:20:35.906264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# RF","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import accuracy_score\n\nrf = RandomForestClassifier(n_estimators=100,max_depth = 12)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:35.908933Z","iopub.execute_input":"2022-07-12T12:20:35.909335Z","iopub.status.idle":"2022-07-12T12:20:35.916423Z","shell.execute_reply.started":"2022-07-12T12:20:35.909280Z","shell.execute_reply":"2022-07-12T12:20:35.915351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf.fit(X_train, y_train)\ny_rf = rf.predict(X_test)\ny_predrf = rf.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:35.917902Z","iopub.execute_input":"2022-07-12T12:20:35.919344Z","iopub.status.idle":"2022-07-12T12:20:36.946387Z","shell.execute_reply.started":"2022-07-12T12:20:35.919304Z","shell.execute_reply":"2022-07-12T12:20:36.944960Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", rf.score(X_train, y_train))\nprint(\"Testing Accuracy :\", rf.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:36.947919Z","iopub.execute_input":"2022-07-12T12:20:36.948236Z","iopub.status.idle":"2022-07-12T12:20:37.119604Z","shell.execute_reply.started":"2022-07-12T12:20:36.948208Z","shell.execute_reply":"2022-07-12T12:20:37.118127Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# CATboost","metadata":{}},{"cell_type":"code","source":"from catboost import CatBoostClassifier","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:37.121452Z","iopub.execute_input":"2022-07-12T12:20:37.124192Z","iopub.status.idle":"2022-07-12T12:20:37.347813Z","shell.execute_reply.started":"2022-07-12T12:20:37.124121Z","shell.execute_reply":"2022-07-12T12:20:37.346464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = CatBoostClassifier(random_state=42, iterations=10000,eval_metric='Accuracy',verbose=1000)  \nclf.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:20:37.349492Z","iopub.execute_input":"2022-07-12T12:20:37.349977Z","iopub.status.idle":"2022-07-12T12:21:25.245662Z","shell.execute_reply.started":"2022-07-12T12:20:37.349932Z","shell.execute_reply":"2022-07-12T12:21:25.244679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predcat = clf.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:21:25.247491Z","iopub.execute_input":"2022-07-12T12:21:25.248281Z","iopub.status.idle":"2022-07-12T12:21:25.287431Z","shell.execute_reply.started":"2022-07-12T12:21:25.248233Z","shell.execute_reply":"2022-07-12T12:21:25.285741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", clf.score(X_train, y_train))\nprint(\"Testing Accuracy :\", clf.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:21:25.289978Z","iopub.execute_input":"2022-07-12T12:21:25.290687Z","iopub.status.idle":"2022-07-12T12:21:25.419486Z","shell.execute_reply.started":"2022-07-12T12:21:25.290633Z","shell.execute_reply":"2022-07-12T12:21:25.418245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# CVGRID","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import GridSearchCV","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:21:25.421086Z","iopub.execute_input":"2022-07-12T12:21:25.422533Z","iopub.status.idle":"2022-07-12T12:21:25.429614Z","shell.execute_reply.started":"2022-07-12T12:21:25.422485Z","shell.execute_reply":"2022-07-12T12:21:25.428147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"parameters = {\n    \"n_estimators\": [5, 10, 15, 20, 25], \n    \"max_depth\": [3, 5, 7, 9, 11, 12],\n    \"min_samples_leaf\" : [18, 19, 20],\n    \"min_samples_split\" : [8, 9, 10]\n}\n\n\nRFC_Model = RandomForestClassifier()\nRFC_grid = GridSearchCV(RFC_Model, param_grid = parameters, cv = 5, scoring = 'accuracy', n_jobs= -1)\nRFC_grid.fit(X_train, y_train)\nprint('Best Parameters : ', RFC_grid.best_params_)\nprint()\nprint('Best Accuracy : ', RFC_grid.best_score_)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:21:25.431723Z","iopub.execute_input":"2022-07-12T12:21:25.432242Z","iopub.status.idle":"2022-07-12T12:22:16.558610Z","shell.execute_reply.started":"2022-07-12T12:21:25.432199Z","shell.execute_reply":"2022-07-12T12:22:16.555969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"RFC_Model = RandomForestClassifier(**RFC_grid.best_params_)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:26:13.323367Z","iopub.execute_input":"2022-07-12T12:26:13.323855Z","iopub.status.idle":"2022-07-12T12:26:13.333015Z","shell.execute_reply.started":"2022-07-12T12:26:13.323816Z","shell.execute_reply":"2022-07-12T12:26:13.331779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_grid = RFC_grid.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.560528Z","iopub.execute_input":"2022-07-12T12:22:16.561020Z","iopub.status.idle":"2022-07-12T12:22:16.580909Z","shell.execute_reply.started":"2022-07-12T12:22:16.560974Z","shell.execute_reply":"2022-07-12T12:22:16.579708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", RFC_grid.score(X_train, y_train))\nprint(\"Testing Accuracy :\", RFC_grid.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.582730Z","iopub.execute_input":"2022-07-12T12:22:16.583292Z","iopub.status.idle":"2022-07-12T12:22:16.613281Z","shell.execute_reply.started":"2022-07-12T12:22:16.583237Z","shell.execute_reply":"2022-07-12T12:22:16.611978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf1 = RandomForestClassifier(max_depth= 11,min_samples_leaf= 18, min_samples_split=10, n_estimators= 25)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.615312Z","iopub.execute_input":"2022-07-12T12:22:16.616188Z","iopub.status.idle":"2022-07-12T12:22:16.623282Z","shell.execute_reply.started":"2022-07-12T12:22:16.616143Z","shell.execute_reply":"2022-07-12T12:22:16.621935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf1.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.625152Z","iopub.execute_input":"2022-07-12T12:22:16.625569Z","iopub.status.idle":"2022-07-12T12:22:16.839990Z","shell.execute_reply.started":"2022-07-12T12:22:16.625534Z","shell.execute_reply":"2022-07-12T12:22:16.838434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_rf= rf1.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.842064Z","iopub.execute_input":"2022-07-12T12:22:16.842701Z","iopub.status.idle":"2022-07-12T12:22:16.869645Z","shell.execute_reply.started":"2022-07-12T12:22:16.842649Z","shell.execute_reply":"2022-07-12T12:22:16.868430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", rf1.score(X_train, y_train))\nprint(\"Testing Accuracy :\", rf1.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.873074Z","iopub.execute_input":"2022-07-12T12:22:16.873633Z","iopub.status.idle":"2022-07-12T12:22:16.920924Z","shell.execute_reply.started":"2022-07-12T12:22:16.873586Z","shell.execute_reply":"2022-07-12T12:22:16.919739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# SVM","metadata":{}},{"cell_type":"code","source":"from sklearn.svm import SVC\nclassifier = SVC(random_state=2)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.923244Z","iopub.execute_input":"2022-07-12T12:22:16.923643Z","iopub.status.idle":"2022-07-12T12:22:16.929734Z","shell.execute_reply.started":"2022-07-12T12:22:16.923602Z","shell.execute_reply":"2022-07-12T12:22:16.928353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.probability=True\nclassifier.fit(X_train,y_train)\ny_svm = classifier.predict_proba(np.array(testdf))[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:16.931566Z","iopub.execute_input":"2022-07-12T12:22:16.932543Z","iopub.status.idle":"2022-07-12T12:22:26.284805Z","shell.execute_reply.started":"2022-07-12T12:22:16.932498Z","shell.execute_reply":"2022-07-12T12:22:26.283173Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Training Accuracy :\", classifier.score(X_train, y_train))\nprint(\"Testing Accuracy :\", classifier.score(X_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:26.287079Z","iopub.execute_input":"2022-07-12T12:22:26.287450Z","iopub.status.idle":"2022-07-12T12:22:28.059367Z","shell.execute_reply.started":"2022-07-12T12:22:26.287418Z","shell.execute_reply":"2022-07-12T12:22:28.057594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# SUB","metadata":{}},{"cell_type":"code","source":"test_df['Transported'] = y_svm\ntest_df.index.name = 'PassengerId'\nsub_svm = test_df[['Transported']].reset_index()\nsub_svm.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.061091Z","iopub.execute_input":"2022-07-12T12:22:28.061661Z","iopub.status.idle":"2022-07-12T12:22:28.096004Z","shell.execute_reply.started":"2022-07-12T12:22:28.061611Z","shell.execute_reply":"2022-07-12T12:22:28.094707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Transported'] = y_predtest\ntest_df.index.name = 'PassengerId'\nsub_gradient = test_df[['Transported']].reset_index()\nsub_gradient.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.098622Z","iopub.execute_input":"2022-07-12T12:22:28.099115Z","iopub.status.idle":"2022-07-12T12:22:28.138466Z","shell.execute_reply.started":"2022-07-12T12:22:28.099068Z","shell.execute_reply":"2022-07-12T12:22:28.136866Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Transported'] = y_lgbmtest\ntest_df.index.name = 'PassengerId'\nsub_lgbm = test_df[['Transported']].reset_index()\nsub_lgbm.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.154595Z","iopub.execute_input":"2022-07-12T12:22:28.156175Z","iopub.status.idle":"2022-07-12T12:22:28.192668Z","shell.execute_reply.started":"2022-07-12T12:22:28.156105Z","shell.execute_reply":"2022-07-12T12:22:28.190894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Transported'] = y_pred_test\ntest_df.index.name = 'PassengerId'\nsub_logreg = test_df[['Transported']].reset_index()\nsub_logreg.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.195227Z","iopub.execute_input":"2022-07-12T12:22:28.195623Z","iopub.status.idle":"2022-07-12T12:22:28.229444Z","shell.execute_reply.started":"2022-07-12T12:22:28.195593Z","shell.execute_reply":"2022-07-12T12:22:28.228230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Transported'] = y_xgbtest\ntest_df.index.name = 'PassengerId'\nsub_xgb = test_df[['Transported']].reset_index()\nsub_xgb.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.231323Z","iopub.execute_input":"2022-07-12T12:22:28.232315Z","iopub.status.idle":"2022-07-12T12:22:28.271006Z","shell.execute_reply.started":"2022-07-12T12:22:28.232267Z","shell.execute_reply":"2022-07-12T12:22:28.269853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Transported'] = y_predrf \ntest_df.index.name = 'PassengerId'\nsub_rf = test_df[['Transported']].reset_index()\nsub_rf.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.272678Z","iopub.execute_input":"2022-07-12T12:22:28.273679Z","iopub.status.idle":"2022-07-12T12:22:28.303230Z","shell.execute_reply.started":"2022-07-12T12:22:28.273629Z","shell.execute_reply":"2022-07-12T12:22:28.301868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Transported'] = y_predcat\ntest_df.index.name = 'PassengerId'\nsub_cat = test_df[['Transported']].reset_index()\nsub_cat.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.305054Z","iopub.execute_input":"2022-07-12T12:22:28.305446Z","iopub.status.idle":"2022-07-12T12:22:28.336894Z","shell.execute_reply.started":"2022-07-12T12:22:28.305412Z","shell.execute_reply":"2022-07-12T12:22:28.334989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_xgb","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.339091Z","iopub.execute_input":"2022-07-12T12:22:28.340752Z","iopub.status.idle":"2022-07-12T12:22:28.360335Z","shell.execute_reply.started":"2022-07-12T12:22:28.340697Z","shell.execute_reply":"2022-07-12T12:22:28.359215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_xgb.set_index('PassengerId' , inplace = True)\nsub_gradient.set_index('PassengerId' , inplace = True)\nsub_lgbm.set_index('PassengerId' , inplace = True)\nsub_rf.set_index('PassengerId' , inplace = True)\nsub_logreg.set_index('PassengerId' , inplace = True)\nsub_cat.set_index('PassengerId' , inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.364278Z","iopub.execute_input":"2022-07-12T12:22:28.366178Z","iopub.status.idle":"2022-07-12T12:22:28.378289Z","shell.execute_reply.started":"2022-07-12T12:22:28.366081Z","shell.execute_reply":"2022-07-12T12:22:28.377254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_svm.set_index('PassengerId' , inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.379988Z","iopub.execute_input":"2022-07-12T12:22:28.380695Z","iopub.status.idle":"2022-07-12T12:22:28.393966Z","shell.execute_reply.started":"2022-07-12T12:22:28.380638Z","shell.execute_reply":"2022-07-12T12:22:28.392147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_svm","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.395989Z","iopub.execute_input":"2022-07-12T12:22:28.397340Z","iopub.status.idle":"2022-07-12T12:22:28.421047Z","shell.execute_reply.started":"2022-07-12T12:22:28.397288Z","shell.execute_reply":"2022-07-12T12:22:28.419878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = (0.06*sub_gradient + 0.06*sub_logreg + 0.5*sub_xgb + 0.2*sub_lgbm + 0.06*sub_rf + 0.06*sub_cat + 0.06*sub_svm)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:35:44.596420Z","iopub.execute_input":"2022-07-12T12:35:44.596853Z","iopub.status.idle":"2022-07-12T12:35:44.612277Z","shell.execute_reply.started":"2022-07-12T12:35:44.596822Z","shell.execute_reply":"2022-07-12T12:35:44.610835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = sub>0.5","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:35:45.581344Z","iopub.execute_input":"2022-07-12T12:35:45.582517Z","iopub.status.idle":"2022-07-12T12:35:45.588111Z","shell.execute_reply.started":"2022-07-12T12:35:45.582455Z","shell.execute_reply":"2022-07-12T12:35:45.587012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.reset_index(inplace = True)\nsub.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:35:46.986280Z","iopub.execute_input":"2022-07-12T12:35:46.986931Z","iopub.status.idle":"2022-07-12T12:35:47.001977Z","shell.execute_reply.started":"2022-07-12T12:35:46.986893Z","shell.execute_reply":"2022-07-12T12:35:47.000582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub","metadata":{"execution":{"iopub.status.busy":"2022-07-12T12:22:28.488575Z","iopub.execute_input":"2022-07-12T12:22:28.489280Z","iopub.status.idle":"2022-07-12T12:22:28.508357Z","shell.execute_reply.started":"2022-07-12T12:22:28.489243Z","shell.execute_reply":"2022-07-12T12:22:28.506714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}