{"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":"Problem statement\n\nWelcome to the year 2912, where your data science skills are needed to solve a cosmic mystery. We've received a transmission from four lightyears away and things aren't looking good.\n\nThe Spaceship Titanic was an interstellar passenger liner launched a month ago. With almost 13,000 passengers on board, the vessel set out on its maiden voyage transporting emigrants from our solar system to three newly habitable exoplanets orbiting nearby stars.\n\nWhile rounding Alpha Centauri en route to its first destination—the torrid 55 Cancri E—the unwary Spaceship Titanic collided with a spacetime anomaly hidden within a dust cloud. Sadly, it met a similar fate as its namesake from 1000 years before. Though the ship stayed intact, almost half of the passengers were transported to an alternate dimension!\n\n\n\nTo help rescue crews and retrieve the lost passengers, you are challenged to predict which passengers were transported by the anomaly using records recovered from the spaceship’s damaged computer system.\n\nHelp save them and change history!","metadata":{}},{"cell_type":"markdown","source":"Import libraries","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.401633Z","iopub.execute_input":"2022-02-27T20:59:17.402546Z","iopub.status.idle":"2022-02-27T20:59:17.408107Z","shell.execute_reply.started":"2022-02-27T20:59:17.402493Z","shell.execute_reply":"2022-02-27T20:59:17.406943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Load files","metadata":{}},{"cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.410435Z","iopub.execute_input":"2022-02-27T20:59:17.411093Z","iopub.status.idle":"2022-02-27T20:59:17.430022Z","shell.execute_reply.started":"2022-02-27T20:59:17.411043Z","shell.execute_reply":"2022-02-27T20:59:17.429064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Read files","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/spaceship-titanic/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/spaceship-titanic/test.csv\")\nsubmission = pd.read_csv(\"/kaggle/input/spaceship-titanic/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.431913Z","iopub.execute_input":"2022-02-27T20:59:17.432442Z","iopub.status.idle":"2022-02-27T20:59:17.492031Z","shell.execute_reply.started":"2022-02-27T20:59:17.432302Z","shell.execute_reply":"2022-02-27T20:59:17.491111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.493287Z","iopub.execute_input":"2022-02-27T20:59:17.493535Z","iopub.status.idle":"2022-02-27T20:59:17.525656Z","shell.execute_reply.started":"2022-02-27T20:59:17.493502Z","shell.execute_reply":"2022-02-27T20:59:17.524784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.528097Z","iopub.execute_input":"2022-02-27T20:59:17.528345Z","iopub.status.idle":"2022-02-27T20:59:17.566163Z","shell.execute_reply.started":"2022-02-27T20:59:17.528318Z","shell.execute_reply":"2022-02-27T20:59:17.56518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.567429Z","iopub.execute_input":"2022-02-27T20:59:17.567725Z","iopub.status.idle":"2022-02-27T20:59:17.582494Z","shell.execute_reply.started":"2022-02-27T20:59:17.567692Z","shell.execute_reply":"2022-02-27T20:59:17.581575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Analyse train","metadata":{}},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.584392Z","iopub.execute_input":"2022-02-27T20:59:17.58513Z","iopub.status.idle":"2022-02-27T20:59:17.606253Z","shell.execute_reply.started":"2022-02-27T20:59:17.585068Z","shell.execute_reply":"2022-02-27T20:59:17.605299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train1 = train.dropna()\ntrain1","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.607887Z","iopub.execute_input":"2022-02-27T20:59:17.608445Z","iopub.status.idle":"2022-02-27T20:59:17.658443Z","shell.execute_reply.started":"2022-02-27T20:59:17.60841Z","shell.execute_reply":"2022-02-27T20:59:17.657539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Analyse target","metadata":{}},{"cell_type":"code","source":"train1['Transported'].replace({False: 0, True: 1},inplace=True)\ntrain1['Transported']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.659817Z","iopub.execute_input":"2022-02-27T20:59:17.66047Z","iopub.status.idle":"2022-02-27T20:59:17.672536Z","shell.execute_reply.started":"2022-02-27T20:59:17.660433Z","shell.execute_reply":"2022-02-27T20:59:17.671908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(train1['Transported'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:17.673917Z","iopub.execute_input":"2022-02-27T20:59:17.674375Z","iopub.status.idle":"2022-02-27T20:59:18.004775Z","shell.execute_reply.started":"2022-02-27T20:59:17.67434Z","shell.execute_reply":"2022-02-27T20:59:18.003783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trans_count = train1['Transported'].value_counts()\ntrans_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.006121Z","iopub.execute_input":"2022-02-27T20:59:18.006351Z","iopub.status.idle":"2022-02-27T20:59:18.014156Z","shell.execute_reply.started":"2022-02-27T20:59:18.006319Z","shell.execute_reply":"2022-02-27T20:59:18.013216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trans_percent = trans_count / len(train1)\ntrans_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.015832Z","iopub.execute_input":"2022-02-27T20:59:18.016091Z","iopub.status.idle":"2022-02-27T20:59:18.03375Z","shell.execute_reply.started":"2022-02-27T20:59:18.016062Z","shell.execute_reply":"2022-02-27T20:59:18.033031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(25, 7))\nax = plt.subplot()\nax.scatter(train1[train1['Transported'] == 1]['Age'], train1[train['Transported'] == 1]['FoodCourt'], c='green', s=train1[train1['Transported'] == 1]['VRDeck'])\nax.scatter(train1[train1['Transported'] == 0]['Age'], train1[train['Transported'] == 0]['FoodCourt'], c='red', s=train1[train1['Transported'] == 0]['VRDeck']);\n","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.034936Z","iopub.execute_input":"2022-02-27T20:59:18.035161Z","iopub.status.idle":"2022-02-27T20:59:18.528012Z","shell.execute_reply.started":"2022-02-27T20:59:18.035134Z","shell.execute_reply":"2022-02-27T20:59:18.526964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Drop target","metadata":{}},{"cell_type":"code","source":"target = train1['Transported']\n\ntrain1.drop(['Transported'],axis=1, inplace=True)\ntrain1","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.531324Z","iopub.execute_input":"2022-02-27T20:59:18.532173Z","iopub.status.idle":"2022-02-27T20:59:18.567218Z","shell.execute_reply.started":"2022-02-27T20:59:18.532133Z","shell.execute_reply":"2022-02-27T20:59:18.566556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Combine train and test","metadata":{}},{"cell_type":"code","source":"combi = train1.append(test)\ncombi","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.56839Z","iopub.execute_input":"2022-02-27T20:59:18.568726Z","iopub.status.idle":"2022-02-27T20:59:18.600565Z","shell.execute_reply.started":"2022-02-27T20:59:18.568699Z","shell.execute_reply":"2022-02-27T20:59:18.599662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Analyse combi","metadata":{}},{"cell_type":"code","source":"combi.info()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.601985Z","iopub.execute_input":"2022-02-27T20:59:18.602195Z","iopub.status.idle":"2022-02-27T20:59:18.624691Z","shell.execute_reply.started":"2022-02-27T20:59:18.602168Z","shell.execute_reply":"2022-02-27T20:59:18.623816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi.describe()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.626398Z","iopub.execute_input":"2022-02-27T20:59:18.626765Z","iopub.status.idle":"2022-02-27T20:59:18.661174Z","shell.execute_reply.started":"2022-02-27T20:59:18.62672Z","shell.execute_reply":"2022-02-27T20:59:18.660084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Check for null values","metadata":{}},{"cell_type":"code","source":"combi.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.662486Z","iopub.execute_input":"2022-02-27T20:59:18.66311Z","iopub.status.idle":"2022-02-27T20:59:18.681748Z","shell.execute_reply.started":"2022-02-27T20:59:18.663069Z","shell.execute_reply":"2022-02-27T20:59:18.680911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Impute null values","metadata":{}},{"cell_type":"code","source":"from sklearn.experimental import enable_iterative_imputer\nfrom sklearn.impute import IterativeImputer\n\nimp = IterativeImputer(random_state=42)\n\ndate = pd.Timestamp('2200-01-01')\n\nfor col in combi:\n    if combi[col].dtype==\"object\":\n        combi[col].fillna(\"not listed\", inplace=True)\n    if combi[col].dtype==\"int\":\n        #X[col].fillna(X[col].mode()[0], inplace=True)\n        combi[col].fillna(combi[col].mean(), inplace=True)\n        #combi[col] = combi[col].astype.int()\n    if combi[col].dtype=='float':\n       #X[col].fillna(X[col].mean(), inplace=True)\n       combi[col] = imp.fit_transform(combi[col].values.reshape(-1,1))\n    if combi[col].dtype==\"datetime64[ns]\":\n        combi[col].fillna(date, inplace=True)\ncombi","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.682942Z","iopub.execute_input":"2022-02-27T20:59:18.68319Z","iopub.status.idle":"2022-02-27T20:59:18.741215Z","shell.execute_reply.started":"2022-02-27T20:59:18.683162Z","shell.execute_reply":"2022-02-27T20:59:18.740299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.742459Z","iopub.execute_input":"2022-02-27T20:59:18.742699Z","iopub.status.idle":"2022-02-27T20:59:18.760343Z","shell.execute_reply.started":"2022-02-27T20:59:18.742671Z","shell.execute_reply":"2022-02-27T20:59:18.759407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Analyse features","metadata":{}},{"cell_type":"markdown","source":"Home Planet","metadata":{}},{"cell_type":"code","source":"sns.displot(combi['HomePlanet'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:18.762212Z","iopub.execute_input":"2022-02-27T20:59:18.763116Z","iopub.status.idle":"2022-02-27T20:59:19.056567Z","shell.execute_reply.started":"2022-02-27T20:59:18.763079Z","shell.execute_reply":"2022-02-27T20:59:19.055533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"home_count = combi['HomePlanet'].value_counts()\nhome_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.058119Z","iopub.execute_input":"2022-02-27T20:59:19.058448Z","iopub.status.idle":"2022-02-27T20:59:19.070242Z","shell.execute_reply.started":"2022-02-27T20:59:19.058402Z","shell.execute_reply":"2022-02-27T20:59:19.069201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"home_percent = home_count / len(combi)\nhome_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.071451Z","iopub.execute_input":"2022-02-27T20:59:19.071716Z","iopub.status.idle":"2022-02-27T20:59:19.083738Z","shell.execute_reply.started":"2022-02-27T20:59:19.071685Z","shell.execute_reply":"2022-02-27T20:59:19.0828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"Earth\", \"Europa\", \"Mars\", \"not listed\"]\nplt.pie(home_percent, labels=mylabels)\nplt.show() ","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.085482Z","iopub.execute_input":"2022-02-27T20:59:19.086773Z","iopub.status.idle":"2022-02-27T20:59:19.189237Z","shell.execute_reply.started":"2022-02-27T20:59:19.086731Z","shell.execute_reply":"2022-02-27T20:59:19.188185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['HomePlanet'].replace({\"Earth\": 1, \"Europa\": 2, \"Mars\": 3, \"not listed\": 4},inplace=True)\ncombi['HomePlanet']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.191115Z","iopub.execute_input":"2022-02-27T20:59:19.191706Z","iopub.status.idle":"2022-02-27T20:59:19.223048Z","shell.execute_reply.started":"2022-02-27T20:59:19.191647Z","shell.execute_reply":"2022-02-27T20:59:19.2217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Cryo Sleep","metadata":{}},{"cell_type":"code","source":"combi['CryoSleep'][combi['CryoSleep'] == 'not listed'] = False","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.225396Z","iopub.execute_input":"2022-02-27T20:59:19.225826Z","iopub.status.idle":"2022-02-27T20:59:19.243551Z","shell.execute_reply.started":"2022-02-27T20:59:19.22578Z","shell.execute_reply":"2022-02-27T20:59:19.241672Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(combi.iloc[6674])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.245321Z","iopub.execute_input":"2022-02-27T20:59:19.24599Z","iopub.status.idle":"2022-02-27T20:59:19.25896Z","shell.execute_reply.started":"2022-02-27T20:59:19.245934Z","shell.execute_reply":"2022-02-27T20:59:19.257553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['CryoSleep'].replace({False: 0, True: 1})","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.261592Z","iopub.execute_input":"2022-02-27T20:59:19.26234Z","iopub.status.idle":"2022-02-27T20:59:19.286972Z","shell.execute_reply.started":"2022-02-27T20:59:19.262115Z","shell.execute_reply":"2022-02-27T20:59:19.286271Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(combi['CryoSleep'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.28809Z","iopub.execute_input":"2022-02-27T20:59:19.288449Z","iopub.status.idle":"2022-02-27T20:59:19.617024Z","shell.execute_reply.started":"2022-02-27T20:59:19.288414Z","shell.execute_reply":"2022-02-27T20:59:19.616164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sleep_count = combi['CryoSleep'].value_counts()\nsleep_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.618302Z","iopub.execute_input":"2022-02-27T20:59:19.618723Z","iopub.status.idle":"2022-02-27T20:59:19.626821Z","shell.execute_reply.started":"2022-02-27T20:59:19.618675Z","shell.execute_reply":"2022-02-27T20:59:19.626158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sleep_percent = sleep_count / len(combi)\nsleep_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.628213Z","iopub.execute_input":"2022-02-27T20:59:19.62869Z","iopub.status.idle":"2022-02-27T20:59:19.642828Z","shell.execute_reply.started":"2022-02-27T20:59:19.628647Z","shell.execute_reply":"2022-02-27T20:59:19.642154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['CryoSleep'] = combi['CryoSleep'].astype(int)\ncombi['CryoSleep']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.644332Z","iopub.execute_input":"2022-02-27T20:59:19.645027Z","iopub.status.idle":"2022-02-27T20:59:19.667143Z","shell.execute_reply.started":"2022-02-27T20:59:19.644988Z","shell.execute_reply":"2022-02-27T20:59:19.666129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Destination","metadata":{}},{"cell_type":"code","source":"sns.displot(combi['Destination'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.669023Z","iopub.execute_input":"2022-02-27T20:59:19.669356Z","iopub.status.idle":"2022-02-27T20:59:19.988769Z","shell.execute_reply.started":"2022-02-27T20:59:19.669309Z","shell.execute_reply":"2022-02-27T20:59:19.98799Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dest_count = combi['Destination'].value_counts()\ndest_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:19.989998Z","iopub.execute_input":"2022-02-27T20:59:19.991006Z","iopub.status.idle":"2022-02-27T20:59:20.001157Z","shell.execute_reply.started":"2022-02-27T20:59:19.990952Z","shell.execute_reply":"2022-02-27T20:59:20.000292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dest_percent = dest_count / len(combi)\ndest_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.002726Z","iopub.execute_input":"2022-02-27T20:59:20.00308Z","iopub.status.idle":"2022-02-27T20:59:20.016877Z","shell.execute_reply.started":"2022-02-27T20:59:20.003034Z","shell.execute_reply":"2022-02-27T20:59:20.015944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"TRAPPIST-1e\", \"55 Cancri e\", \"PSO J318.5-22\", \"not listed\"]\nplt.pie(dest_percent, labels=mylabels)\nplt.show() ","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.018559Z","iopub.execute_input":"2022-02-27T20:59:20.019069Z","iopub.status.idle":"2022-02-27T20:59:20.124197Z","shell.execute_reply.started":"2022-02-27T20:59:20.019033Z","shell.execute_reply":"2022-02-27T20:59:20.123208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Destination'].replace({\"TRAPPIST-1e\": 1, \"55 Cancri e\": 2, \"PSO J318.5-22\": 3, \"not listed\": 4},inplace=True)\ncombi['Destination']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.126182Z","iopub.execute_input":"2022-02-27T20:59:20.127423Z","iopub.status.idle":"2022-02-27T20:59:20.157206Z","shell.execute_reply.started":"2022-02-27T20:59:20.127364Z","shell.execute_reply":"2022-02-27T20:59:20.156187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Age","metadata":{}},{"cell_type":"code","source":"combi['Age_group'] = pd.cut(x=combi['Age'], bins=[-1, 18, 40, 65, 100], labels=['child', 'young adult', 'middle age', 'pensioner'])\ncombi['Age_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.158741Z","iopub.execute_input":"2022-02-27T20:59:20.159658Z","iopub.status.idle":"2022-02-27T20:59:20.180259Z","shell.execute_reply.started":"2022-02-27T20:59:20.159597Z","shell.execute_reply":"2022-02-27T20:59:20.179224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(combi['Age_group'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.181838Z","iopub.execute_input":"2022-02-27T20:59:20.182725Z","iopub.status.idle":"2022-02-27T20:59:20.490033Z","shell.execute_reply.started":"2022-02-27T20:59:20.182668Z","shell.execute_reply":"2022-02-27T20:59:20.489155Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"age_count = combi['Age_group'].value_counts()\nage_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.491378Z","iopub.execute_input":"2022-02-27T20:59:20.491607Z","iopub.status.idle":"2022-02-27T20:59:20.500543Z","shell.execute_reply.started":"2022-02-27T20:59:20.491579Z","shell.execute_reply":"2022-02-27T20:59:20.499638Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"age_percent = age_count / len(combi)\nage_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.507352Z","iopub.execute_input":"2022-02-27T20:59:20.507762Z","iopub.status.idle":"2022-02-27T20:59:20.514278Z","shell.execute_reply.started":"2022-02-27T20:59:20.507725Z","shell.execute_reply":"2022-02-27T20:59:20.51373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"young adult\", \"child\", \"middle age\", \"pensioner\"]\nplt.pie(age_percent, labels=mylabels)\nplt.show() ","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.515585Z","iopub.execute_input":"2022-02-27T20:59:20.515795Z","iopub.status.idle":"2022-02-27T20:59:20.619873Z","shell.execute_reply.started":"2022-02-27T20:59:20.51577Z","shell.execute_reply":"2022-02-27T20:59:20.618718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Age_group'].replace({\"young adult\": 1, \"child\": 2, \"middle age\": 3, \"pensioner\": 4},inplace=True)\ncombi['Age_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.621667Z","iopub.execute_input":"2022-02-27T20:59:20.622118Z","iopub.status.idle":"2022-02-27T20:59:20.646649Z","shell.execute_reply.started":"2022-02-27T20:59:20.622059Z","shell.execute_reply":"2022-02-27T20:59:20.645591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Age_group'] = combi['Age_group'].astype(int)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.648402Z","iopub.execute_input":"2022-02-27T20:59:20.648829Z","iopub.status.idle":"2022-02-27T20:59:20.655799Z","shell.execute_reply.started":"2022-02-27T20:59:20.648778Z","shell.execute_reply":"2022-02-27T20:59:20.654714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"VIP","metadata":{}},{"cell_type":"code","source":"combi['VIP'][combi['VIP'] == 'not listed'] = False","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.657699Z","iopub.execute_input":"2022-02-27T20:59:20.658109Z","iopub.status.idle":"2022-02-27T20:59:20.67835Z","shell.execute_reply.started":"2022-02-27T20:59:20.65805Z","shell.execute_reply":"2022-02-27T20:59:20.677242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['VIP'].replace({False: 0, True: 1})","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.680655Z","iopub.execute_input":"2022-02-27T20:59:20.681122Z","iopub.status.idle":"2022-02-27T20:59:20.705405Z","shell.execute_reply.started":"2022-02-27T20:59:20.68106Z","shell.execute_reply":"2022-02-27T20:59:20.704253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(combi['VIP'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:20.707498Z","iopub.execute_input":"2022-02-27T20:59:20.707754Z","iopub.status.idle":"2022-02-27T20:59:21.089781Z","shell.execute_reply.started":"2022-02-27T20:59:20.707723Z","shell.execute_reply":"2022-02-27T20:59:21.088723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vip_count = combi['VIP'].value_counts()\nvip_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.091255Z","iopub.execute_input":"2022-02-27T20:59:21.091525Z","iopub.status.idle":"2022-02-27T20:59:21.102102Z","shell.execute_reply.started":"2022-02-27T20:59:21.091493Z","shell.execute_reply":"2022-02-27T20:59:21.100932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vip_percent = vip_count / len(combi)\nvip_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.10394Z","iopub.execute_input":"2022-02-27T20:59:21.104487Z","iopub.status.idle":"2022-02-27T20:59:21.119731Z","shell.execute_reply.started":"2022-02-27T20:59:21.104447Z","shell.execute_reply":"2022-02-27T20:59:21.118825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['VIP'] = combi['VIP'].astype(int)\ncombi['VIP']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.121652Z","iopub.execute_input":"2022-02-27T20:59:21.122041Z","iopub.status.idle":"2022-02-27T20:59:21.136188Z","shell.execute_reply.started":"2022-02-27T20:59:21.121987Z","shell.execute_reply":"2022-02-27T20:59:21.135297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Room Service","metadata":{}},{"cell_type":"code","source":"sns.violinplot(combi['RoomService'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.137777Z","iopub.execute_input":"2022-02-27T20:59:21.13827Z","iopub.status.idle":"2022-02-27T20:59:21.366133Z","shell.execute_reply.started":"2022-02-27T20:59:21.138226Z","shell.execute_reply":"2022-02-27T20:59:21.365414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rm_service_high = combi['RoomService'].max()\nprint(rm_service_high)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.368007Z","iopub.execute_input":"2022-02-27T20:59:21.368707Z","iopub.status.idle":"2022-02-27T20:59:21.375178Z","shell.execute_reply.started":"2022-02-27T20:59:21.368652Z","shell.execute_reply":"2022-02-27T20:59:21.374262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Room_Service_group'] = pd.cut(x=combi['RoomService'], bins=[-1, 2000, 8000, 12000], labels=['low', 'med', 'high'])\ncombi['Room_Service_group']\n","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.376391Z","iopub.execute_input":"2022-02-27T20:59:21.37721Z","iopub.status.idle":"2022-02-27T20:59:21.397905Z","shell.execute_reply.started":"2022-02-27T20:59:21.377158Z","shell.execute_reply":"2022-02-27T20:59:21.396827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(combi['Room_Service_group'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.399329Z","iopub.execute_input":"2022-02-27T20:59:21.40049Z","iopub.status.idle":"2022-02-27T20:59:21.675895Z","shell.execute_reply.started":"2022-02-27T20:59:21.400452Z","shell.execute_reply":"2022-02-27T20:59:21.675235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rm_service_count = combi['Room_Service_group'].value_counts()\nrm_service_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.677606Z","iopub.execute_input":"2022-02-27T20:59:21.679424Z","iopub.status.idle":"2022-02-27T20:59:21.694599Z","shell.execute_reply.started":"2022-02-27T20:59:21.679365Z","shell.execute_reply":"2022-02-27T20:59:21.693402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rm_service_percent = rm_service_count / len(combi)\nrm_service_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.696381Z","iopub.execute_input":"2022-02-27T20:59:21.69671Z","iopub.status.idle":"2022-02-27T20:59:21.713311Z","shell.execute_reply.started":"2022-02-27T20:59:21.696665Z","shell.execute_reply":"2022-02-27T20:59:21.71246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"low\", \"med\", \"high\"]\nplt.pie(rm_service_percent, labels=mylabels)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.714843Z","iopub.execute_input":"2022-02-27T20:59:21.715308Z","iopub.status.idle":"2022-02-27T20:59:21.831137Z","shell.execute_reply.started":"2022-02-27T20:59:21.715274Z","shell.execute_reply":"2022-02-27T20:59:21.829947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Room_Service_group'].replace({\"low\": 1, \"med\": 2, \"high\": 3},inplace=True)\ncombi['Room_Service_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.833071Z","iopub.execute_input":"2022-02-27T20:59:21.834036Z","iopub.status.idle":"2022-02-27T20:59:21.857221Z","shell.execute_reply.started":"2022-02-27T20:59:21.833984Z","shell.execute_reply":"2022-02-27T20:59:21.856272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Food Court","metadata":{}},{"cell_type":"code","source":"sns.violinplot(combi['FoodCourt'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:21.859299Z","iopub.execute_input":"2022-02-27T20:59:21.860149Z","iopub.status.idle":"2022-02-27T20:59:22.114182Z","shell.execute_reply.started":"2022-02-27T20:59:21.860042Z","shell.execute_reply":"2022-02-27T20:59:22.113104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"food_high = combi['FoodCourt'].max()\nprint(food_high)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.115408Z","iopub.execute_input":"2022-02-27T20:59:22.115675Z","iopub.status.idle":"2022-02-27T20:59:22.123743Z","shell.execute_reply.started":"2022-02-27T20:59:22.115642Z","shell.execute_reply":"2022-02-27T20:59:22.122969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Food_Court_group'] = pd.cut(x=combi['FoodCourt'], bins=[-1, 5000, 20000, 30000], labels=['low', 'med', 'high'])\ncombi['Food_Court_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.125249Z","iopub.execute_input":"2022-02-27T20:59:22.125881Z","iopub.status.idle":"2022-02-27T20:59:22.144262Z","shell.execute_reply.started":"2022-02-27T20:59:22.125824Z","shell.execute_reply":"2022-02-27T20:59:22.143174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(combi['Food_Court_group'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.146274Z","iopub.execute_input":"2022-02-27T20:59:22.147195Z","iopub.status.idle":"2022-02-27T20:59:22.437036Z","shell.execute_reply.started":"2022-02-27T20:59:22.147005Z","shell.execute_reply":"2022-02-27T20:59:22.435643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fd_court_count = combi['Food_Court_group'].value_counts()\nfd_court_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.438923Z","iopub.execute_input":"2022-02-27T20:59:22.43955Z","iopub.status.idle":"2022-02-27T20:59:22.448883Z","shell.execute_reply.started":"2022-02-27T20:59:22.439503Z","shell.execute_reply":"2022-02-27T20:59:22.447955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fd_court_percent = fd_court_count / len(combi)\nfd_court_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.450151Z","iopub.execute_input":"2022-02-27T20:59:22.451085Z","iopub.status.idle":"2022-02-27T20:59:22.463284Z","shell.execute_reply.started":"2022-02-27T20:59:22.451034Z","shell.execute_reply":"2022-02-27T20:59:22.462514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"low\", \"med\", \"high\"]\nplt.pie(fd_court_percent, labels=mylabels)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.464764Z","iopub.execute_input":"2022-02-27T20:59:22.465639Z","iopub.status.idle":"2022-02-27T20:59:22.570766Z","shell.execute_reply.started":"2022-02-27T20:59:22.465577Z","shell.execute_reply":"2022-02-27T20:59:22.569843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Food_Court_group'].replace({\"low\": 1, \"med\": 2, \"high\": 3},inplace=True)\ncombi['Food_Court_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.572145Z","iopub.execute_input":"2022-02-27T20:59:22.572886Z","iopub.status.idle":"2022-02-27T20:59:22.588138Z","shell.execute_reply.started":"2022-02-27T20:59:22.572825Z","shell.execute_reply":"2022-02-27T20:59:22.587304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Shopping Mall","metadata":{}},{"cell_type":"code","source":"sns.violinplot(combi['ShoppingMall'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.589522Z","iopub.execute_input":"2022-02-27T20:59:22.591066Z","iopub.status.idle":"2022-02-27T20:59:22.850574Z","shell.execute_reply.started":"2022-02-27T20:59:22.591017Z","shell.execute_reply":"2022-02-27T20:59:22.849909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shop_high = combi['ShoppingMall'].max()\nprint(shop_high)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.852335Z","iopub.execute_input":"2022-02-27T20:59:22.853235Z","iopub.status.idle":"2022-02-27T20:59:22.860106Z","shell.execute_reply.started":"2022-02-27T20:59:22.853182Z","shell.execute_reply":"2022-02-27T20:59:22.85883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Shopping_group'] = pd.cut(x=combi['ShoppingMall'], bins=[-1, 2000, 8000, 13000], labels=['low', 'med', 'high'])\ncombi['Shopping_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.86161Z","iopub.execute_input":"2022-02-27T20:59:22.862325Z","iopub.status.idle":"2022-02-27T20:59:22.880412Z","shell.execute_reply.started":"2022-02-27T20:59:22.862276Z","shell.execute_reply":"2022-02-27T20:59:22.879551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(combi['Shopping_group'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:22.882073Z","iopub.execute_input":"2022-02-27T20:59:22.88256Z","iopub.status.idle":"2022-02-27T20:59:23.156264Z","shell.execute_reply.started":"2022-02-27T20:59:22.882517Z","shell.execute_reply":"2022-02-27T20:59:23.155501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shopping_count = combi['Shopping_group'].value_counts()\nshopping_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.157684Z","iopub.execute_input":"2022-02-27T20:59:23.158045Z","iopub.status.idle":"2022-02-27T20:59:23.16789Z","shell.execute_reply.started":"2022-02-27T20:59:23.157999Z","shell.execute_reply":"2022-02-27T20:59:23.166712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shopping_percent = shopping_count / len(combi)\nshopping_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.169601Z","iopub.execute_input":"2022-02-27T20:59:23.17039Z","iopub.status.idle":"2022-02-27T20:59:23.182097Z","shell.execute_reply.started":"2022-02-27T20:59:23.170345Z","shell.execute_reply":"2022-02-27T20:59:23.181298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"low\", \"med\", \"high\"]\nplt.pie(shopping_percent, labels=mylabels)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.18364Z","iopub.execute_input":"2022-02-27T20:59:23.184347Z","iopub.status.idle":"2022-02-27T20:59:23.278385Z","shell.execute_reply.started":"2022-02-27T20:59:23.184309Z","shell.execute_reply":"2022-02-27T20:59:23.276954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Shopping_group'].replace({\"low\": 1, \"med\": 2, \"high\": 3},inplace=True)\ncombi['Shopping_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.280657Z","iopub.execute_input":"2022-02-27T20:59:23.281073Z","iopub.status.idle":"2022-02-27T20:59:23.30561Z","shell.execute_reply.started":"2022-02-27T20:59:23.281023Z","shell.execute_reply":"2022-02-27T20:59:23.304465Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Spa","metadata":{}},{"cell_type":"code","source":"sns.violinplot(combi['Spa'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.307694Z","iopub.execute_input":"2022-02-27T20:59:23.308111Z","iopub.status.idle":"2022-02-27T20:59:23.558594Z","shell.execute_reply.started":"2022-02-27T20:59:23.308058Z","shell.execute_reply":"2022-02-27T20:59:23.557784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spa_high = combi['Spa'].max()\nprint(spa_high)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.559914Z","iopub.execute_input":"2022-02-27T20:59:23.560399Z","iopub.status.idle":"2022-02-27T20:59:23.566899Z","shell.execute_reply.started":"2022-02-27T20:59:23.560355Z","shell.execute_reply":"2022-02-27T20:59:23.565805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Spa_group'] = pd.cut(x=combi['Spa'], bins=[-1, 5000, 15000, 23000], labels=['low', 'med', 'high'])\ncombi['Spa_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.568482Z","iopub.execute_input":"2022-02-27T20:59:23.568804Z","iopub.status.idle":"2022-02-27T20:59:23.59002Z","shell.execute_reply.started":"2022-02-27T20:59:23.568761Z","shell.execute_reply":"2022-02-27T20:59:23.588979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(combi['Spa_group'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.591258Z","iopub.execute_input":"2022-02-27T20:59:23.591949Z","iopub.status.idle":"2022-02-27T20:59:23.871288Z","shell.execute_reply.started":"2022-02-27T20:59:23.591911Z","shell.execute_reply":"2022-02-27T20:59:23.870222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spa_count = combi['Spa_group'].value_counts()\nspa_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.873218Z","iopub.execute_input":"2022-02-27T20:59:23.873553Z","iopub.status.idle":"2022-02-27T20:59:23.88302Z","shell.execute_reply.started":"2022-02-27T20:59:23.87351Z","shell.execute_reply":"2022-02-27T20:59:23.882166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"spa_percent = spa_count / len(combi)\nspa_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.884792Z","iopub.execute_input":"2022-02-27T20:59:23.885106Z","iopub.status.idle":"2022-02-27T20:59:23.901025Z","shell.execute_reply.started":"2022-02-27T20:59:23.885073Z","shell.execute_reply":"2022-02-27T20:59:23.899896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"low\", \"med\", \"high\"]\nplt.pie(spa_percent, labels=mylabels)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:23.902558Z","iopub.execute_input":"2022-02-27T20:59:23.903333Z","iopub.status.idle":"2022-02-27T20:59:24.008982Z","shell.execute_reply.started":"2022-02-27T20:59:23.903292Z","shell.execute_reply":"2022-02-27T20:59:24.007948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['Spa_group'].replace({\"low\": 1, \"med\": 2, \"high\": 3},inplace=True)\ncombi['Spa_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.010591Z","iopub.execute_input":"2022-02-27T20:59:24.0112Z","iopub.status.idle":"2022-02-27T20:59:24.039485Z","shell.execute_reply.started":"2022-02-27T20:59:24.011143Z","shell.execute_reply":"2022-02-27T20:59:24.038434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"VR Deck","metadata":{}},{"cell_type":"code","source":"sns.violinplot(combi['VRDeck'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.041102Z","iopub.execute_input":"2022-02-27T20:59:24.042251Z","iopub.status.idle":"2022-02-27T20:59:24.26317Z","shell.execute_reply.started":"2022-02-27T20:59:24.042183Z","shell.execute_reply":"2022-02-27T20:59:24.262384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vr_high = combi['VRDeck'].max()\nprint(vr_high)","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.264424Z","iopub.execute_input":"2022-02-27T20:59:24.264961Z","iopub.status.idle":"2022-02-27T20:59:24.271309Z","shell.execute_reply.started":"2022-02-27T20:59:24.264915Z","shell.execute_reply":"2022-02-27T20:59:24.270466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['VR_group'] = pd.cut(x=combi['VRDeck'], bins=[-1, 5000, 15000, 23000], labels=['low', 'med', 'high'])\ncombi['VR_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.273001Z","iopub.execute_input":"2022-02-27T20:59:24.273583Z","iopub.status.idle":"2022-02-27T20:59:24.295317Z","shell.execute_reply.started":"2022-02-27T20:59:24.273538Z","shell.execute_reply":"2022-02-27T20:59:24.294349Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(combi['VR_group'])","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.29674Z","iopub.execute_input":"2022-02-27T20:59:24.297093Z","iopub.status.idle":"2022-02-27T20:59:24.515279Z","shell.execute_reply.started":"2022-02-27T20:59:24.297052Z","shell.execute_reply":"2022-02-27T20:59:24.514141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vr_count = combi['VR_group'].value_counts()\nvr_count","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.517038Z","iopub.execute_input":"2022-02-27T20:59:24.517361Z","iopub.status.idle":"2022-02-27T20:59:24.526502Z","shell.execute_reply.started":"2022-02-27T20:59:24.517318Z","shell.execute_reply":"2022-02-27T20:59:24.525442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vr_percent = vr_count / len(combi)\nvr_percent","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.527627Z","iopub.execute_input":"2022-02-27T20:59:24.527892Z","iopub.status.idle":"2022-02-27T20:59:24.543099Z","shell.execute_reply.started":"2022-02-27T20:59:24.527833Z","shell.execute_reply":"2022-02-27T20:59:24.542072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mylabels = [\"low\", \"med\", \"high\"]\nplt.pie(vr_percent, labels=mylabels)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.544568Z","iopub.execute_input":"2022-02-27T20:59:24.544994Z","iopub.status.idle":"2022-02-27T20:59:24.931614Z","shell.execute_reply.started":"2022-02-27T20:59:24.544957Z","shell.execute_reply":"2022-02-27T20:59:24.930698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"combi['VR_group'].replace({\"low\": 1, \"med\": 2, \"high\": 3},inplace=True)\ncombi['VR_group']","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.933118Z","iopub.execute_input":"2022-02-27T20:59:24.934169Z","iopub.status.idle":"2022-02-27T20:59:24.95977Z","shell.execute_reply.started":"2022-02-27T20:59:24.93411Z","shell.execute_reply":"2022-02-27T20:59:24.958336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Assign features","metadata":{}},{"cell_type":"code","source":"combi.info()","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:24.961878Z","iopub.execute_input":"2022-02-27T20:59:24.962892Z","iopub.status.idle":"2022-02-27T20:59:24.998444Z","shell.execute_reply.started":"2022-02-27T20:59:24.962802Z","shell.execute_reply":"2022-02-27T20:59:24.997004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Define X and y","metadata":{}},{"cell_type":"code","source":"features = [\"HomePlanet\", \"CryoSleep\", \"Destination\", \"Age_group\", \"Room_Service_group\", \"Food_Court_group\", \"Shopping_group\", \"Spa_group\", \"VR_group\"]\n\ny = target\nX = combi[features][: len(train1)]\nX_test = combi[features][len(train1) :]","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:25.001157Z","iopub.execute_input":"2022-02-27T20:59:25.001559Z","iopub.status.idle":"2022-02-27T20:59:25.016992Z","shell.execute_reply.started":"2022-02-27T20:59:25.001509Z","shell.execute_reply":"2022-02-27T20:59:25.015105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Heatmap","metadata":{}},{"cell_type":"code","source":"cmap = combi[features].corr()\nsns.heatmap(cmap)\n","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:25.022016Z","iopub.execute_input":"2022-02-27T20:59:25.024011Z","iopub.status.idle":"2022-02-27T20:59:25.413589Z","shell.execute_reply.started":"2022-02-27T20:59:25.023927Z","shell.execute_reply":"2022-02-27T20:59:25.412761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Split dataset for training and validating","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\nX_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.10, random_state=1, stratify=y, shuffle=True)\nX_train.shape, X_val.shape, y_train.shape, y_val.shape, X_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-27T20:59:25.414731Z","iopub.execute_input":"2022-02-27T20:59:25.415098Z","iopub.status.idle":"2022-02-27T20:59:25.432922Z","shell.execute_reply.started":"2022-02-27T20:59:25.415059Z","shell.execute_reply":"2022-02-27T20:59:25.432039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Select model","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\n\nmodel = LogisticRegression(random_state=42, C=10).fit(X_train, y_train)\nprint(model.score(X_train, y_train))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:02:57.060155Z","iopub.execute_input":"2022-02-27T21:02:57.060471Z","iopub.status.idle":"2022-02-27T21:02:57.176542Z","shell.execute_reply.started":"2022-02-27T21:02:57.060436Z","shell.execute_reply":"2022-02-27T21:02:57.175579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Predict validation","metadata":{}},{"cell_type":"code","source":"y_pred = model.predict(X_val)\nprint(model.score(X_val, y_val))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:04:42.319578Z","iopub.execute_input":"2022-02-27T21:04:42.32062Z","iopub.status.idle":"2022-02-27T21:04:42.332835Z","shell.execute_reply.started":"2022-02-27T21:04:42.320582Z","shell.execute_reply":"2022-02-27T21:04:42.33183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Confusion matrix","metadata":{}},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix\n\nprint(confusion_matrix(y_val, y_pred))","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:05:32.229846Z","iopub.execute_input":"2022-02-27T21:05:32.230515Z","iopub.status.idle":"2022-02-27T21:05:32.243091Z","shell.execute_reply.started":"2022-02-27T21:05:32.230467Z","shell.execute_reply":"2022-02-27T21:05:32.241818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Predict on X_test","metadata":{}},{"cell_type":"code","source":"predictions = model.predict(X_test)\npredictions = predictions.astype(str)\npredictions = np.char.replace(predictions, '0', 'False')\npredictions = np.char.replace(predictions, '1', 'True')\npredictions","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:11:56.029824Z","iopub.execute_input":"2022-02-27T21:11:56.030214Z","iopub.status.idle":"2022-02-27T21:11:56.092631Z","shell.execute_reply.started":"2022-02-27T21:11:56.030174Z","shell.execute_reply":"2022-02-27T21:11:56.091674Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Prepare and submit","metadata":{}},{"cell_type":"code","source":"submission['Transported'] = predictions\nsubmission.to_csv('submission.csv', index=False)\nmy_submission = pd.read_csv(\"submission.csv\")\nmy_submission","metadata":{"execution":{"iopub.status.busy":"2022-02-27T21:13:34.999148Z","iopub.execute_input":"2022-02-27T21:13:34.999472Z","iopub.status.idle":"2022-02-27T21:13:35.035992Z","shell.execute_reply.started":"2022-02-27T21:13:34.99944Z","shell.execute_reply":"2022-02-27T21:13:35.034935Z"},"trusted":true},"execution_count":null,"outputs":[]}]}