{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-27T16:19:34.529388Z","iopub.execute_input":"2022-07-27T16:19:34.530943Z","iopub.status.idle":"2022-07-27T16:19:34.542925Z","shell.execute_reply.started":"2022-07-27T16:19:34.530876Z","shell.execute_reply":"2022-07-27T16:19:34.541702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:34.928116Z","iopub.execute_input":"2022-07-27T16:19:34.929053Z","iopub.status.idle":"2022-07-27T16:19:34.936832Z","shell.execute_reply.started":"2022-07-27T16:19:34.929009Z","shell.execute_reply":"2022-07-27T16:19:34.935711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neighbors import KNeighborsClassifier\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.svm import SVC\nfrom sklearn.model_selection import KFold\nfrom sklearn.model_selection import cross_val_score","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.113266Z","iopub.execute_input":"2022-07-27T16:19:35.114662Z","iopub.status.idle":"2022-07-27T16:19:35.122108Z","shell.execute_reply.started":"2022-07-27T16:19:35.114574Z","shell.execute_reply":"2022-07-27T16:19:35.120898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv('../input/aviakompaniya/train_dataset.csv')\ndf_test = pd.read_csv('../input/aviakompaniya/test_dataset.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.214063Z","iopub.execute_input":"2022-07-27T16:19:35.215014Z","iopub.status.idle":"2022-07-27T16:19:35.263361Z","shell.execute_reply.started":"2022-07-27T16:19:35.214976Z","shell.execute_reply":"2022-07-27T16:19:35.261972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.310614Z","iopub.execute_input":"2022-07-27T16:19:35.311839Z","iopub.status.idle":"2022-07-27T16:19:35.318636Z","shell.execute_reply.started":"2022-07-27T16:19:35.311794Z","shell.execute_reply":"2022-07-27T16:19:35.317695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.402811Z","iopub.execute_input":"2022-07-27T16:19:35.403754Z","iopub.status.idle":"2022-07-27T16:19:35.409707Z","shell.execute_reply.started":"2022-07-27T16:19:35.403716Z","shell.execute_reply":"2022-07-27T16:19:35.408553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.521184Z","iopub.execute_input":"2022-07-27T16:19:35.521807Z","iopub.status.idle":"2022-07-27T16:19:35.543082Z","shell.execute_reply.started":"2022-07-27T16:19:35.521774Z","shell.execute_reply":"2022-07-27T16:19:35.541909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.683744Z","iopub.execute_input":"2022-07-27T16:19:35.684163Z","iopub.status.idle":"2022-07-27T16:19:35.701514Z","shell.execute_reply.started":"2022-07-27T16:19:35.684132Z","shell.execute_reply":"2022-07-27T16:19:35.699928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[df_train['Arrival Delay in Minutes'].isna()]","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.850449Z","iopub.execute_input":"2022-07-27T16:19:35.850840Z","iopub.status.idle":"2022-07-27T16:19:35.885668Z","shell.execute_reply.started":"2022-07-27T16:19:35.850812Z","shell.execute_reply":"2022-07-27T16:19:35.884610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train['Arrival Delay in Minutes'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:35.949490Z","iopub.execute_input":"2022-07-27T16:19:35.950192Z","iopub.status.idle":"2022-07-27T16:19:35.960962Z","shell.execute_reply.started":"2022-07-27T16:19:35.950144Z","shell.execute_reply":"2022-07-27T16:19:35.959567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.sample(10)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:36.051545Z","iopub.execute_input":"2022-07-27T16:19:36.052225Z","iopub.status.idle":"2022-07-27T16:19:36.079718Z","shell.execute_reply.started":"2022-07-27T16:19:36.052182Z","shell.execute_reply":"2022-07-27T16:19:36.078555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train['Arrival Delay in Minutes'].fillna(df_train['Departure Delay in Minutes'],inplace=True)\ndf_test['Arrival Delay in Minutes'].fillna(df_test['Departure Delay in Minutes'],inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:36.150999Z","iopub.execute_input":"2022-07-27T16:19:36.151714Z","iopub.status.idle":"2022-07-27T16:19:36.159263Z","shell.execute_reply.started":"2022-07-27T16:19:36.151676Z","shell.execute_reply":"2022-07-27T16:19:36.157920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[['Gender','Customer Type','Type of Travel','Class']].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:36.268370Z","iopub.execute_input":"2022-07-27T16:19:36.268771Z","iopub.status.idle":"2022-07-27T16:19:36.283973Z","shell.execute_reply.started":"2022-07-27T16:19:36.268741Z","shell.execute_reply":"2022-07-27T16:19:36.282686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def str_int(df):\n    gender_mapping = {\n           'Male': 1,\n           'Female':0}\n    df['Gender'] = df['Gender'].map(gender_mapping)\n    customer_mapping = {\n           'Loyal Customer': 1,\n           'disloyal Customer':0}\n    df['Customer Type'] = df['Customer Type'].map(customer_mapping)\n    class_mapping = {\n           'Eco Plus': 1,\n           'Eco':0,\n           'Business':2}\n    df['Class'] = df['Class'].map(class_mapping)\n    travel_mapping = {\n           'Personal Travel': 0,\n           'Business travel':1}\n    df['Type of Travel'] = df['Type of Travel'].map(travel_mapping)\n    return df","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:36.377571Z","iopub.execute_input":"2022-07-27T16:19:36.378737Z","iopub.status.idle":"2022-07-27T16:19:36.386778Z","shell.execute_reply.started":"2022-07-27T16:19:36.378698Z","shell.execute_reply":"2022-07-27T16:19:36.385551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = str_int(df_train)\ndf_test = str_int(df_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:36.497388Z","iopub.execute_input":"2022-07-27T16:19:36.497814Z","iopub.status.idle":"2022-07-27T16:19:36.521439Z","shell.execute_reply.started":"2022-07-27T16:19:36.497776Z","shell.execute_reply":"2022-07-27T16:19:36.520401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfacet = sns.FacetGrid(data=df_train, hue=\"satisfaction\",aspect=4)\nfacet.map(sns.kdeplot,'Age',shade= True)\nfacet.set(xlim=(0, df_train['Age'].max()))\nfacet.add_legend()\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:36.617982Z","iopub.execute_input":"2022-07-27T16:19:36.618366Z","iopub.status.idle":"2022-07-27T16:19:37.041061Z","shell.execute_reply.started":"2022-07-27T16:19:36.618337Z","shell.execute_reply":"2022-07-27T16:19:37.039958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"facet = sns.FacetGrid(data=df_train, hue=\"satisfaction\",aspect=4)\nfacet.map(sns.kdeplot,'Flight Distance',shade= True)\nfacet.set(xlim=(0, df_train['Flight Distance'].max()))\nfacet.add_legend()\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:37.043150Z","iopub.execute_input":"2022-07-27T16:19:37.044049Z","iopub.status.idle":"2022-07-27T16:19:37.429462Z","shell.execute_reply.started":"2022-07-27T16:19:37.044001Z","shell.execute_reply":"2022-07-27T16:19:37.428218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"facet = sns.FacetGrid(data=df_train, hue=\"satisfaction\",aspect=4)\nfacet.map(sns.kdeplot,'Arrival Delay in Minutes',shade= True)\nfacet.set(xlim=(0, df_train['Arrival Delay in Minutes'].max()))\nfacet.add_legend()\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:37.431097Z","iopub.execute_input":"2022-07-27T16:19:37.431560Z","iopub.status.idle":"2022-07-27T16:19:37.825984Z","shell.execute_reply.started":"2022-07-27T16:19:37.431516Z","shell.execute_reply":"2022-07-27T16:19:37.824929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"facet = sns.FacetGrid(data=df_train, hue=\"satisfaction\",aspect=4)\nfacet.map(sns.kdeplot,'Arrival Delay in Minutes',shade= True)\nfacet.set(xlim=(0, df_train['Arrival Delay in Minutes'].max()))\nfacet.add_legend()\nplt.xlim(0, 100)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:37.828326Z","iopub.execute_input":"2022-07-27T16:19:37.828670Z","iopub.status.idle":"2022-07-27T16:19:38.227001Z","shell.execute_reply.started":"2022-07-27T16:19:37.828640Z","shell.execute_reply":"2022-07-27T16:19:38.225870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"facet = sns.FacetGrid(data=df_train, hue=\"satisfaction\",aspect=4)\nfacet.map(sns.kdeplot,'Departure Delay in Minutes',shade= True)\nfacet.set(xlim=(0, df_train['Departure Delay in Minutes'].max()))\nfacet.add_legend()\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:38.228705Z","iopub.execute_input":"2022-07-27T16:19:38.229080Z","iopub.status.idle":"2022-07-27T16:19:38.620114Z","shell.execute_reply.started":"2022-07-27T16:19:38.229051Z","shell.execute_reply":"2022-07-27T16:19:38.619045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"facet = sns.FacetGrid(data=df_train, hue=\"satisfaction\",aspect=4)\nfacet.map(sns.kdeplot,'Departure Delay in Minutes',shade= True)\nfacet.set(xlim=(0, df_train['Departure Delay in Minutes'].max()))\nfacet.add_legend()\nplt.xlim(0,100)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:38.621639Z","iopub.execute_input":"2022-07-27T16:19:38.621953Z","iopub.status.idle":"2022-07-27T16:19:39.018341Z","shell.execute_reply.started":"2022-07-27T16:19:38.621925Z","shell.execute_reply":"2022-07-27T16:19:39.017177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def group_v(df):\n    df.loc[ df['Age'] <= 18, 'Age'] = 0\n    df.loc[(df['Age'] > 18) & (df['Age'] <= 36), 'Age'] = 1\n    df.loc[(df['Age'] > 36) & (df['Age'] <= 62), 'Age'] = 2\n#     df.loc[(df['Age'] > ) & (df['Age'] <= 50), 'Age'] = 3\n#     df.loc[(df['Age'] > 50) & (df['Age'] <= 65), 'Age'] = 2\n    df.loc[ df['Age'] > 62, 'Age'] = 0\n    df.loc[ df['Flight Distance'] <= 1400, 'Flight Distance'] = 0\n    df.loc[(df['Flight Distance'] > 1400) & (df['Flight Distance'] <= 2000), 'Flight Distance'] = 2\n    df.loc[(df['Flight Distance'] > 2000) & (df['Flight Distance'] <= 4000), 'Flight Distance'] = 2\n    df.loc[ df['Flight Distance'] > 4000, 'Flight Distance'] = 1\n#     df.loc[ df['Flight Distance'] <= 300, 'Flight Distance'] = 0\n#     df.loc[(df['Flight Distance'] > 300) & (df['Flight Distance'] <= 700), 'Flight Distance'] = 1\n#     df.loc[(df['Flight Distance'] > 700) & (df['Flight Distance'] <= 1250), 'Flight Distance'] = 0\n#     df.loc[(df['Flight Distance'] > 1250) & (df['Flight Distance'] <= 1550), 'Flight Distance'] = 1\n#     df.loc[(df['Flight Distance'] > 1550) & (df['Flight Distance'] <= 2500), 'Flight Distance'] = 2\n#     df.loc[ df['Flight Distance'] > 2500, 'Flight Distance'] = 1\n    df.loc[ df['Arrival Delay in Minutes'] <= 5, 'Arrival Delay in Minutes'] = 0\n    df.loc[(df['Arrival Delay in Minutes'] > 5) & (df['Arrival Delay in Minutes'] <= 15), 'Arrival Delay in Minutes'] = 1\n    df.loc[(df['Arrival Delay in Minutes'] > 15) & (df['Arrival Delay in Minutes'] <= 25), 'Arrival Delay in Minutes'] = 2\n    df.loc[ df['Arrival Delay in Minutes'] > 25, 'Arrival Delay in Minutes'] = 3\n    df.loc[ df['Departure Delay in Minutes'] <= 5, 'Departure Delay in Minutes'] = 0\n    df.loc[(df['Departure Delay in Minutes'] > 5) & (df['Departure Delay in Minutes'] <= 15), 'Departure Delay in Minutes'] = 1\n    df.loc[(df['Departure Delay in Minutes'] > 15) & (df['Arrival Delay in Minutes'] <= 25), 'Departure Delay in Minutes'] = 2\n    df.loc[ df['Departure Delay in Minutes'] > 25, 'Departure Delay in Minutes'] = 3\n    return df","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.019985Z","iopub.execute_input":"2022-07-27T16:19:39.020344Z","iopub.status.idle":"2022-07-27T16:19:39.033779Z","shell.execute_reply.started":"2022-07-27T16:19:39.020312Z","shell.execute_reply":"2022-07-27T16:19:39.032670Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train1 = group_v( df_train )\ndf_test= group_v( df_test )","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.035159Z","iopub.execute_input":"2022-07-27T16:19:39.035475Z","iopub.status.idle":"2022-07-27T16:19:39.071163Z","shell.execute_reply.started":"2022-07-27T16:19:39.035446Z","shell.execute_reply":"2022-07-27T16:19:39.069964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train1.describe().T","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.072500Z","iopub.execute_input":"2022-07-27T16:19:39.072856Z","iopub.status.idle":"2022-07-27T16:19:39.160686Z","shell.execute_reply.started":"2022-07-27T16:19:39.072825Z","shell.execute_reply":"2022-07-27T16:19:39.159651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train1.corrwith(df_train1['satisfaction'])","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.164324Z","iopub.execute_input":"2022-07-27T16:19:39.164672Z","iopub.status.idle":"2022-07-27T16:19:39.185660Z","shell.execute_reply.started":"2022-07-27T16:19:39.164641Z","shell.execute_reply":"2022-07-27T16:19:39.184655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr_matrix = df_train.corr().abs()\ncorr_matrix.style.background_gradient(cmap='coolwarm')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.186906Z","iopub.execute_input":"2022-07-27T16:19:39.187213Z","iopub.status.idle":"2022-07-27T16:19:39.288573Z","shell.execute_reply.started":"2022-07-27T16:19:39.187186Z","shell.execute_reply":"2022-07-27T16:19:39.287493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = df_train.drop(['id','Gender','Gate location','Departure Delay in Minutes','Departure/Arrival time convenient'],axis=1)\ntest = df_test.drop(['id','Gender','Gate location','Departure Delay in Minutes','Departure/Arrival time convenient'],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.290020Z","iopub.execute_input":"2022-07-27T16:19:39.290435Z","iopub.status.idle":"2022-07-27T16:19:39.300141Z","shell.execute_reply.started":"2022-07-27T16:19:39.290402Z","shell.execute_reply":"2022-07-27T16:19:39.298872Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_to_model = train.drop('satisfaction', axis=1).values\nY_to_model = train['satisfaction']\nX_test = test.values","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.301894Z","iopub.execute_input":"2022-07-27T16:19:39.302700Z","iopub.status.idle":"2022-07-27T16:19:39.311353Z","shell.execute_reply.started":"2022-07-27T16:19:39.302666Z","shell.execute_reply":"2022-07-27T16:19:39.310196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"k_fold = KFold(n_splits=10, shuffle=True, random_state=0)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.328391Z","iopub.execute_input":"2022-07-27T16:19:39.329193Z","iopub.status.idle":"2022-07-27T16:19:39.336721Z","shell.execute_reply.started":"2022-07-27T16:19:39.329149Z","shell.execute_reply":"2022-07-27T16:19:39.335899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = KNeighborsClassifier()\nscoring = 'accuracy'\nscore = cross_val_score(clf, X_to_model, Y_to_model, cv=k_fold, n_jobs=1, scoring=scoring)\nprint(score)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:39.338127Z","iopub.execute_input":"2022-07-27T16:19:39.338730Z","iopub.status.idle":"2022-07-27T16:19:41.943013Z","shell.execute_reply.started":"2022-07-27T16:19:39.338698Z","shell.execute_reply":"2022-07-27T16:19:41.941963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"round(np.mean(score)*100, 2)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:41.944214Z","iopub.execute_input":"2022-07-27T16:19:41.944513Z","iopub.status.idle":"2022-07-27T16:19:41.953149Z","shell.execute_reply.started":"2022-07-27T16:19:41.944485Z","shell.execute_reply":"2022-07-27T16:19:41.951940Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = DecisionTreeClassifier()\nscoring = 'accuracy'\nscore = cross_val_score(clf, X_to_model, Y_to_model, cv=k_fold, n_jobs=1, scoring=scoring)\nprint(score)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:41.954673Z","iopub.execute_input":"2022-07-27T16:19:41.955121Z","iopub.status.idle":"2022-07-27T16:19:42.233775Z","shell.execute_reply.started":"2022-07-27T16:19:41.955081Z","shell.execute_reply":"2022-07-27T16:19:42.232804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"round(np.mean(score)*100, 2)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:42.235429Z","iopub.execute_input":"2022-07-27T16:19:42.236700Z","iopub.status.idle":"2022-07-27T16:19:42.246239Z","shell.execute_reply.started":"2022-07-27T16:19:42.236655Z","shell.execute_reply":"2022-07-27T16:19:42.244881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = RandomForestClassifier()\nscoring = 'accuracy'\nscore = cross_val_score(clf, X_to_model, Y_to_model, cv=k_fold, n_jobs=1, scoring=scoring)\nprint(score)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:42.247456Z","iopub.execute_input":"2022-07-27T16:19:42.247812Z","iopub.status.idle":"2022-07-27T16:19:49.935229Z","shell.execute_reply.started":"2022-07-27T16:19:42.247782Z","shell.execute_reply":"2022-07-27T16:19:49.934042Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"round(np.mean(score)*100, 2)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:49.936550Z","iopub.execute_input":"2022-07-27T16:19:49.936923Z","iopub.status.idle":"2022-07-27T16:19:49.944471Z","shell.execute_reply.started":"2022-07-27T16:19:49.936895Z","shell.execute_reply":"2022-07-27T16:19:49.943401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = GaussianNB()\nscoring = 'accuracy'\nscore = cross_val_score(clf, X_to_model, Y_to_model, cv=k_fold, n_jobs=1, scoring=scoring)\nprint(score)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:49.946211Z","iopub.execute_input":"2022-07-27T16:19:49.946531Z","iopub.status.idle":"2022-07-27T16:19:50.026303Z","shell.execute_reply.started":"2022-07-27T16:19:49.946505Z","shell.execute_reply":"2022-07-27T16:19:50.024975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"round(np.mean(score)*100, 2)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:50.027443Z","iopub.execute_input":"2022-07-27T16:19:50.028094Z","iopub.status.idle":"2022-07-27T16:19:50.035480Z","shell.execute_reply.started":"2022-07-27T16:19:50.028054Z","shell.execute_reply":"2022-07-27T16:19:50.034213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = SVC()\nscoring = 'accuracy'\nscore = cross_val_score(clf, X_to_model, Y_to_model, cv=k_fold, n_jobs=1, scoring=scoring)\nprint(score)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:19:50.037022Z","iopub.execute_input":"2022-07-27T16:19:50.037322Z","iopub.status.idle":"2022-07-27T16:20:03.412304Z","shell.execute_reply.started":"2022-07-27T16:19:50.037295Z","shell.execute_reply":"2022-07-27T16:20:03.411260Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"round(np.mean(score)*100, 2)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:20:03.413547Z","iopub.execute_input":"2022-07-27T16:20:03.413994Z","iopub.status.idle":"2022-07-27T16:20:03.422164Z","shell.execute_reply.started":"2022-07-27T16:20:03.413962Z","shell.execute_reply":"2022-07-27T16:20:03.420862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf_model = RandomForestClassifier()\nrf_model.fit(X_to_model, Y_to_model)\ny_predict = rf_model.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:20:03.423739Z","iopub.execute_input":"2022-07-27T16:20:03.424671Z","iopub.status.idle":"2022-07-27T16:20:04.290237Z","shell.execute_reply.started":"2022-07-27T16:20:03.424630Z","shell.execute_reply":"2022-07-27T16:20:04.289018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame(y_predict,columns=['satisfaction'])\nsubmission['id'] = df_test['id']\nsubmission = submission[['id','satisfaction']]","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:20:04.296389Z","iopub.execute_input":"2022-07-27T16:20:04.297193Z","iopub.status.idle":"2022-07-27T16:20:04.306211Z","shell.execute_reply.started":"2022-07-27T16:20:04.297155Z","shell.execute_reply":"2022-07-27T16:20:04.304888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv',index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:20:04.307610Z","iopub.execute_input":"2022-07-27T16:20:04.308103Z","iopub.status.idle":"2022-07-27T16:20:04.324751Z","shell.execute_reply.started":"2022-07-27T16:20:04.308065Z","shell.execute_reply":"2022-07-27T16:20:04.323487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2022-07-27T16:20:04.326833Z","iopub.execute_input":"2022-07-27T16:20:04.327739Z","iopub.status.idle":"2022-07-27T16:20:04.340039Z","shell.execute_reply.started":"2022-07-27T16:20:04.327691Z","shell.execute_reply":"2022-07-27T16:20:04.338869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}