03 part 1

This commit is contained in:
Michał Ulaniuk 2022-03-21 11:04:16 +01:00
parent 78eb1a9c1a
commit d43a29e1a7
2 changed files with 147 additions and 0 deletions

94
create_data.ipynb Normal file
View File

@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install kaggle\n",
"!pip install pandas\n",
"!pip install seaborn\n",
"!pip install torch"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 1 Pobranie zbioru\n",
"!kaggle datasets download -d joniarroba/noshowappointments"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!unzip -o noshowappointments.zip"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"no_shows=pd.read_csv('KaggleV2-May-2016.csv')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Wyczyszczenie zbioru\n",
"# Usunięcie negatywnego wieku\n",
"no_shows = no_shows.drop(no_shows[no_shows[\"Age\"] < 0].index)\n",
"\n",
"# Usunięcie niewiadomego wieku (zależy od zastosowania)\n",
"# no_shows = no_shows.drop(no_shows[no_shows[\"Age\"] == 0].index)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Normalizacja danych\n",
"\n",
"# Usunięcie kolumn PatientId oraz AppointmentID\n",
"no_shows.drop([\"PatientId\", \"AppointmentID\"], inplace=True, axis=1)\n",
"\n",
"# Zmiena wartości kolumny No-show z Yes/No na wartość boolowską\n",
"no_shows[\"No-show\"] = no_shows[\"No-show\"].map({'Yes': 1, 'No': 0})\n",
"\n",
"# Normalizacja kolumny Age\n",
"no_shows[\"Age\"]=(no_shows[\"Age\"]-no_shows[\"Age\"].min())/(no_shows[\"Age\"].max()-no_shows[\"Age\"].min())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Zapisanie wyników jako artefakt"
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

53
dataset_stats.ipynb Normal file
View File

@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Załadowanie artefaktu"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 3. Statystyki\n",
"# Wielkość zbioru i podzbiorów\n",
"print(f\"Wielkosc zbioru: {len(no_shows)}, podzbiór train: {train_size}, podzbiór test {test_size}.\")\n",
"# Opis parametrów\n",
"no_shows.describe(include='all')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Rozkład częstości dla klas\n",
"no_shows[\"No-show\"].value_counts().plot(kind=\"bar\", title=\"No-show\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Zapisanie statystyk jako artefakt"
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}