Skip to content

Instantly share code, notes, and snippets.

@qbeer
Created September 7, 2021 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qbeer/a7b26bcbc56a63f32097e52738f57a76 to your computer and use it in GitHub Desktop.
Save qbeer/a7b26bcbc56a63f32097e52738f57a76 to your computer and use it in GitHub Desktop.
HW1.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {
"language_info": {
"name": "plaintext"
},
"colab": {
"name": "HW1.ipynb",
"provenance": [],
"include_colab_link": true
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/qbeer/a7b26bcbc56a63f32097e52738f57a76/hw1.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FGRHaSq_eNml"
},
"source": [
"Exploratory data analysis<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#Exploratory-data-analysis\" class=\"anchor-link\">¶</a>\n",
"========================================================================================================================================================\n",
"\n",
"<http://patbaa.web.elte.hu/physdm/data/titanic.csv>\n",
"\n",
"On the link above you will find a dataset about the Titanic passengers.\n",
"Your task is to explore the dataset.\n",
"\n",
"Help for the columns:\n",
"\n",
"- SibSp - number of sibling/spouses on the ship\n",
"- Parch - number of parent/children on the ship\n",
"- Cabin - the cabin they slept in (if they had a cabin)\n",
"- Embarked - harbour of entering the ship\n",
"- Pclass - passenger class (like on trains)\n",
"\n",
"### 1. Load the above-linked csv file as a pandas dataframe. Check & plot if any of the columns has missing values. If they have, investigate if the missingness is random or not.<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#1.-Load-the-above-linked-csv-file-as-a-pandas-dataframe.-Check-&amp;-plot-if-any-of-the-columns-has-missing-values.-If-they-have,-investigate-if-the-missingness-is-random-or-not.\" class=\"anchor-link\">¶</a>\n",
"\n",
"Impute the missing values in a sensible way:\n",
"\n",
"- if only a very small percentage is missing, imputing with the\n",
" column-wise mean makes sense, or also removing the missing rows\n",
" makes sense\n",
"- if in a row almost all the entries is missing, it worth to remove\n",
" that given row\n",
"- if a larger portion is missing from a column, usually it worth to\n",
" encode that with a value that does not appear in the dataset (eg:\n",
" -1).\n",
"\n",
"The imputing method affects different machine learning models different\n",
"way, but now we are interested only in EDA, so try to keep as much\n",
"information as possible!\n",
"\n",
"### 2. Create a heatmap which shows how many people survived and dies with the different Pclass variables. You need to create a table where the columns indicates if a person survived or not, the rows indicates the different Pclass and the cell values contains the number of people belonging the that given category. The table should be colored based on the value of the cells in the table.<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#2.-Create-a-heatmap-which-shows-how-many-people-survived-and-dies-with-the-different-Pclass-variables.-You-need-to-create-a-table-where-the-columns-indicates-if-a-person-survived-or-not,-the-rows-indicates-the-different-Pclass-and-the-cell-values-contains-the-number-of-people-belonging-the-that-given-category.-The-table-should-be-colored-based-on-the-value-of-the-cells-in-the-table.\" class=\"anchor-link\">¶</a>\n",
"\n",
"### 3. Create boxplots for each different Pclass. The boxplot should show the age distribution for the given Pclass. Plot all of these next to each other in a row to make it easier to compare!<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#3.-Create-boxplots-for-each-different-Pclass.-The-boxplot-should-show-the-age-distribution-for-the-given-Pclass.-Plot-all-of-these-next-to-each-other-in-a-row-to-make-it-easier-to-compare!\" class=\"anchor-link\">¶</a>\n",
"\n",
"### 4. Calculate the correlation matrix for the numerical columns. Show it also as a heatmap described at the 1st task.<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#4.-Calculate-the-correlation-matrix-for-the-numerical-columns.-Show-it-also-as-a-heatmap-described-at-the-1st-task.\" class=\"anchor-link\">¶</a>\n",
"\n",
"Which feature seems to play the most important role in surviving/not\n",
"surviving? Explain how and why could that feature be important!\n",
"\n",
"### 5. Create two plots which you think are meaningful. Interpret both of them. (Eg.: older people buy more expensive ticket? people buying more expensive ticket survive more? etc.)<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#5.-Create-two-plots-which-you-think-are-meaningful.-Interpret-both-of-them.-(Eg.:-older-people-buy-more-expensive-ticket?-people-buying-more-expensive-ticket-survive-more?-etc.)\" class=\"anchor-link\">¶</a>\n",
"\n",
"### Hints:<a href=\"http://patbaa.web.elte.hu/physdm/code_examples/01_SOLVED_EDA.html#Hints:\" class=\"anchor-link\">¶</a>\n",
"\n",
"- On total you can get 10 points for fully completing all tasks.\n",
"- Decorate your notebook with, questions, explanation etc, make it\n",
" self contained and understandable!\n",
"- Comments you code when necessary\n",
"- Write functions for repetitive tasks!\n",
"- Use the pandas package for data loading and handling\n",
"- Use matplotlib and seaborn for plotting or bokeh and plotly for\n",
" interactive investigation\n",
"- Use the scikit learn package for almost everything\n",
"- Use for loops only if it is really necessary!\n",
"- Code sharing is not allowed between student! Sharing code will\n",
" result in zero points.\n",
"- If you use code found on web, it is OK, but, make its source clear!\n",
"\n"
],
"id": "FGRHaSq_eNml"
},
{
"cell_type": "code",
"metadata": {
"id": "O1i1FVjuebGp"
},
"source": [
""
],
"id": "O1i1FVjuebGp",
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment