Unterlagen

This commit is contained in:
git-sandro 2026-06-05 09:19:26 +02:00
parent 89a8543159
commit be3b063764
7 changed files with 1862 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,567 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7cff0901",
"metadata": {},
"source": [
"# Datenqualität — Musterlösung (Lego)\n",
"\n",
"**Modul M04 — Data Strategy, Quality & Tidy Data · `lego_daten_tidy.csv`** \n",
"Prof. Dr. Yves Staudt\n",
"\n",
"Wir beurteilen die **objektive** (messbare) und **subjektive** (zweckabhängige)\n",
"Datenqualität und prüfen, ob der Datensatz **tidy** ist."
]
},
{
"cell_type": "markdown",
"id": "ef13c590",
"metadata": {},
"source": [
"## Pakete & Daten"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "ca37b23b",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-03T21:52:04.296931Z",
"iopub.status.busy": "2026-06-03T21:52:04.296673Z",
"iopub.status.idle": "2026-06-03T21:52:04.789460Z",
"shell.execute_reply": "2026-06-03T21:52:04.789262Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(890, 47)\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>price</th>\n",
" <th>link_picture</th>\n",
" <th>Produkttyp</th>\n",
" <th>Vorgeschlagenes Geschlecht</th>\n",
" <th>Empfohlenes Alter in Jahren (mind.)</th>\n",
" <th>Empfohlenes Alter in Jahren (max.)</th>\n",
" <th>Anzahl Teile</th>\n",
" <th>Sound-Effekte</th>\n",
" <th>Produktfarbe</th>\n",
" <th>...</th>\n",
" <th>Anzahl Produkte pro Versandkarton</th>\n",
" <th>Hauptkarton GTIN (EAN/UPC)</th>\n",
" <th>Lagenanzahl pro Palette</th>\n",
" <th>Produkte pro Palettenlage</th>\n",
" <th>Fernbedienung erforderlich</th>\n",
" <th>Warnung vor Erstickungsgefahr</th>\n",
" <th>Fernbedienung enthalten</th>\n",
" <th>Akkus/Batterien enthalten</th>\n",
" <th>null</th>\n",
" <th>LegoCategory</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>LEGO Harry Potter Schloss Hogwarts™ mit Schlos...</td>\n",
" <td>179.00</td>\n",
" <td>https://www.fcw.ch/api/ProcessRequest/191538/B...</td>\n",
" <td>Bausatz</td>\n",
" <td>Junge/Mädchen</td>\n",
" <td>18.0</td>\n",
" <td>99.0</td>\n",
" <td>2660.0</td>\n",
" <td></td>\n",
" <td>Mehrfarbig</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>LEGO Harry Potter Schloss Hogwarts™ mit Schlos...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>LEGO Disney - Kamera Hommage an Walt Disney ...</td>\n",
" <td>119.00</td>\n",
" <td>https://www.fcw.ch/api/ProcessRequest/191541/B...</td>\n",
" <td>Bausatz</td>\n",
" <td>Junge/Mädchen</td>\n",
" <td>18.0</td>\n",
" <td>99.0</td>\n",
" <td>811.0</td>\n",
" <td></td>\n",
" <td>Mehrfarbig</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>LEGO Disney</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>LEGO Technic - Audi RS Q e-tron (42160)</td>\n",
" <td>159.00</td>\n",
" <td>https://www.fcw.ch/api/ProcessRequest/190646/B...</td>\n",
" <td>Bausatz</td>\n",
" <td>Junge/Mädchen</td>\n",
" <td>10.0</td>\n",
" <td>99.0</td>\n",
" <td>914.0</td>\n",
" <td></td>\n",
" <td>Mehrfarbig</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>LEGO Technic</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>LEGO Technic - Lamborghini Huracán Tecnica (42...</td>\n",
" <td>59.95</td>\n",
" <td>https://www.fcw.ch/api/ProcessRequest/190611/B...</td>\n",
" <td>Bausatz</td>\n",
" <td>Junge/Mädchen</td>\n",
" <td>9.0</td>\n",
" <td>99.0</td>\n",
" <td>806.0</td>\n",
" <td></td>\n",
" <td>Mehrfarbig</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>LEGO Technic</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>LEGO City - Personen-Schnellzug (60337)</td>\n",
" <td>169.00</td>\n",
" <td>https://www.fcw.ch/api/ProcessRequest/138905/B...</td>\n",
" <td>Bausatz</td>\n",
" <td>Junge/Mädchen</td>\n",
" <td>7.0</td>\n",
" <td>99.0</td>\n",
" <td>764.0</td>\n",
" <td></td>\n",
" <td>Mehrfarbig</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>LEGO City</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 47 columns</p>\n",
"</div>"
],
"text/plain": [
" name price \\\n",
"0 LEGO Harry Potter Schloss Hogwarts™ mit Schlos... 179.00 \n",
"1 LEGO Disney - Kamera Hommage an Walt Disney ... 119.00 \n",
"2 LEGO Technic - Audi RS Q e-tron (42160) 159.00 \n",
"3 LEGO Technic - Lamborghini Huracán Tecnica (42... 59.95 \n",
"4 LEGO City - Personen-Schnellzug (60337) 169.00 \n",
"\n",
" link_picture Produkttyp \\\n",
"0 https://www.fcw.ch/api/ProcessRequest/191538/B... Bausatz \n",
"1 https://www.fcw.ch/api/ProcessRequest/191541/B... Bausatz \n",
"2 https://www.fcw.ch/api/ProcessRequest/190646/B... Bausatz \n",
"3 https://www.fcw.ch/api/ProcessRequest/190611/B... Bausatz \n",
"4 https://www.fcw.ch/api/ProcessRequest/138905/B... Bausatz \n",
"\n",
" Vorgeschlagenes Geschlecht Empfohlenes Alter in Jahren (mind.) \\\n",
"0 Junge/Mädchen 18.0 \n",
"1 Junge/Mädchen 18.0 \n",
"2 Junge/Mädchen 10.0 \n",
"3 Junge/Mädchen 9.0 \n",
"4 Junge/Mädchen 7.0 \n",
"\n",
" Empfohlenes Alter in Jahren (max.) Anzahl Teile Sound-Effekte \\\n",
"0 99.0 2660.0 \n",
"1 99.0 811.0 \n",
"2 99.0 914.0 \n",
"3 99.0 806.0 \n",
"4 99.0 764.0 \n",
"\n",
" Produktfarbe ... Anzahl Produkte pro Versandkarton \\\n",
"0 Mehrfarbig ... NaN \n",
"1 Mehrfarbig ... NaN \n",
"2 Mehrfarbig ... NaN \n",
"3 Mehrfarbig ... NaN \n",
"4 Mehrfarbig ... NaN \n",
"\n",
" Hauptkarton GTIN (EAN/UPC) Lagenanzahl pro Palette \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"\n",
" Produkte pro Palettenlage Fernbedienung erforderlich \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"\n",
" Warnung vor Erstickungsgefahr Fernbedienung enthalten \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"\n",
" Akkus/Batterien enthalten null \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 NaN NaN \n",
"\n",
" LegoCategory \n",
"0 LEGO Harry Potter Schloss Hogwarts™ mit Schlos... \n",
"1 LEGO Disney \n",
"2 LEGO Technic \n",
"3 LEGO Technic \n",
"4 LEGO City \n",
"\n",
"[5 rows x 47 columns]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"df = pd.read_csv(\"../../../Data/lego/lego_daten_tidy.csv\")\n",
"print(df.shape)\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"id": "58a491c1",
"metadata": {},
"source": [
"## 1 Objektive Datenqualität\n",
"\n",
"Messbar und nutzerunabhängig: **Vollständigkeit**, **Konsistenz**, **Genauigkeit**."
]
},
{
"cell_type": "markdown",
"id": "bdd7106b",
"metadata": {},
"source": [
"### Vollständigkeit (fehlende Werte)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "dbd27974",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-03T21:52:04.790694Z",
"iopub.status.busy": "2026-06-03T21:52:04.790633Z",
"iopub.status.idle": "2026-06-03T21:52:04.793783Z",
"shell.execute_reply": "2026-06-03T21:52:04.793592Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Gesamtanteil fehlender Werte: 49.1 %\n",
"\n",
"Spalten mit den meisten Lücken:\n",
"Freigabedatum (TT/MM/JJ) 87.5\n",
"Warnung vor Erstickungsgefahr 87.3\n",
"Fernbedienung erforderlich 87.1\n",
"Fernbedienung enthalten 87.1\n",
"Anzahl der Versandkartons pro Vorlagenkarton 86.1\n",
"Anzahl der Pakete 85.5\n",
"EU TSD Sprache 85.2\n",
"null 84.6\n",
"Nettogewicht Hauptkarton 84.0\n",
"Figur enthalten 83.5\n",
"dtype: float64\n"
]
}
],
"source": [
"na = (df.isna().mean()*100).round(1)\n",
"print('Gesamtanteil fehlender Werte: %.1f %%' % (df.isna().mean().mean()*100))\n",
"print('\\nSpalten mit den meisten Lücken:')\n",
"print(na.sort_values(ascending=False).head(10))"
]
},
{
"cell_type": "markdown",
"id": "a750b3c3",
"metadata": {},
"source": [
"**Evaluation.** Viele Spalten haben hohe Fehlquoten (Versand-/Verpackungsangaben oft >80\\,%). Für eine Preisanalyse sind v.\\,a. `price`, `Anzahl Teile`, `Empfohlenes Alter` relevant — diese sind deutlich vollständiger."
]
},
{
"cell_type": "markdown",
"id": "290f7886",
"metadata": {},
"source": [
"### Konsistenz (Duplikate, konstante Spalten, Typen)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "049719ac",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-03T21:52:04.794890Z",
"iopub.status.busy": "2026-06-03T21:52:04.794813Z",
"iopub.status.idle": "2026-06-03T21:52:04.800139Z",
"shell.execute_reply": "2026-06-03T21:52:04.799954Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Doppelte Zeilen: 0\n",
"Konstante Spalten (kein Informationsgehalt): 12\n",
" ['Sound-Effekte', 'Material', 'Batterien erforderlich', 'Menge pro Packung', 'Montage erforderlich', 'Anzahl der Pakete', 'Figur enthalten', 'Fernbedienung erforderlich']\n",
"Datentypen:\n",
"object 36\n",
"float64 11\n",
"Name: count, dtype: int64\n"
]
}
],
"source": [
"dups = df.duplicated().sum()\n",
"const = [c for c in df.columns if df[c].nunique(dropna=True) <= 1]\n",
"print('Doppelte Zeilen:', int(dups))\n",
"print('Konstante Spalten (kein Informationsgehalt):', len(const))\n",
"print(' ', const[:8])\n",
"print('Datentypen:'); print(df.dtypes.value_counts())"
]
},
{
"cell_type": "markdown",
"id": "658c1011",
"metadata": {},
"source": [
"**Evaluation.** Es gibt **12 konstante** Spalten (inkl. einer Spalte `null`) — redundant/inkonsistent erhoben. Mehrere eigentlich numerische Grössen sind als Text (`object`) gespeichert — ein Konsistenzproblem für spätere Berechnungen."
]
},
{
"cell_type": "markdown",
"id": "5aa5a284",
"metadata": {},
"source": [
"### Genauigkeit (Plausibilität)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "735e79b3",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-03T21:52:04.801270Z",
"iopub.status.busy": "2026-06-03T21:52:04.801194Z",
"iopub.status.idle": "2026-06-03T21:52:04.803055Z",
"shell.execute_reply": "2026-06-03T21:52:04.802889Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"price: min=3.00 max=949.00 median=54.95\n",
"negative oder Null-Preise: 0\n"
]
}
],
"source": [
"print('price: min=%.2f max=%.2f median=%.2f' % (df['price'].min(), df['price'].max(), df['price'].median()))\n",
"print('negative oder Null-Preise:', int((df['price'] <= 0).sum()))"
]
},
{
"cell_type": "markdown",
"id": "8f1109f3",
"metadata": {},
"source": [
"**Evaluation.** Genauigkeit lässt sich ohne Referenz nur über Plausibilität prüfen: die Preise liegen im sinnvollen Bereich (keine negativen Werte), einzelne sehr hohe Werte (bis ~949) sind plausible Ausreisser (grosse Sets)."
]
},
{
"cell_type": "markdown",
"id": "dd6a6a4c",
"metadata": {},
"source": [
"## 2 Subjektive Datenqualität\n",
"\n",
"Hängt vom **Verwendungszweck** ab (Eignung, Relevanz, Vertrauenswürdigkeit).\n",
"\n",
"**Bewertung für den Zweck *Preisvorhersage von Lego-Sets*:**\n",
"- *Relevant* sind `price` (Ziel), `Anzahl Teile`, `Empfohlenes Alter`, `Produktfarbe`,\n",
" `Ursprungsland` — diese sind brauchbar.\n",
"- *Wenig brauchbar* sind die vielen lückenhaften Logistik-/Verpackungsspalten und die\n",
" konstanten Spalten — sie stiften für diesen Zweck keinen Mehrwert.\n",
"- *Vertrauenswürdigkeit:* mittel — die Kerngrössen wirken solide, aber die vielen\n",
" Lücken und Text-statt-Zahl-Felder erfordern Aufbereitung (→ M08/M11).\n",
"\n",
"Für einen *anderen* Zweck (z.\\,B. Logistikplanung) wären genau die jetzt verworfenen\n",
"Verpackungsspalten zentral — Datenqualität ist also **zweckrelativ**."
]
},
{
"cell_type": "markdown",
"id": "cb2d47fb",
"metadata": {},
"source": [
"## 3 Tidy Data\n",
"\n",
"**Tidy** (Wickham): (1) jede *Variable* eine Spalte, (2) jede *Beobachtung* eine Zeile,\n",
"(3) jede *Beobachtungseinheit* eine Tabelle."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "e29cedbb",
"metadata": {
"execution": {
"iopub.execute_input": "2026-06-03T21:52:04.804148Z",
"iopub.status.busy": "2026-06-03T21:52:04.804093Z",
"iopub.status.idle": "2026-06-03T21:52:04.805688Z",
"shell.execute_reply": "2026-06-03T21:52:04.805511Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Zeilen = Beobachtungen (Lego-Sets): 890\n",
"Eindeutige Produktnamen: 890\n",
"Spalten = Variablen: 47\n",
"Leere/Pseudo-Spalte vorhanden: True\n"
]
}
],
"source": [
"print('Zeilen = Beobachtungen (Lego-Sets):', len(df))\n",
"print('Eindeutige Produktnamen:', df['name'].nunique())\n",
"print('Spalten = Variablen:', df.shape[1])\n",
"print('Leere/Pseudo-Spalte vorhanden:', 'null' in df.columns)"
]
},
{
"cell_type": "markdown",
"id": "792c7f1b",
"metadata": {},
"source": [
"**Evaluation.** Der Datensatz ist **weitgehend tidy**: eine Zeile pro Lego-Set, eine Spalte pro Eigenschaft, eine Beobachtungseinheit (Produkte). **Verstösse:** die Spalte `null` ist keine echte Variable, einige numerische Grössen stehen als Text, und konstante Spalten tragen keine Variableninformation. Nach Bereinigung (konstante/`null` entfernen, Typen korrigieren) ist er sauber tidy."
]
},
{
"cell_type": "markdown",
"id": "25ca3d6b",
"metadata": {},
"source": [
"## Fazit\n",
"\n",
"Objektiv: hohe Vollständigkeit nur bei den Kernvariablen, einige Konsistenzmängel (konstante Spalten, Text-statt-Zahl). Subjektiv: für die Preisvorhersage gut nutzbar, für Logistik weniger. Struktur: weitgehend tidy mit kleinen, behebbaren Verstössen."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
unterlagen/leitfaden.pdf Normal file

Binary file not shown.