From faac73c574f674791eb0ad063b5717b2dce10b91 Mon Sep 17 00:00:00 2001 From: shaikhiz <72118161+shaikhiz@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:32:58 -0500 Subject: [PATCH] changes to tpot max time --- tpot_tutorial.ipynb | 253 ++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 137 deletions(-) diff --git a/tpot_tutorial.ipynb b/tpot_tutorial.ipynb index 63f426c..40bbf5b 100644 --- a/tpot_tutorial.ipynb +++ b/tpot_tutorial.ipynb @@ -10,7 +10,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 1, "id": "eaee9fda", "metadata": {}, "outputs": [ @@ -18,33 +18,33 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: torch in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (1.10.2)\n", - "Requirement already satisfied: typing-extensions in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from torch) (3.10.0.2)\n", + "Requirement already satisfied: torch in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (1.13.1)\n", + "Requirement already satisfied: typing-extensions in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from torch) (3.10.0.2)\n", "Note: you may need to restart the kernel to use updated packages.\n", - "Requirement already satisfied: xgboost in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (1.5.2)\n", - "Requirement already satisfied: numpy in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from xgboost) (1.21.2)\n", - "Requirement already satisfied: scipy in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from xgboost) (1.8.0)\n", + "Requirement already satisfied: xgboost in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (1.7.3)\n", + "Requirement already satisfied: numpy in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from xgboost) (1.21.2)\n", + "Requirement already satisfied: scipy in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from xgboost) (1.7.3)\n", "Note: you may need to restart the kernel to use updated packages.\n", - "Requirement already satisfied: tpot in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (0.11.7)\n", - "Requirement already satisfied: xgboost>=1.1.0 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.5.2)\n", - "Requirement already satisfied: joblib>=0.13.2 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.1.0)\n", - "Requirement already satisfied: numpy>=1.16.3 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.21.2)\n", - "Requirement already satisfied: stopit>=1.1.1 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.1.2)\n", - "Requirement already satisfied: tqdm>=4.36.1 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (4.62.3)\n", - "Requirement already satisfied: scipy>=1.3.1 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.8.0)\n", - "Requirement already satisfied: scikit-learn>=0.22.0 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.0.1)\n", - "Requirement already satisfied: update-checker>=0.16 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (0.18.0)\n", - "Requirement already satisfied: deap>=1.2 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.3.1)\n", - "Requirement already satisfied: pandas>=0.24.2 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.3.5)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.2->tpot) (2.8.2)\n", - "Requirement already satisfied: pytz>=2017.3 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.2->tpot) (2021.3)\n", - "Requirement already satisfied: six>=1.5 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas>=0.24.2->tpot) (1.16.0)\n", - "Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from scikit-learn>=0.22.0->tpot) (2.2.0)\n", - "Requirement already satisfied: requests>=2.3.0 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from update-checker>=0.16->tpot) (2.26.0)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (1.26.7)\n", - "Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (2.0.4)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (2021.10.8)\n", - "Requirement already satisfied: idna<4,>=2.5 in /Users/kaitlynarnold/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (3.3)\n", + "Requirement already satisfied: tpot in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (0.11.7)\n", + "Requirement already satisfied: tqdm>=4.36.1 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (4.62.3)\n", + "Requirement already satisfied: xgboost>=1.1.0 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.7.3)\n", + "Requirement already satisfied: deap>=1.2 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.3.3)\n", + "Requirement already satisfied: pandas>=0.24.2 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.3.5)\n", + "Requirement already satisfied: update-checker>=0.16 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (0.18.0)\n", + "Requirement already satisfied: stopit>=1.1.1 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.1.2)\n", + "Requirement already satisfied: scipy>=1.3.1 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.7.3)\n", + "Requirement already satisfied: scikit-learn>=0.22.0 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.0.1)\n", + "Requirement already satisfied: joblib>=0.13.2 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.1.0)\n", + "Requirement already satisfied: numpy>=1.16.3 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from tpot) (1.21.2)\n", + "Requirement already satisfied: python-dateutil>=2.7.3 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.2->tpot) (2.8.2)\n", + "Requirement already satisfied: pytz>=2017.3 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.24.2->tpot) (2021.3)\n", + "Requirement already satisfied: six>=1.5 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas>=0.24.2->tpot) (1.16.0)\n", + "Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from scikit-learn>=0.22.0->tpot) (2.2.0)\n", + "Requirement already satisfied: requests>=2.3.0 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from update-checker>=0.16->tpot) (2.27.1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (3.3)\n", + "Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (2.0.4)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (1.26.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /Users/izaanys/opt/anaconda3/lib/python3.8/site-packages (from requests>=2.3.0->update-checker>=0.16->tpot) (2022.9.24)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } @@ -94,7 +94,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 2, "id": "022ab1ce", "metadata": {}, "outputs": [], @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "2898aaa9", "metadata": {}, "outputs": [ @@ -137,7 +137,7 @@ " 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))" ] }, - "execution_count": 4, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -150,7 +150,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "1d1ac27a", "metadata": {}, "outputs": [ @@ -160,7 +160,7 @@ "((112, 4), (38, 4), (112,), (38,))" ] }, - "execution_count": 5, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -173,21 +173,14 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 5, "id": "015515d0", "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Warning: xgboost.XGBClassifier is not available and will not be used by TPOT.\n" - ] - }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "49da94ec3a20499782a4a98ab6224166", + "model_id": "", "version_major": 2, "version_minor": 0 }, @@ -203,14 +196,14 @@ "output_type": "stream", "text": [ "\n", - "2.21 minutes have elapsed. TPOT will close down.\n", + "2.02 minutes have elapsed. TPOT will close down.\n", "TPOT closed during evaluation in one generation.\n", "WARNING: TPOT may not provide a good pipeline if TPOT is stopped/interrupted in a early generation.\n", "\n", "\n", "TPOT closed prematurely. Will use the current best pipeline.\n", "\n", - "Best pipeline: MLPClassifier(input_matrix, alpha=0.0001, learning_rate_init=0.01)\n", + "Best pipeline: LogisticRegression(input_matrix, C=25.0, dual=False, penalty=l2)\n", "0.9736842105263158\n" ] } @@ -220,14 +213,22 @@ "# Will report the score of the best found pipeline\n", "# Change max_time_mins to a higher time to allow TPOT to run without interuption\n", "# It is currently at 2 mins for sake of not taking to long\n", - "tpot = TPOTClassifier(verbosity=2, max_time_mins=2)\n", + "tpot = TPOTClassifier(verbosity=2, max_time_mins=4)\n", "tpot.fit(X_train, y_train)\n", "print(tpot.score(X_test, y_test))" ] }, + { + "cell_type": "markdown", + "id": "22bb780f", + "metadata": {}, + "source": [ + "Issued warning of TPOT closed prematurely. I am increasing the max_time to 4 so tpot can completely run and the results are more accurate" + ] + }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 6, "id": "fedcae2c", "metadata": {}, "outputs": [], @@ -246,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 7, "id": "f2ac0eda", "metadata": {}, "outputs": [ @@ -388,7 +389,7 @@ "4 0 373450 8.0500 NaN S " ] }, - "execution_count": 12, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -401,7 +402,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 8, "id": "30eeb3aa", "metadata": {}, "outputs": [], @@ -412,7 +413,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 9, "id": "bcc561a3", "metadata": {}, "outputs": [ @@ -436,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 10, "id": "5be7251f", "metadata": {}, "outputs": [ @@ -457,7 +458,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 11, "id": "8bb50fa8", "metadata": {}, "outputs": [], @@ -469,7 +470,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 12, "id": "11c06d01", "metadata": {}, "outputs": [ @@ -491,7 +492,7 @@ "dtype: bool" ] }, - "execution_count": 17, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -504,7 +505,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 13, "id": "aa017a2a", "metadata": {}, "outputs": [], @@ -517,7 +518,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 14, "id": "34567d07", "metadata": {}, "outputs": [ @@ -533,7 +534,7 @@ " [1, 0, 0, ..., 0, 0, 0]])" ] }, - "execution_count": 19, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -544,7 +545,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 15, "id": "f31db644", "metadata": {}, "outputs": [], @@ -555,7 +556,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 16, "id": "e8ccd33c", "metadata": {}, "outputs": [], @@ -566,7 +567,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 17, "id": "594776f6", "metadata": {}, "outputs": [], @@ -578,7 +579,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 18, "id": "e8d47aef", "metadata": {}, "outputs": [ @@ -588,7 +589,7 @@ "False" ] }, - "execution_count": 23, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -600,7 +601,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 19, "id": "6fb6b7df", "metadata": {}, "outputs": [ @@ -610,7 +611,7 @@ "156" ] }, - "execution_count": 24, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -621,7 +622,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 20, "id": "09fe6803", "metadata": {}, "outputs": [], @@ -632,7 +633,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 21, "id": "a14bb5fd", "metadata": {}, "outputs": [ @@ -642,7 +643,7 @@ "(668, 223)" ] }, - "execution_count": 26, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -655,21 +656,14 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "id": "227863a0", "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Warning: xgboost.XGBClassifier is not available and will not be used by TPOT.\n" - ] - }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "", + "model_id": "986af026de044e8694da6328fcffcb1c", "version_major": 2, "version_minor": 0 }, @@ -679,56 +673,36 @@ }, "metadata": {}, "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Generation 1 - Current best internal CV score: 0.8068791381438671\n", - "\n", - "2.01 minutes have elapsed. TPOT will close down.\n", - "TPOT closed during evaluation in one generation.\n", - "WARNING: TPOT may not provide a good pipeline if TPOT is stopped/interrupted in a early generation.\n", - "\n", - "\n", - "TPOT closed prematurely. Will use the current best pipeline.\n", - "\n", - "Best pipeline: DecisionTreeClassifier(input_matrix, criterion=gini, max_depth=3, min_samples_leaf=13, min_samples_split=20)\n" - ] - }, - { - "data": { - "text/plain": [ - "TPOTClassifier(max_eval_time_mins=0.04, max_time_mins=2, population_size=40,\n", - " verbosity=2)" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ "# create the classifier and fit the model, reports the best pipeline\n", "# Parameters within the TPOT Classifier can be changed to allow for longer run time across more models\n", - "tpot = TPOTClassifier(verbosity=2, max_time_mins=2, max_eval_time_mins=0.04, population_size=40)\n", + "tpot = TPOTClassifier(verbosity=2, max_time_mins=4, max_eval_time_mins=0.04, population_size=40)\n", "tpot.fit(titanic_new[training_indices], titanic_class[training_indices])" ] }, + { + "cell_type": "markdown", + "id": "910d6e80", + "metadata": {}, + "source": [ + "Issued warning of TPOT closed prematurely. I am increasing the max_time so tpot can completely run and the results are more accurate" + ] + }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 23, "id": "ca18f35b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "0.757847533632287" + "0.7533632286995515" ] }, - "execution_count": 28, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -740,7 +714,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 24, "id": "4d710e07", "metadata": {}, "outputs": [], @@ -751,7 +725,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 25, "id": "d7ff45ed", "metadata": {}, "outputs": [ @@ -873,7 +847,7 @@ "max 1309.000000 3.000000 76.000000 8.000000 9.000000 512.329200" ] }, - "execution_count": 30, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -886,7 +860,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 26, "id": "8264d2ed", "metadata": {}, "outputs": [], @@ -899,7 +873,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 27, "id": "fe8198e3", "metadata": {}, "outputs": [], @@ -911,7 +885,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 28, "id": "13204313", "metadata": {}, "outputs": [ @@ -932,7 +906,7 @@ "dtype: bool" ] }, - "execution_count": 33, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -945,7 +919,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 29, "id": "82e8d3fb", "metadata": {}, "outputs": [], @@ -960,7 +934,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 30, "id": "185ba8c1", "metadata": {}, "outputs": [], @@ -971,7 +945,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 31, "id": "359c8b6b", "metadata": {}, "outputs": [ @@ -981,7 +955,7 @@ "False" ] }, - "execution_count": 36, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -992,7 +966,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 32, "id": "e73a0c32", "metadata": {}, "outputs": [], @@ -1002,7 +976,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 33, "id": "d868e452", "metadata": {}, "outputs": [], @@ -1013,7 +987,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 34, "id": "1666f357", "metadata": {}, "outputs": [ @@ -1023,7 +997,7 @@ "array([0, 1, 0, 0, 1, 0, 1, 0, 1, 0])" ] }, - "execution_count": 40, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1034,10 +1008,26 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 35, "id": "3d91d737", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "FileNotFoundError", + "evalue": "[Errno 2] No such file or directory: 'data/submission.csv'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/var/folders/tk/mrjkyqms0651_r4m4qvb9xz00000gn/T/ipykernel_43658/2451894762.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m#save as csv\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mfinal\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m'PassengerId'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mtitanic_sub\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'PassengerId'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Survived'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0msubmission\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mfinal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'data/submission.csv'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36mto_csv\u001b[0;34m(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, decimal, errors, storage_options)\u001b[0m\n\u001b[1;32m 3464\u001b[0m )\n\u001b[1;32m 3465\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3466\u001b[0;31m return DataFrameRenderer(formatter).to_csv(\n\u001b[0m\u001b[1;32m 3467\u001b[0m \u001b[0mpath_or_buf\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3468\u001b[0m \u001b[0mline_terminator\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mline_terminator\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/pandas/io/formats/format.py\u001b[0m in \u001b[0;36mto_csv\u001b[0;34m(self, path_or_buf, encoding, sep, columns, index_label, mode, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, errors, storage_options)\u001b[0m\n\u001b[1;32m 1103\u001b[0m \u001b[0mformatter\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfmt\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1104\u001b[0m )\n\u001b[0;32m-> 1105\u001b[0;31m \u001b[0mcsv_formatter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msave\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1106\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1107\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcreated_buffer\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/pandas/io/formats/csvs.py\u001b[0m in \u001b[0;36msave\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 235\u001b[0m \"\"\"\n\u001b[1;32m 236\u001b[0m \u001b[0;31m# apply compression and byte/text conversion\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 237\u001b[0;31m with get_handle(\n\u001b[0m\u001b[1;32m 238\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/pandas/io/common.py\u001b[0m in \u001b[0;36mget_handle\u001b[0;34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[0m\n\u001b[1;32m 700\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mioargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mencoding\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;34m\"b\"\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mioargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 701\u001b[0m \u001b[0;31m# Encoding\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 702\u001b[0;31m handle = open(\n\u001b[0m\u001b[1;32m 703\u001b[0m \u001b[0mhandle\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 704\u001b[0m \u001b[0mioargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'data/submission.csv'" + ] + } + ], "source": [ "#create a data frame with passenger id and what class they belong to (if they survived or not)\n", "#save as csv\n", @@ -1047,21 +1037,10 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": null, "id": "240feb73", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(418, 2)" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "final.shape" ] @@ -1093,7 +1072,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.12" + "version": "3.8.2" } }, "nbformat": 4, -- GitLab