{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# **Import Libs**","metadata":{"id":"ZbkBWi-E_B2m"}},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.model_selection import StratifiedKFold, train_test_split\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.svm import SVC\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.neighbors import KNeighborsClassifier\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.tree import DecisionTreeClassifier\nimport seaborn as sns\nimport warnings\nimport plotly.express as px\nfrom matplotlib import rcParams\nwarnings.filterwarnings(\"ignore\")","metadata":{"id":"EXw_aeeVciUK","execution":{"iopub.status.busy":"2022-07-19T08:03:42.659823Z","iopub.execute_input":"2022-07-19T08:03:42.660215Z","iopub.status.idle":"2022-07-19T08:03:44.080110Z","shell.execute_reply.started":"2022-07-19T08:03:42.660134Z","shell.execute_reply":"2022-07-19T08:03:44.078505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **import Data**","metadata":{"id":"S6I0lj9EazTQ"}},{"cell_type":"code","source":"test=pd.read_csv('../input/spaceship-titanic/test.csv')\ntrain=pd.read_csv('../input/spaceship-titanic/train.csv')","metadata":{"id":"FbDwbL6Dc-Vk","execution":{"iopub.status.busy":"2022-07-19T08:03:44.082215Z","iopub.execute_input":"2022-07-19T08:03:44.083026Z","iopub.status.idle":"2022-07-19T08:03:44.140293Z","shell.execute_reply.started":"2022-07-19T08:03:44.082975Z","shell.execute_reply":"2022-07-19T08:03:44.139091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Data Preprocessing**","metadata":{"id":"8mNdwUREa7Ws"}},{"cell_type":"code","source":"for col in train.columns:\n    if train[col].dtypes == object:\n      print(col)\n      print(train[col].unique())","metadata":{"id":"sDtKncYUdK4L","outputId":"562d0fb3-a506-41a6-92d1-65d90b417b84","execution":{"iopub.status.busy":"2022-07-19T08:03:44.141940Z","iopub.execute_input":"2022-07-19T08:03:44.142635Z","iopub.status.idle":"2022-07-19T08:03:44.160030Z","shell.execute_reply.started":"2022-07-19T08:03:44.142586Z","shell.execute_reply":"2022-07-19T08:03:44.158983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"id":"L22OpSHCdW9W","outputId":"5012b268-9634-4593-a356-b50fdef37817","execution":{"iopub.status.busy":"2022-07-19T08:03:44.162936Z","iopub.execute_input":"2022-07-19T08:03:44.163254Z","iopub.status.idle":"2022-07-19T08:03:44.189084Z","shell.execute_reply.started":"2022-07-19T08:03:44.163226Z","shell.execute_reply":"2022-07-19T08:03:44.188183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rcParams['figure.figsize'] = 11.7,8.27\nsns.distplot( x=train[\"Age\"], hist=True, kde=False, rug=False ,color=\"blue\")\nsns.set(font_scale = 2)\nplt.title('Distribution Of Age',fontsize = 30)\nplt.xlabel('Age')\nplt.ylabel('Number Of People',fontsize = 30)\nplt.show()","metadata":{"id":"UvMPD8YNbiAp","outputId":"00fc37b0-e611-41e3-8ce7-42aaaaf9d340","execution":{"iopub.status.busy":"2022-07-19T08:03:44.190717Z","iopub.execute_input":"2022-07-19T08:03:44.191437Z","iopub.status.idle":"2022-07-19T08:03:44.496216Z","shell.execute_reply.started":"2022-07-19T08:03:44.191392Z","shell.execute_reply":"2022-07-19T08:03:44.495069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape,test.shape","metadata":{"id":"-ddgIdj-d7EG","outputId":"e9159f22-66d9-4f0f-9692-48b1379b0cb6","execution":{"iopub.status.busy":"2022-07-19T08:03:44.497603Z","iopub.execute_input":"2022-07-19T08:03:44.497968Z","iopub.status.idle":"2022-07-19T08:03:44.505191Z","shell.execute_reply.started":"2022-07-19T08:03:44.497937Z","shell.execute_reply":"2022-07-19T08:03:44.504049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.isna().sum())\nprint('')\nprint(test.isna().sum())","metadata":{"id":"WMxLP2HPdaDd","outputId":"fa6b1fcc-625d-4907-931d-febb27b65379","execution":{"iopub.status.busy":"2022-07-19T08:03:44.506717Z","iopub.execute_input":"2022-07-19T08:03:44.507760Z","iopub.status.idle":"2022-07-19T08:03:44.532827Z","shell.execute_reply.started":"2022-07-19T08:03:44.507716Z","shell.execute_reply":"2022-07-19T08:03:44.531418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"There are many columns which contains null values","metadata":{}},{"cell_type":"code","source":"for col in train.columns:\n    if train[col].isnull().mean()*100>40:\n        train.drop(col,axis=1,inplace=True)\n    \n\n\nfor col in test.columns:\n    if test[col].isnull().mean()*100>40:\n        test.drop(col,axis=1,inplace=True)","metadata":{"id":"OX7dQfrLhY-4","execution":{"iopub.status.busy":"2022-07-19T08:03:44.534625Z","iopub.execute_input":"2022-07-19T08:03:44.535322Z","iopub.status.idle":"2022-07-19T08:03:44.562304Z","shell.execute_reply.started":"2022-07-19T08:03:44.535274Z","shell.execute_reply":"2022-07-19T08:03:44.561193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.dtypes)\nprint('')\nprint(test.dtypes)","metadata":{"id":"dDybODqhha0E","outputId":"59aff5c4-8ad4-4a27-e149-c25d1a2ad86d","execution":{"iopub.status.busy":"2022-07-19T08:03:44.563833Z","iopub.execute_input":"2022-07-19T08:03:44.564696Z","iopub.status.idle":"2022-07-19T08:03:44.572579Z","shell.execute_reply.started":"2022-07-19T08:03:44.564654Z","shell.execute_reply":"2022-07-19T08:03:44.571234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Remove the column Name,PassengerId,and Cabin as they don't affect the performance of Data","metadata":{}},{"cell_type":"code","source":"train = train.drop(['Cabin','Name', 'PassengerId'], axis=1)\ntest_id=test['PassengerId']\ntest = test.drop(['Cabin','Name', 'PassengerId'], axis=1)","metadata":{"id":"DxmW-N_Piepf","execution":{"iopub.status.busy":"2022-07-19T08:03:44.574107Z","iopub.execute_input":"2022-07-19T08:03:44.575276Z","iopub.status.idle":"2022-07-19T08:03:44.588100Z","shell.execute_reply.started":"2022-07-19T08:03:44.575231Z","shell.execute_reply":"2022-07-19T08:03:44.586724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"id":"PjcnS4c8jH-l","outputId":"c929e784-fe20-439a-b774-f753123e97ec","execution":{"iopub.status.busy":"2022-07-19T08:03:44.589387Z","iopub.execute_input":"2022-07-19T08:03:44.589932Z","iopub.status.idle":"2022-07-19T08:03:44.612734Z","shell.execute_reply.started":"2022-07-19T08:03:44.589900Z","shell.execute_reply":"2022-07-19T08:03:44.611617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe().T.style.background_gradient(cmap='Blues')","metadata":{"id":"6f4_-vHZjX1b","outputId":"d348a550-137c-4f85-c4a6-12607ab6858a","execution":{"iopub.status.busy":"2022-07-19T08:03:44.614211Z","iopub.execute_input":"2022-07-19T08:03:44.614568Z","iopub.status.idle":"2022-07-19T08:03:44.712904Z","shell.execute_reply.started":"2022-07-19T08:03:44.614538Z","shell.execute_reply":"2022-07-19T08:03:44.711711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"id":"dsTc5276jlvK","outputId":"95ed7dc6-3c6d-4139-ac69-f7066d402624","execution":{"iopub.status.busy":"2022-07-19T08:03:44.717793Z","iopub.execute_input":"2022-07-19T08:03:44.718144Z","iopub.status.idle":"2022-07-19T08:03:44.739329Z","shell.execute_reply.started":"2022-07-19T08:03:44.718114Z","shell.execute_reply":"2022-07-19T08:03:44.738012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imputer_cols = [\"Age\", \"FoodCourt\", \"ShoppingMall\", \"Spa\", \"VRDeck\" ,\"RoomService\"]\nimputer = SimpleImputer(strategy='mean' )\nimputer.fit(train[imputer_cols])\ntrain[imputer_cols] = imputer.transform(train[imputer_cols])\ntest[imputer_cols] = imputer.transform(test[imputer_cols])\ntrain[\"HomePlanet\"].fillna('Z', inplace=True)\ntest[\"HomePlanet\"].fillna('Z', inplace=True)","metadata":{"id":"xg5K1J0Ejwbf","execution":{"iopub.status.busy":"2022-07-19T08:03:44.741168Z","iopub.execute_input":"2022-07-19T08:03:44.741740Z","iopub.status.idle":"2022-07-19T08:03:44.761920Z","shell.execute_reply.started":"2022-07-19T08:03:44.741689Z","shell.execute_reply":"2022-07-19T08:03:44.761028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Dealing with Null Values","metadata":{}},{"cell_type":"code","source":"cateogry_columns=train.select_dtypes(include=['object']).columns.tolist()\nfor column in train.columns:\n    if train[column].isnull().any():\n        if(column in cateogry_columns):\n            train[column]=train[column].fillna(train[column].mode()[0])\n\n\n\ncateogry_columns=test.select_dtypes(include=['object']).columns.tolist()\nfor column in test.columns:\n    if test[column].isnull().any():\n        if(column in cateogry_columns):\n            test[column]=test[column].fillna(test[column].mode()[0])","metadata":{"id":"WSTPCJg7qONq","execution":{"iopub.status.busy":"2022-07-19T08:03:44.763321Z","iopub.execute_input":"2022-07-19T08:03:44.764798Z","iopub.status.idle":"2022-07-19T08:03:44.804807Z","shell.execute_reply.started":"2022-07-19T08:03:44.764751Z","shell.execute_reply":"2022-07-19T08:03:44.803094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,8))\nrcParams['figure.figsize'] = 11.7,8.27\nsns.barplot(x='HomePlanet',y='Transported',hue='Destination',data=train)","metadata":{"id":"V9aToJVTj78S","outputId":"67ba008c-2762-4322-f608-94f4e3b57190","execution":{"iopub.status.busy":"2022-07-19T08:03:44.806431Z","iopub.execute_input":"2022-07-19T08:03:44.806849Z","iopub.status.idle":"2022-07-19T08:03:45.747977Z","shell.execute_reply.started":"2022-07-19T08:03:44.806814Z","shell.execute_reply":"2022-07-19T08:03:45.746718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.isna().sum())\nprint('')\nprint(test.isna().sum())","metadata":{"id":"phoHddSWqsJ9","outputId":"0f79d281-fec4-4f94-af7e-8afa7f476b0f","execution":{"iopub.status.busy":"2022-07-19T08:03:45.749738Z","iopub.execute_input":"2022-07-19T08:03:45.750191Z","iopub.status.idle":"2022-07-19T08:03:45.765830Z","shell.execute_reply.started":"2022-07-19T08:03:45.750146Z","shell.execute_reply":"2022-07-19T08:03:45.764598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,8))\nrcParams['figure.figsize'] = 11.7,8.27\nsns.barplot(x='CryoSleep',y='Transported',hue='HomePlanet',data=train)","metadata":{"id":"_BIhnu9BsJxG","outputId":"57aa3bc8-c4d6-47b7-be3e-1caf04058e0f","execution":{"iopub.status.busy":"2022-07-19T08:03:45.767376Z","iopub.execute_input":"2022-07-19T08:03:45.768244Z","iopub.status.idle":"2022-07-19T08:03:46.406932Z","shell.execute_reply.started":"2022-07-19T08:03:45.768208Z","shell.execute_reply":"2022-07-19T08:03:46.405710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le=LabelEncoder()\nfor col in train.columns:\n    if train[col].dtypes == object or train[col].dtypes == bool:\n        train[col]= le.fit_transform(train[col])\n\n\n\nfor col in test.columns:\n    if test[col].dtypes == object or test[col].dtypes == bool:\n        test[col]= le.fit_transform(test[col])","metadata":{"id":"kkC1w6TDsJda","execution":{"iopub.status.busy":"2022-07-19T08:03:46.408765Z","iopub.execute_input":"2022-07-19T08:03:46.409510Z","iopub.status.idle":"2022-07-19T08:03:46.430398Z","shell.execute_reply.started":"2022-07-19T08:03:46.409462Z","shell.execute_reply":"2022-07-19T08:03:46.429435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rcParams['figure.figsize'] = 11.7,8.27\nTransported = 'Transported'\nnot_Transported = 'Not Transported'\nfig, axes = plt.subplots(nrows=1, ncols=2,figsize=(16, 8))\nVIP_Y = train[train['VIP']==1]\nVIP_N = train[train['VIP']==0]\nax = sns.distplot(VIP_Y[VIP_Y['Transported']==1].Age.dropna(), bins=18, label = Transported, ax = axes[0], kde =False, color=\"green\")\nax = sns.distplot(VIP_Y[VIP_Y['Transported']==0].Age.dropna(), bins=40, label = not_Transported, ax = axes[0], kde =False, color=\"red\")\nax.legend()\nax.set_title('Survival Rate for VIP_Y')\nax = sns.distplot(VIP_N[VIP_N['Transported']==1].Age.dropna(), bins=18, label = Transported, ax = axes[1], kde = False, color=\"green\")\nax = sns.distplot(VIP_N[VIP_N['Transported']==0].Age.dropna(), bins=40, label = not_Transported, ax = axes[1], kde = False, color=\"red\")\nax.legend()\n_ = ax.set_title('Transported Rate for VIP_N');","metadata":{"id":"P9P1PzYTh_lz","outputId":"55b0b45b-b9ad-4c18-e404-4736d203fb52","execution":{"iopub.status.busy":"2022-07-19T08:03:46.432121Z","iopub.execute_input":"2022-07-19T08:03:46.432912Z","iopub.status.idle":"2022-07-19T08:03:47.161554Z","shell.execute_reply.started":"2022-07-19T08:03:46.432866Z","shell.execute_reply":"2022-07-19T08:03:47.160129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.dtypes)\nprint('')\nprint(test.dtypes)","metadata":{"id":"-z_S-dgXrJ6S","outputId":"57a26ca2-b666-4d2c-e3fd-6aab3db5ea7b","execution":{"iopub.status.busy":"2022-07-19T08:03:47.163075Z","iopub.execute_input":"2022-07-19T08:03:47.163428Z","iopub.status.idle":"2022-07-19T08:03:47.171888Z","shell.execute_reply.started":"2022-07-19T08:03:47.163397Z","shell.execute_reply":"2022-07-19T08:03:47.170936Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rcParams['figure.figsize'] = 11.7,8.27\nCorr = train.select_dtypes(exclude=[\"object\"]).corr()\nabs_corr_on_saleprice = abs(Corr[['Transported']].copy())\nabs_corr_on_saleprice.drop('Transported', axis=0, inplace=True)\n\nabs_corr_on_saleprice.sort_values(by='Transported', ascending=False).plot(kind='bar', figsize=(12,8))\nplt.xticks(rotation=70)\nplt.show()","metadata":{"id":"eRoNTWY0ja0s","outputId":"6dcf92a4-d137-4fa7-ad25-cede767be4d3","execution":{"iopub.status.busy":"2022-07-19T08:03:47.173087Z","iopub.execute_input":"2022-07-19T08:03:47.173983Z","iopub.status.idle":"2022-07-19T08:03:47.480949Z","shell.execute_reply.started":"2022-07-19T08:03:47.173945Z","shell.execute_reply":"2022-07-19T08:03:47.479926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"id":"R6EZlTEOs7kv","outputId":"a3ff8422-2f9b-45b8-c425-d4dc574e2348","execution":{"iopub.status.busy":"2022-07-19T08:03:47.482264Z","iopub.execute_input":"2022-07-19T08:03:47.483297Z","iopub.status.idle":"2022-07-19T08:03:47.504535Z","shell.execute_reply.started":"2022-07-19T08:03:47.483262Z","shell.execute_reply":"2022-07-19T08:03:47.503484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"id":"nShD1VMPtJVZ","outputId":"ddcb832f-53b7-4f65-f1aa-0807c4aa434c","execution":{"iopub.status.busy":"2022-07-19T08:03:47.506035Z","iopub.execute_input":"2022-07-19T08:03:47.506832Z","iopub.status.idle":"2022-07-19T08:03:47.523512Z","shell.execute_reply.started":"2022-07-19T08:03:47.506798Z","shell.execute_reply":"2022-07-19T08:03:47.522491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=train.iloc[:,:-1].values\nY=train.iloc[:,-1].values\n# test=test.values","metadata":{"id":"8llvF5F_tOnd","execution":{"iopub.status.busy":"2022-07-19T08:03:47.524823Z","iopub.execute_input":"2022-07-19T08:03:47.525595Z","iopub.status.idle":"2022-07-19T08:03:47.536519Z","shell.execute_reply.started":"2022-07-19T08:03:47.525560Z","shell.execute_reply":"2022-07-19T08:03:47.535350Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X","metadata":{"id":"r3uOfuzguaWF","outputId":"b48ec932-0ec4-43b9-868e-79bd548a66af","execution":{"iopub.status.busy":"2022-07-19T08:03:47.538101Z","iopub.execute_input":"2022-07-19T08:03:47.538700Z","iopub.status.idle":"2022-07-19T08:03:47.550187Z","shell.execute_reply.started":"2022-07-19T08:03:47.538666Z","shell.execute_reply":"2022-07-19T08:03:47.549188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nX_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.1, random_state = 0)","metadata":{"id":"hf_EbXG2v5ke","execution":{"iopub.status.busy":"2022-07-19T08:03:47.551622Z","iopub.execute_input":"2022-07-19T08:03:47.551980Z","iopub.status.idle":"2022-07-19T08:03:47.560734Z","shell.execute_reply.started":"2022-07-19T08:03:47.551948Z","shell.execute_reply":"2022-07-19T08:03:47.559524Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Feature Scaling**","metadata":{"id":"orDp2kb7syAs"}},{"cell_type":"code","source":"\nsc = StandardScaler()\nX_train = sc.fit_transform(X_train)\nX_test = sc.transform(X_test)\ntest=sc.transform(test.values)","metadata":{"id":"omQvGr2f0ux9","execution":{"iopub.status.busy":"2022-07-19T08:03:47.562307Z","iopub.execute_input":"2022-07-19T08:03:47.562619Z","iopub.status.idle":"2022-07-19T08:03:47.574541Z","shell.execute_reply.started":"2022-07-19T08:03:47.562591Z","shell.execute_reply":"2022-07-19T08:03:47.573587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Modeling**","metadata":{"id":"YA181r8Cs208"}},{"cell_type":"markdown","source":"## Predictor ","metadata":{"id":"LbLXMSZRs9AV"}},{"cell_type":"code","source":"def acc(classifier,X_test):\n\n    y_pred = classifier.predict(X_test)\n    from sklearn.metrics import confusion_matrix, accuracy_score\n    cm = confusion_matrix(y_test, y_pred)\n    print(cm)\n    print(accuracy_score(y_test, y_pred))\n\n","metadata":{"id":"3tn3KS7nwZR6","execution":{"iopub.status.busy":"2022-07-19T08:03:47.575757Z","iopub.execute_input":"2022-07-19T08:03:47.576358Z","iopub.status.idle":"2022-07-19T08:03:47.581388Z","shell.execute_reply.started":"2022-07-19T08:03:47.576329Z","shell.execute_reply":"2022-07-19T08:03:47.580692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## RandomForestClassifier","metadata":{"id":"i9hvOUMbtBh6"}},{"cell_type":"code","source":"\nclassifier = RandomForestClassifier(n_estimators = 100, criterion = 'entropy', random_state = 42)\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"lJBK_jfUwSQk","outputId":"ef7f6c0b-a811-4c06-c791-b78037720803","execution":{"iopub.status.busy":"2022-07-19T08:03:47.582471Z","iopub.execute_input":"2022-07-19T08:03:47.582938Z","iopub.status.idle":"2022-07-19T08:03:48.710557Z","shell.execute_reply.started":"2022-07-19T08:03:47.582909Z","shell.execute_reply":"2022-07-19T08:03:48.709410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## SVC","metadata":{"id":"L71infiGtH9S"}},{"cell_type":"code","source":"\nclassifier = SVC(kernel = 'linear', random_state = 42)\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"NX9CKIx81CUQ","outputId":"5ed9b6a5-69c3-480e-f5b4-8a46251b0cf4","execution":{"iopub.status.busy":"2022-07-19T08:03:48.712298Z","iopub.execute_input":"2022-07-19T08:03:48.713335Z","iopub.status.idle":"2022-07-19T08:03:51.917189Z","shell.execute_reply.started":"2022-07-19T08:03:48.713295Z","shell.execute_reply":"2022-07-19T08:03:51.915774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Kernel SVC","metadata":{"id":"1uG9AhL5tMCI"}},{"cell_type":"code","source":"\nclassifier = SVC(kernel = 'rbf', random_state = 42)\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"TtWX732W1cDt","outputId":"f57c66ca-97c4-498b-de75-5673bd026db1","execution":{"iopub.status.busy":"2022-07-19T08:03:51.918728Z","iopub.execute_input":"2022-07-19T08:03:51.919487Z","iopub.status.idle":"2022-07-19T08:03:54.707369Z","shell.execute_reply.started":"2022-07-19T08:03:51.919447Z","shell.execute_reply":"2022-07-19T08:03:54.705923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Logistic Regression","metadata":{"id":"l11O6dXDtPNQ"}},{"cell_type":"code","source":"\nclassifier = LogisticRegression(random_state = 42)\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"d1oCvuZh1_xZ","outputId":"d39d67ef-1be0-432e-c51b-3fe3f275d1bb","execution":{"iopub.status.busy":"2022-07-19T08:03:54.709609Z","iopub.execute_input":"2022-07-19T08:03:54.710504Z","iopub.status.idle":"2022-07-19T08:03:54.752168Z","shell.execute_reply.started":"2022-07-19T08:03:54.710453Z","shell.execute_reply":"2022-07-19T08:03:54.750897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## KNeighborsClassifier","metadata":{"id":"3Wg44e2DtXM0"}},{"cell_type":"code","source":"\nclassifier = KNeighborsClassifier(n_neighbors = 5, metric = 'minkowski', p = 2)\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"6MePkKWl2TR1","outputId":"0f9b48e1-79e2-4aa5-f05e-cf79b6fc9d20","execution":{"iopub.status.busy":"2022-07-19T08:03:54.754535Z","iopub.execute_input":"2022-07-19T08:03:54.755484Z","iopub.status.idle":"2022-07-19T08:03:54.904347Z","shell.execute_reply.started":"2022-07-19T08:03:54.755436Z","shell.execute_reply":"2022-07-19T08:03:54.902983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## GaussianNB","metadata":{"id":"V9QBiML5tefc"}},{"cell_type":"code","source":"\nclassifier = GaussianNB()\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"n7iifj2T2hDb","outputId":"f747060c-7ac9-43f5-d779-a7be5ab4f978","execution":{"iopub.status.busy":"2022-07-19T08:03:54.906489Z","iopub.execute_input":"2022-07-19T08:03:54.906984Z","iopub.status.idle":"2022-07-19T08:03:54.919578Z","shell.execute_reply.started":"2022-07-19T08:03:54.906944Z","shell.execute_reply":"2022-07-19T08:03:54.918193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## DecisionTreeClassifier","metadata":{"id":"NdnMR9ITtjfl"}},{"cell_type":"code","source":"\nclassifier = DecisionTreeClassifier(criterion = 'entropy', random_state = 42)\nclassifier.fit(X_train, y_train)\nacc(classifier,X_test)","metadata":{"id":"5LNIUBI_4FQR","outputId":"2e33b0a5-a254-44df-e71e-18eb9191b3ac","execution":{"iopub.status.busy":"2022-07-19T08:03:54.921022Z","iopub.execute_input":"2022-07-19T08:03:54.921884Z","iopub.status.idle":"2022-07-19T08:03:54.968090Z","shell.execute_reply.started":"2022-07-19T08:03:54.921851Z","shell.execute_reply":"2022-07-19T08:03:54.967210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# **Submission**","metadata":{"id":"kOUC_p75tpGd"}},{"cell_type":"code","source":"y_pred = classifier.predict(test)\nsubmission7 = pd.DataFrame({\n        \"PassengerId\": test_id,\n        \"Transported\": y_pred\n    })\n\nsubmission7[\"Transported\"] = submission7[\"Transported\"].astype(bool)\nsubmission7.Transported.replace({0:False, 1:True})\n# submission7.to_csv(\"submission7.csv\",index=False)","metadata":{"id":"9rxJtuyl5WcY","execution":{"iopub.status.busy":"2022-07-19T08:03:54.969214Z","iopub.execute_input":"2022-07-19T08:03:54.970205Z","iopub.status.idle":"2022-07-19T08:03:54.984796Z","shell.execute_reply.started":"2022-07-19T08:03:54.970149Z","shell.execute_reply":"2022-07-19T08:03:54.983610Z"},"trusted":true},"execution_count":null,"outputs":[]}]}