{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "30b61190-61c1-4dd2-a9ec-acbadc8a52ef",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Supervised learning - Classification\n",
    "Goal of the excercise is to learn how to use Scikit-learn library for a classification tasks using Decision tree and Fully-connected neural network and moreover evaluate the performance of the proposed models."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a70c5553-ad01-4d43-93fb-50c085f09a64",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import math\n",
    "\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn.model_selection import train_test_split, StratifiedKFold, KFold\n",
    "from sklearn.metrics import accuracy_score, f1_score, recall_score, precision_score, confusion_matrix, auc\n",
    "from sklearn.preprocessing import OrdinalEncoder\n",
    "from sklearn.neural_network import MLPClassifier"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "948a2f23-7783-4218-b011-1690c65805c3",
   "metadata": {
    "tags": []
   },
   "source": [
    "#### Data Dictionary\n",
    "\n",
    "|Variable|Definition|Key|\n",
    "|:-------|:-------|:--------|\n",
    "|survival|Survival|0 = No, 1 = Yes|\n",
    "|pclass|Ticket class|1 = 1st, 2 = 2nd, 3 = 3rd|\n",
    "|sex|Sex||\n",
    "|Age|Age in years||\n",
    "|sibsp|# of siblings / spouses aboard the Titanic||\n",
    "|parch|# of parents / children aboard the Titanic||\n",
    "|ticket|Ticket number||\n",
    "|fare|Passenger fare||\n",
    "|cabin|Cabin number||\n",
    "|embarked|Port of Embarkation|C = Cherbourg, Q = Queenstown, S = Southampton|\n",
    "\n",
    "**pclass**: A proxy for socio-economic status (SES)\n",
    "1st = Upper\n",
    "2nd = Middle\n",
    "3rd = Lower\n",
    "\n",
    "**age**: Age is fractional if less than 1. If the age is estimated, is it in the form of xx.5\n",
    "\n",
    "**sibsp**: The dataset defines family relations in this way...\n",
    "Sibling = brother, sister, stepbrother, stepsister\n",
    "Spouse = husband, wife (mistresses and fiancés were ignored)\n",
    "\n",
    "**parch**: The dataset defines family relations in this way...\n",
    "Parent = mother, father\n",
    "Child = daughter, son, stepdaughter, stepson\n",
    "Some children travelled only with a nanny, therefore parch=0 for them."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bdd915f1-bf25-4b51-8f86-863cd5a891c4",
   "metadata": {},
   "source": [
    "- Decision tree https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html\n",
    "- Train test split https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html\n",
    "- Accuracy https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html\n",
    "- Metrics https://scikit-learn.org/stable/modules/model_evaluation.html\n",
    "- K-Fold CV https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.KFold.html#sklearn.model_selection.KFold\n",
    "- Neural network https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2d685ada-68b5-474a-84d5-5bfacd4a9eca",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Load the titanic.csv dataset\n",
    "- We want to create a model that predicts if a certain passanger survives or not, thus **survival** is the class label in this case"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b9043cd-4e41-40b0-93e1-712d94d122b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('titanic.csv', index_col=0)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03a3d400-65c8-4beb-bf62-5a524eb2eacf",
   "metadata": {},
   "source": [
    "## How many passangers survived?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "be1dfcb0-ac1c-4271-986a-fc5c017c760d",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.Survived.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f8e2c89-99da-455d-a856-ecb388c43d99",
   "metadata": {},
   "source": [
    "## We need to pre-process the data first\n",
    "- We want to use only numerical attributes as a model features\n",
    "- Certain attributes need to be dropped and some of them can be encoded\n",
    "\n",
    "### Which features would you drop and why?\n",
    "### Which features could be encoded and which methods would you use?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "07348831-2059-4df6-bd4b-3e8c7d7d23bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2ed1a75a-842a-4bb9-9d96-9f41e82faba9",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.describe(exclude=np.number)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "925eb694-ad0f-4c53-b524-c9f8ea3f7d39",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.describe(include=np.number)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1052ca31-34be-4775-b0d3-15c38e0b0593",
   "metadata": {},
   "source": [
    "## How many values are missing in the individual attributes?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aa840886-9c82-4fe5-8407-487a4de85ee5",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.apply(lambda x: x.isna().sum()).sort_values(ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14d2f054-6572-4aa5-a3b5-3c9a24ed11e7",
   "metadata": {},
   "source": [
    "## Let's drop Name and Ticket features - these have no use for us now"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8816c0bb-03c7-4b3b-be9b-af574c19728d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "63b1214c-278f-4fa6-8259-989ce7192b66",
   "metadata": {},
   "source": [
    "## Extract the deck identifier from the Cabin feature\n",
    "- Note: A = top deck, G = lowest deck\n",
    "- Change type to string\n",
    "- Filter the first letter using *apply* function\n",
    "- If the value is *nan* use *U* value as an replacement - this will mark the passangers with missing Cabin value\n",
    "- Replace the T value with A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "715f6d85-aee5-4649-ba4b-dbff92c97a8a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a06e72ef-5465-4660-9f2f-78d449e1ac48",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "074d8231-19b8-470d-a3a0-31efc63ad0fc",
   "metadata": {},
   "source": [
    "## The Age feature is tricky, we have multiple solutions for this, e.g.:\n",
    "- Drop the feature\n",
    "- Take the mean/median value to replace the missing value\n",
    "- Take a random list of ages that maintains the original statistical summary values.\n",
    "- Use a model to predict values based on the existing values.\n",
    "\n",
    "### We will use the second option"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0042d5ec-7134-4019-b5fb-82847b3e8818",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.boxplot(y=df.Age)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f5992687-87c1-476b-b674-0e4767e8f1e6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6cd2688-f10e-4cfe-a38f-16dd6f462170",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.boxplot(y=df.Age)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8d69cd4-dfe3-4e37-9997-8fe135fa12dc",
   "metadata": {},
   "source": [
    "## Two passangers don't have the Embarked filled - we can drop these two rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "efb68d26-598e-4e2d-b782-63b6c38a70e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5a377bb-ad92-4952-bff0-642e9f68efe7",
   "metadata": {},
   "outputs": [],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b71aa04-f392-4bbe-a2c3-9acd871665f5",
   "metadata": {
    "tags": []
   },
   "source": [
    "## The last step of the pre-processing pipeline is to encode Sex, Cabin and Embarked features\n",
    "- We will use one-hot encoding for Sex and Embarked and Ordinal encoding for Cabin\n",
    "- Specify the encoding scheme for the ordinal encoding using an array in a form ['first', 'second', 'third', ...]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "46e4dcea-3112-4988-ba71-90cd87c1248d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aec43f04-0b47-4ef5-8a63-b1e2c0a3f632",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "107cd80d-6c2c-4f8e-8e52-640314633c95",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b78e22af-b485-4721-b886-1b03eeca28bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c18869dd-aca4-4ba0-9cb4-81d8891ba249",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8a32c1d1-cd69-4f07-b9fa-62a075b57460",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e56cba21-7214-4cd2-acd6-e7507ffcba02",
   "metadata": {},
   "source": [
    "## Now we have the data ready"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f0d78f97-2c46-4c5a-8297-d1effbeaa5ab",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0affd869-d673-4af1-b523-eb27e36bba64",
   "metadata": {},
   "source": [
    "## Let's start with splitting the data into the input and output part\n",
    "- Usually named as a *X* and *y* variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5f021d0-28b1-4c2a-8e03-6070d3ace1c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "X, y = df.loc[:, df.columns != 'Survived'], df.loc[:, 'Survived']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c412ed1-20ff-47a8-9dfd-4f26a69cc624",
   "metadata": {},
   "outputs": [],
   "source": [
    "X.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8f4d44f9-ada3-4ed0-9b15-4c5c4d699b04",
   "metadata": {},
   "outputs": [],
   "source": [
    "y.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2c161813-24a7-46b5-9301-792c93810629",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Lets continue with train test split process.\n",
    "- Note that number of rows in the *X* and *y* in the Train/Test part of the data has to be equal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8c4621df-36a4-4097-bb2c-4c8325f3b882",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "08cdb399-d902-428c-9fbc-fe985a446b03",
   "metadata": {},
   "source": [
    "## Create the Decision tree classifier instance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90b94962-d1f7-4451-a460-4f88d4cfe95a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f0509a62-5a8e-4f21-b229-b10d6a30f865",
   "metadata": {},
   "source": [
    "### Use *fit()* method for training of classifier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8e2f2156-e441-4321-ba53-69f59c648980",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "36b97786-6284-43fe-9f48-e52370106d9d",
   "metadata": {},
   "source": [
    "### Lets use trained model for the prediction part\n",
    "- Get predictions via the method *predict()*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a48e30c4-95e9-4625-967e-587b5099de67",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "49e17f70-c136-4eb0-b362-f19a8b787eb3",
   "metadata": {
    "tags": []
   },
   "source": [
    "### Can we evaluate our model?\n",
    "- There are multiple metrics used: Accuracy, Recall, Precision, F1-Score, etc.\n",
    "- Very useful is also creating a confusion matrix\n",
    "\n",
    "### Take a look at this [article](https://builtin.com/data-science/precision-and-recall) and [wiki](https://en.wikipedia.org/wiki/Precision_and_recall) about precision and recall\n",
    "- Beware the fact that as we increase precision, we decrease recall and vice-versa.\n",
    "\n",
    "- **Precision** is the ratio of correctly predicted positive observations to the total predicted positive observations. The question that this metric answer is of all passengers that labeled as survived, how many actually survived? High precision relates to the low false positive rate.\n",
    "\n",
    "- **Recall** is the ratio of correctly predicted positive observations to the all observations in actual class - yes. The question recall answers is: Of all the passengers that truly survived, how many did we label?\n",
    "\n",
    "- **F1 Score** is the harmonic mean of Precision and Recall. Therefore, this score takes both false positives and false negatives into account. Intuitively it is not as easy to understand as accuracy, but F1 is usually more useful than accuracy, especially if you have an uneven class distribution. Accuracy works best if false positives and false negatives have similar cost. If the cost of false positives and false negatives are very different, it’s better to look at both Precision and Recall."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc664aac-8cdc-43fe-9d14-41ffae234647",
   "metadata": {},
   "source": [
    "$ConfMatrix = \\begin{bmatrix}\n",
    "TP & FN\\\\\n",
    "FP & TN\n",
    "\\end{bmatrix}$\n",
    "\n",
    "#### Let's try some example:\n",
    "$|1| = 10$\n",
    "\n",
    "$|0| = 90$\n",
    "\n",
    "$M = \\begin{bmatrix}\n",
    "1 & 9\\\\\n",
    "0 & 90\n",
    "\\end{bmatrix}$\n",
    "\n",
    "$Accuracy = \\frac{TP+TN}{TP+TN+FP+FN} = \\frac{1+90}{1+90+0+9} = \\frac{91}{100} = 0.91$\n",
    "\n",
    "$Precision = \\frac{TP}{TP+FP} = \\frac{1}{1+0} = 1$\n",
    "\n",
    "$Recall = \\frac{TP}{TP+FN} = \\frac{1}{1+9} = \\frac{1}{10} = 0.1$\n",
    "\n",
    "$F1-Score = 2 \\cdot \\frac{Precision \\cdot Recall}{Precision+Recall} = 2 \\cdot \\frac{1 \\cdot 0.1}{1+0.1} = 2 \\cdot \\frac{0.1}{1.1} = 0.09$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c25742d4-061b-4cae-b0a6-31d75f8ec956",
   "metadata": {},
   "outputs": [],
   "source": [
    "accuracy_score(y_test, y_pred)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef0763f5-4d79-4ca5-9770-ecaad6f71a5e",
   "metadata": {},
   "source": [
    "## What does the confusion matrix tell us?\n",
    "- Where do we find true positives, false positives etc?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "298e88ae-1977-4689-b19f-6a408c141d68",
   "metadata": {},
   "outputs": [],
   "source": [
    "sns.heatmap(confusion_matrix(y_test, y_pred), annot=True, cmap=\"Blues\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c6bcc55-8e10-40c8-a9a0-8e76e56f0037",
   "metadata": {},
   "outputs": [],
   "source": [
    "tn, fp, fn, tp = confusion_matrix(y_test, y_pred).ravel()\n",
    "tn, fp, fn, tp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f3c03ad3-fb5a-46a2-b45f-2b2ed0d22095",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c98c7af7-8630-4c0e-accc-d996841d0bfa",
   "metadata": {},
   "source": [
    "## Can we improve our evaluation process?\n",
    "- Lets try crossvalidation process for decision tree model\n",
    "- https://scikit-learn.org/stable/modules/cross_validation.html\n",
    "- **What is the difference between Pure and Stratified K-Fold?**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69807937-742d-4286-ac50-c93d535acdd6",
   "metadata": {},
   "outputs": [],
   "source": [
    "skf = KFold(n_splits=5)\n",
    "scores = list()\n",
    "for train_index, test_index in skf.split(X, y):\n",
    "    X_train, X_test = X.iloc[train_index, :], X.iloc[test_index, :]\n",
    "    y_train, y_test = y.iloc[train_index], y.iloc[test_index]\n",
    "    clf = DecisionTreeClassifier()\n",
    "    clf.fit(X_train, y_train)\n",
    "    y_pred = clf.predict(X_test)\n",
    "    scores.append(f1_score(y_test, y_pred))\n",
    "    print(f'Survival ratio in train set: {y_train.value_counts(normalize=True)[1]:.2}; Survival ratio in test set: {y_test.value_counts(normalize=True)[1]:.2}')\n",
    "scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f0d2d2bf-acad-4785-9f51-dc573f51f0e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "skf = StratifiedKFold(n_splits=5)\n",
    "scores = list()\n",
    "for train_index, test_index in skf.split(X, y):\n",
    "    X_train, X_test = X.iloc[train_index, :], X.iloc[test_index, :]\n",
    "    y_train, y_test = y.iloc[train_index], y.iloc[test_index]\n",
    "    clf = DecisionTreeClassifier()\n",
    "    clf.fit(X_train, y_train)\n",
    "    y_pred = clf.predict(X_test)\n",
    "    scores.append(f1_score(y_test, y_pred))\n",
    "    print(f'Survival ratio in train set: {y_train.value_counts(normalize=True)[1]:.2}; Survival ratio in test set: {y_test.value_counts(normalize=True)[1]:.2}')\n",
    "    \n",
    "scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "736808ff-d46a-49a4-9a1d-b0f5516b37c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.mean(scores), np.min(scores), np.max(scores)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c682878-0052-4cb8-a952-74e1e5cd3ae9",
   "metadata": {},
   "outputs": [],
   "source": [
    "skf = StratifiedKFold(n_splits=5, shuffle=True)\n",
    "scores = list()\n",
    "for train_index, test_index in skf.split(X, y):\n",
    "    X_train, X_test = X.iloc[train_index, :], X.iloc[test_index, :]\n",
    "    y_train, y_test = y.iloc[train_index], y.iloc[test_index]\n",
    "    clf = DecisionTreeClassifier()\n",
    "    clf.fit(X_train, y_train)\n",
    "    y_pred = clf.predict(X_test)\n",
    "    scores.append(f1_score(y_test, y_pred))\n",
    "    \n",
    "scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "30ac65a5-55fa-4cfa-a52a-f08bf4a8b73f",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.mean(scores), np.min(scores), np.max(scores)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc6be346-e4e6-4a84-8222-9cdfef19e738",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Let's try another algorithm - fully connected ANN\n",
    "- MLPClassifier - https://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPClassifier.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "481f63ef-803c-4d32-bc64-643b17d9a8c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "clf = MLPClassifier(hidden_layer_sizes=(5,3), activation='relu', solver='sgd', max_iter=1000, random_state=13)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "59b1eca0-d812-4394-980f-7fe895764a7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "skf = StratifiedKFold(n_splits=5, shuffle=True)\n",
    "scores = list()\n",
    "for train_index, test_index in skf.split(X, y):\n",
    "    X_train, X_test = X.iloc[train_index, :], X.iloc[test_index, :]\n",
    "    y_train, y_test = y.iloc[train_index], y.iloc[test_index]\n",
    "    clf = MLPClassifier(hidden_layer_sizes=(5,3), activation='relu', solver='adam', max_iter=1000, random_state=13)\n",
    "    clf.fit(X_train, y_train)\n",
    "    y_pred = clf.predict(X_test)\n",
    "    scores.append(f1_score(y_test, y_pred))\n",
    "    \n",
    "scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b22e8b5-d25d-44f1-a387-e97e31a87374",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.mean(scores), np.min(scores), np.max(scores)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a65dc8f-cb95-40d7-ba81-c779df06e77b",
   "metadata": {
    "tags": []
   },
   "source": [
    "# Task (2p)\n",
    "- Take a look at the parameers of the MLPClassifier\n",
    "- e.g. hidden_layer_sizes, activation, solver, max_iter\n",
    "- Tune the hyper-parameters and compare the ANN model proposed during the lecture and the one you just created (1p)\n",
    "    - **Write down to markdown cell which is better and why!**\n",
    "- Try to beat the DecisionTreeClassifier (1p)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
