Normalisierung und Erstellung von Train/Test

master
Ibrahim El Sayed 2021-07-13 17:51:08 +02:00
parent c5a2c85788
commit e79bab7e2c
8 changed files with 480 additions and 436 deletions

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "879144d9",
"id": "8301251c",
"metadata": {},
"source": [
"### Load MNIST dataset"
@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "bd032860",
"id": "3368e2c3",
"metadata": {},
"outputs": [],
"source": [
@ -23,7 +23,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "30da011c",
"id": "0dc2fe45",
"metadata": {},
"outputs": [],
"source": [
@ -35,7 +35,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "4f555050",
"id": "30459411",
"metadata": {},
"outputs": [],
"source": [
@ -46,7 +46,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "e4de4331",
"id": "0be717f8",
"metadata": {},
"outputs": [
{
@ -74,7 +74,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "b5221963",
"id": "ae9b3d51",
"metadata": {},
"outputs": [],
"source": [
@ -83,7 +83,7 @@
},
{
"cell_type": "markdown",
"id": "811db75a",
"id": "7c89b6d3",
"metadata": {},
"source": [
"### labels to int"
@ -92,7 +92,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "2bcc19ad",
"id": "30880538",
"metadata": {},
"outputs": [],
"source": [
@ -104,7 +104,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "cc4b728f",
"id": "34b6be41",
"metadata": {},
"outputs": [],
"source": [
@ -114,7 +114,7 @@
},
{
"cell_type": "markdown",
"id": "d7113df3",
"id": "361fea4c",
"metadata": {},
"source": [
"### Prepare data for machine learning"
@ -122,7 +122,7 @@
},
{
"cell_type": "markdown",
"id": "570f328e",
"id": "cab5977a",
"metadata": {},
"source": [
"### Identify Train Set and Test Set"
@ -131,7 +131,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "80e1ca03",
"id": "9bb80760",
"metadata": {},
"outputs": [
{
@ -158,7 +158,7 @@
},
{
"cell_type": "markdown",
"id": "ade8a1f6",
"id": "aac09882",
"metadata": {},
"source": [
"## Pipeline Declaration"
@ -167,7 +167,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "bc5896c2",
"id": "ca389b56",
"metadata": {},
"outputs": [],
"source": [
@ -195,7 +195,7 @@
},
{
"cell_type": "markdown",
"id": "9e905584",
"id": "b7c97601",
"metadata": {},
"source": [
"# Crossvalidation"
@ -204,7 +204,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "bbbb447c",
"id": "cd37833d",
"metadata": {},
"outputs": [],
"source": [
@ -222,7 +222,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "4a8240c4",
"id": "f738a4ca",
"metadata": {},
"outputs": [],
"source": [
@ -240,7 +240,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "f397cf42",
"id": "756c8015",
"metadata": {},
"outputs": [],
"source": [
@ -263,7 +263,7 @@
},
{
"cell_type": "markdown",
"id": "a543706f",
"id": "5d3b1484",
"metadata": {},
"source": [
"# Fitting"
@ -272,7 +272,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "45452ceb",
"id": "1ea6a154",
"metadata": {},
"outputs": [],
"source": [
@ -282,7 +282,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "03c01cd0",
"id": "ac4c7a18",
"metadata": {},
"outputs": [
{
@ -333,7 +333,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "18f02d0c",
"id": "23c51b9e",
"metadata": {},
"outputs": [
{
@ -385,7 +385,7 @@
{
"cell_type": "code",
"execution_count": 16,
"id": "b2e7ee09",
"id": "8c92a008",
"metadata": {},
"outputs": [
{
@ -437,7 +437,7 @@
{
"cell_type": "code",
"execution_count": 17,
"id": "23ae34c3",
"id": "811c3930",
"metadata": {},
"outputs": [
{
@ -490,7 +490,7 @@
{
"cell_type": "code",
"execution_count": 18,
"id": "cac23616",
"id": "3c7440ff",
"metadata": {},
"outputs": [
{
@ -543,7 +543,7 @@
{
"cell_type": "code",
"execution_count": 19,
"id": "a57eb660",
"id": "8b491b79",
"metadata": {},
"outputs": [
{
@ -596,7 +596,7 @@
{
"cell_type": "code",
"execution_count": 20,
"id": "bcbedf38",
"id": "080ea6b8",
"metadata": {},
"outputs": [
{
@ -649,7 +649,7 @@
{
"cell_type": "code",
"execution_count": 21,
"id": "5bc4f44b",
"id": "6ee320cd",
"metadata": {},
"outputs": [
{
@ -702,7 +702,7 @@
{
"cell_type": "code",
"execution_count": 22,
"id": "a901ad5d",
"id": "17934567",
"metadata": {},
"outputs": [
{
@ -755,7 +755,7 @@
{
"cell_type": "code",
"execution_count": 23,
"id": "19e87457",
"id": "88fb14a4",
"metadata": {},
"outputs": [
{
@ -816,7 +816,7 @@
{
"cell_type": "code",
"execution_count": 24,
"id": "6146ccb1",
"id": "378c092b",
"metadata": {},
"outputs": [
{
@ -877,7 +877,7 @@
{
"cell_type": "code",
"execution_count": 25,
"id": "66a7637b",
"id": "3005da1d",
"metadata": {},
"outputs": [
{
@ -930,7 +930,7 @@
{
"cell_type": "code",
"execution_count": 26,
"id": "d4fadaac",
"id": "cbf8e245",
"metadata": {},
"outputs": [
{
@ -983,7 +983,7 @@
{
"cell_type": "code",
"execution_count": 27,
"id": "d15fb11c",
"id": "cc1c7c77",
"metadata": {},
"outputs": [
{
@ -1035,7 +1035,7 @@
{
"cell_type": "code",
"execution_count": 28,
"id": "2db8577b",
"id": "562c937f",
"metadata": {},
"outputs": [
{
@ -1087,7 +1087,7 @@
{
"cell_type": "code",
"execution_count": 29,
"id": "a5702428",
"id": "0c661938",
"metadata": {},
"outputs": [],
"source": [
@ -1104,7 +1104,7 @@
{
"cell_type": "code",
"execution_count": 30,
"id": "0ee57cfe",
"id": "05b7b881",
"metadata": {},
"outputs": [],
"source": [
@ -1120,7 +1120,7 @@
},
{
"cell_type": "markdown",
"id": "7fbbc930",
"id": "0a37b9d8",
"metadata": {},
"source": [
"# Auswertung"
@ -1129,7 +1129,7 @@
{
"cell_type": "code",
"execution_count": 31,
"id": "e5d609aa",
"id": "480adf73",
"metadata": {},
"outputs": [
{
@ -1147,7 +1147,7 @@
{
"cell_type": "code",
"execution_count": 38,
"id": "234f14bb",
"id": "202ff9a7",
"metadata": {},
"outputs": [
{
@ -1179,7 +1179,7 @@
},
{
"cell_type": "markdown",
"id": "a6ddb6f2",
"id": "94f1af95",
"metadata": {},
"source": [
"Default n=3\\\n",
@ -1202,7 +1202,7 @@
},
{
"cell_type": "markdown",
"id": "bde6e847",
"id": "99ad8309",
"metadata": {},
"source": [
"n=3 euclid distance\\\n",
@ -1225,7 +1225,7 @@
},
{
"cell_type": "markdown",
"id": "4c625bc3",
"id": "497d3216",
"metadata": {},
"source": [
"# Hyper Parameter Optimization"
@ -1234,7 +1234,7 @@
{
"cell_type": "code",
"execution_count": 34,
"id": "24ff7ea2",
"id": "e5e0c930",
"metadata": {},
"outputs": [
{
@ -1269,7 +1269,7 @@
{
"cell_type": "code",
"execution_count": 36,
"id": "b3b0eac3",
"id": "41349c36",
"metadata": {},
"outputs": [],
"source": [
@ -1279,7 +1279,7 @@
{
"cell_type": "code",
"execution_count": 37,
"id": "b68589fe",
"id": "91d2f4bc",
"metadata": {},
"outputs": [],
"source": [
@ -1289,7 +1289,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b162e908",
"id": "c031b179",
"metadata": {},
"outputs": [],
"source": []
@ -1311,7 +1311,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "7a0c752a",
"id": "6904e7ae",
"metadata": {},
"source": [
"### Load MNIST dataset"
@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "e07d82fe",
"id": "e3d41c8f",
"metadata": {},
"outputs": [],
"source": [
@ -23,7 +23,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "1f97dcb1",
"id": "55990ccc",
"metadata": {},
"outputs": [],
"source": [
@ -35,7 +35,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "01f83832",
"id": "933f52fb",
"metadata": {},
"outputs": [],
"source": [
@ -46,7 +46,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "affa0e2b",
"id": "41435175",
"metadata": {},
"outputs": [
{
@ -73,7 +73,7 @@
},
{
"cell_type": "markdown",
"id": "4d51fd43",
"id": "fe14558d",
"metadata": {},
"source": [
"Bunch objects are sometimes used as an output for functions and methods. They extend dictionaries by enabling values to be accessed by key, bunch[\"value_key\"], or by an attribute, bunch.value_key.\\\n",
@ -83,7 +83,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "78be57ab",
"id": "80a39a2e",
"metadata": {},
"outputs": [
{
@ -106,7 +106,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "d0450c41",
"id": "5c211b9c",
"metadata": {},
"outputs": [
{
@ -127,7 +127,7 @@
},
{
"cell_type": "markdown",
"id": "e61e2adb",
"id": "a4c5fb8d",
"metadata": {},
"source": [
"Datasets loaded by Scikit-Learn generally have a similar dictionary structure, including the following:\\\n",
@ -139,7 +139,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "fe285433",
"id": "7c077427",
"metadata": {},
"outputs": [
{
@ -159,7 +159,7 @@
},
{
"cell_type": "markdown",
"id": "5a70a746",
"id": "f3f2e42a",
"metadata": {},
"source": [
"### Prepare the MNIST dataset"
@ -167,7 +167,7 @@
},
{
"cell_type": "markdown",
"id": "a9b7a120",
"id": "6d5d2658",
"metadata": {},
"source": [
"$f(X) = y$\n",
@ -181,7 +181,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "4e02cf2a",
"id": "99784cec",
"metadata": {},
"outputs": [],
"source": [
@ -191,7 +191,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "001d736f",
"id": "923676c7",
"metadata": {},
"outputs": [
{
@ -212,7 +212,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "b344be1d",
"id": "ed44fc7a",
"metadata": {},
"outputs": [
{
@ -233,7 +233,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "cef23e9f",
"id": "94ee3e59",
"metadata": {},
"outputs": [
{
@ -253,7 +253,7 @@
},
{
"cell_type": "markdown",
"id": "fe3b1259",
"id": "478cb336",
"metadata": {},
"source": [
"### Plot data"
@ -262,7 +262,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "953d9415",
"id": "f3cfebc6",
"metadata": {},
"outputs": [],
"source": [
@ -274,7 +274,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "b68f6cee",
"id": "6d799c25",
"metadata": {},
"outputs": [
{
@ -297,7 +297,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "8779b1a2",
"id": "72c7305b",
"metadata": {},
"outputs": [
{
@ -317,7 +317,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "dcc605cf",
"id": "f5b0b349",
"metadata": {},
"outputs": [
{
@ -343,7 +343,7 @@
{
"cell_type": "code",
"execution_count": 16,
"id": "6d41d752",
"id": "c70641f8",
"metadata": {},
"outputs": [
{
@ -364,7 +364,7 @@
{
"cell_type": "code",
"execution_count": 17,
"id": "230cfd35",
"id": "98f8561b",
"metadata": {},
"outputs": [],
"source": [
@ -375,7 +375,7 @@
{
"cell_type": "code",
"execution_count": 18,
"id": "25a3a2e7",
"id": "33e244b2",
"metadata": {},
"outputs": [],
"source": [
@ -389,7 +389,7 @@
{
"cell_type": "code",
"execution_count": 19,
"id": "f1552762",
"id": "20043b74",
"metadata": {},
"outputs": [
{
@ -413,7 +413,7 @@
{
"cell_type": "code",
"execution_count": 20,
"id": "74b3a063",
"id": "6e4369de",
"metadata": {},
"outputs": [],
"source": [
@ -429,7 +429,7 @@
{
"cell_type": "code",
"execution_count": 21,
"id": "949b3914",
"id": "fb3f6d95",
"metadata": {},
"outputs": [
{
@ -454,7 +454,7 @@
},
{
"cell_type": "markdown",
"id": "ec8a9d34",
"id": "3a69d0fd",
"metadata": {},
"source": [
"### Prepare data for machine learning"
@ -463,7 +463,7 @@
{
"cell_type": "code",
"execution_count": 22,
"id": "febbd286",
"id": "dcc31672",
"metadata": {},
"outputs": [
{
@ -485,7 +485,7 @@
{
"cell_type": "code",
"execution_count": 23,
"id": "fff839b6",
"id": "282ba914",
"metadata": {},
"outputs": [],
"source": [
@ -495,7 +495,7 @@
},
{
"cell_type": "markdown",
"id": "2bdbeb4e",
"id": "5c34bbd5",
"metadata": {},
"source": [
"### Train classifier"
@ -504,7 +504,7 @@
{
"cell_type": "code",
"execution_count": 24,
"id": "4c32ae9f",
"id": "f0b6e1c9",
"metadata": {},
"outputs": [],
"source": [
@ -515,7 +515,7 @@
{
"cell_type": "code",
"execution_count": 25,
"id": "fe06ae55",
"id": "54e3fb64",
"metadata": {},
"outputs": [
{
@ -540,7 +540,7 @@
{
"cell_type": "code",
"execution_count": 26,
"id": "e6209258",
"id": "29446c32",
"metadata": {},
"outputs": [
{
@ -565,7 +565,7 @@
{
"cell_type": "code",
"execution_count": 27,
"id": "62773b1b",
"id": "5030ccc3",
"metadata": {},
"outputs": [
{
@ -584,7 +584,7 @@
{
"cell_type": "code",
"execution_count": 28,
"id": "0ce21474",
"id": "22c780fb",
"metadata": {},
"outputs": [
{
@ -603,7 +603,7 @@
{
"cell_type": "code",
"execution_count": 29,
"id": "78a8e8a7",
"id": "990d3925",
"metadata": {},
"outputs": [
{
@ -626,7 +626,7 @@
{
"cell_type": "code",
"execution_count": 30,
"id": "45d93a99",
"id": "b6e1d70c",
"metadata": {},
"outputs": [
{
@ -647,7 +647,7 @@
},
{
"cell_type": "markdown",
"id": "fc739051",
"id": "a65ed630",
"metadata": {},
"source": [
"### Evaluation"
@ -656,7 +656,7 @@
{
"cell_type": "code",
"execution_count": 31,
"id": "990a5b7c",
"id": "4c93c5f9",
"metadata": {},
"outputs": [
{
@ -677,7 +677,7 @@
{
"cell_type": "code",
"execution_count": 32,
"id": "f125a37d",
"id": "f01ec3dd",
"metadata": {},
"outputs": [
{
@ -697,7 +697,7 @@
},
{
"cell_type": "markdown",
"id": "bdcb6e6e",
"id": "c41db6b0",
"metadata": {},
"source": [
"Accuracy is strongly influenced by the distribution of the classes in the test data."
@ -705,7 +705,7 @@
},
{
"cell_type": "markdown",
"id": "be858cd5",
"id": "3f830f36",
"metadata": {},
"source": [
"#### Cross Validation\n",
@ -715,7 +715,7 @@
{
"cell_type": "code",
"execution_count": 33,
"id": "7adb1ea7",
"id": "eeec5311",
"metadata": {},
"outputs": [
{
@ -736,7 +736,7 @@
{
"cell_type": "code",
"execution_count": 34,
"id": "11d22c5e",
"id": "d1ed46a3",
"metadata": {},
"outputs": [
{
@ -759,7 +759,7 @@
},
{
"cell_type": "markdown",
"id": "b54e83a5",
"id": "539cfa0c",
"metadata": {},
"source": [
"#### Precision"
@ -768,7 +768,7 @@
{
"cell_type": "code",
"execution_count": 35,
"id": "ef7a9e7e",
"id": "abfe8383",
"metadata": {},
"outputs": [
{
@ -790,7 +790,7 @@
},
{
"cell_type": "markdown",
"id": "da723740",
"id": "d899dd6f",
"metadata": {},
"source": [
"#### Recall"
@ -799,7 +799,7 @@
{
"cell_type": "code",
"execution_count": 36,
"id": "cb77bf58",
"id": "15d30ae5",
"metadata": {},
"outputs": [
{
@ -821,7 +821,7 @@
},
{
"cell_type": "markdown",
"id": "28867d1b",
"id": "393c3b1c",
"metadata": {},
"source": [
"#### F1 Score"
@ -830,7 +830,7 @@
{
"cell_type": "code",
"execution_count": 37,
"id": "0674e0de",
"id": "53fa1823",
"metadata": {},
"outputs": [
{
@ -852,7 +852,7 @@
},
{
"cell_type": "markdown",
"id": "da59da11",
"id": "08b6bdc2",
"metadata": {},
"source": [
"#### Confusion Matrix"
@ -861,7 +861,7 @@
{
"cell_type": "code",
"execution_count": 38,
"id": "adbdeece",
"id": "e205d359",
"metadata": {},
"outputs": [
{
@ -891,7 +891,7 @@
{
"cell_type": "code",
"execution_count": 39,
"id": "fb50c5a4",
"id": "4ec777ac",
"metadata": {},
"outputs": [
{
@ -929,7 +929,7 @@
{
"cell_type": "code",
"execution_count": 40,
"id": "2f0d536a",
"id": "9c53a0a7",
"metadata": {},
"outputs": [],
"source": [
@ -940,7 +940,7 @@
{
"cell_type": "code",
"execution_count": 41,
"id": "dddf5fe8",
"id": "c47e7c69",
"metadata": {},
"outputs": [
{
@ -970,7 +970,7 @@
{
"cell_type": "code",
"execution_count": 42,
"id": "44537aae",
"id": "ef09fc40",
"metadata": {},
"outputs": [
{
@ -1006,7 +1006,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "57d96f56",
"id": "6f9816f1",
"metadata": {},
"outputs": [],
"source": []
@ -1028,7 +1028,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

View File

@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "bfe7a783",
"id": "9f0ddabb",
"metadata": {},
"outputs": [],
"source": [
@ -16,7 +16,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "c6c356ef",
"id": "1e8e6ffb",
"metadata": {},
"outputs": [],
"source": [
@ -32,7 +32,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "69ae3c7a",
"id": "39cf526d",
"metadata": {},
"outputs": [],
"source": [
@ -48,7 +48,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "e28642ea",
"id": "2b169e1f",
"metadata": {},
"outputs": [],
"source": [
@ -67,7 +67,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "6ec561b1",
"id": "9a507393",
"metadata": {},
"outputs": [],
"source": [
@ -89,7 +89,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "e975b7b9",
"id": "8d8da08e",
"metadata": {},
"outputs": [
{
@ -121,7 +121,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "7b7f497c",
"id": "700db412",
"metadata": {},
"outputs": [
{
@ -147,7 +147,7 @@
},
{
"cell_type": "markdown",
"id": "55f47334",
"id": "16cdb8f5",
"metadata": {},
"source": [
"**How to fix this error**:\n",
@ -160,7 +160,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "7f9bb477",
"id": "1f411bea",
"metadata": {},
"outputs": [
{
@ -647,7 +647,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "5d10cf20",
"id": "1a8beb73",
"metadata": {},
"outputs": [],
"source": [
@ -675,7 +675,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "0e97563e",
"id": "0dcd7db2",
"metadata": {},
"outputs": [
{
@ -703,7 +703,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "2676a564",
"id": "3a0e96ac",
"metadata": {},
"outputs": [],
"source": [
@ -714,7 +714,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "a26a60ff",
"id": "d2d8e64d",
"metadata": {},
"outputs": [],
"source": [
@ -724,7 +724,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "39f3ef0e",
"id": "77c502cd",
"metadata": {},
"outputs": [],
"source": [
@ -753,7 +753,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "1fa16a8f",
"id": "7235d56c",
"metadata": {},
"outputs": [],
"source": [
@ -769,7 +769,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "eee9d775",
"id": "cc983f80",
"metadata": {},
"outputs": [
{
@ -809,7 +809,7 @@
{
"cell_type": "code",
"execution_count": 16,
"id": "27ae5c5a",
"id": "59d6ebca",
"metadata": {},
"outputs": [
{
@ -874,7 +874,7 @@
{
"cell_type": "code",
"execution_count": 17,
"id": "d2b3422e",
"id": "f4032731",
"metadata": {},
"outputs": [
{
@ -946,7 +946,7 @@
{
"cell_type": "code",
"execution_count": 18,
"id": "453149ff",
"id": "e20cb3cd",
"metadata": {},
"outputs": [
{
@ -989,7 +989,7 @@
{
"cell_type": "code",
"execution_count": 19,
"id": "dbf863e2",
"id": "5f88c9c6",
"metadata": {},
"outputs": [],
"source": [
@ -1013,7 +1013,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

View File

@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "9706d045",
"id": "024b33fe",
"metadata": {},
"outputs": [],
"source": [
@ -15,7 +15,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "77388c0f",
"id": "72397786",
"metadata": {},
"outputs": [],
"source": [
@ -37,7 +37,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "0fd516ff",
"id": "5f67ba6c",
"metadata": {},
"outputs": [],
"source": [
@ -56,7 +56,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "389e84c0",
"id": "805421f9",
"metadata": {},
"outputs": [],
"source": [
@ -67,7 +67,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "197a57c5",
"id": "a6a00ee3",
"metadata": {},
"outputs": [],
"source": [
@ -78,7 +78,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "e456ab87",
"id": "877573a2",
"metadata": {},
"outputs": [],
"source": [
@ -117,7 +117,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cc789523",
"id": "93303e1e",
"metadata": {},
"outputs": [],
"source": []
@ -125,7 +125,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "c59a84aa",
"id": "5eb3f0c1",
"metadata": {},
"outputs": [],
"source": [
@ -141,7 +141,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "0c0a4649",
"id": "26bcaaad",
"metadata": {},
"outputs": [],
"source": [
@ -196,7 +196,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "5a618dd4",
"id": "32584756",
"metadata": {},
"outputs": [],
"source": [
@ -212,7 +212,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "52e5cc13",
"id": "e7056b09",
"metadata": {},
"outputs": [],
"source": [
@ -229,7 +229,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "62463866",
"id": "fad8741d",
"metadata": {},
"outputs": [],
"source": [
@ -241,7 +241,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "57ec862e",
"id": "96abe0b6",
"metadata": {},
"outputs": [],
"source": [
@ -295,7 +295,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "cc2a6529",
"id": "2ec14876",
"metadata": {},
"outputs": [],
"source": [
@ -306,7 +306,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "66975d62",
"id": "93d7b7e8",
"metadata": {},
"outputs": [
{
@ -338,7 +338,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "cc664cf6",
"id": "bdd09b3a",
"metadata": {},
"outputs": [
{
@ -360,7 +360,7 @@
{
"cell_type": "code",
"execution_count": 18,
"id": "d8463d51",
"id": "b4b048c3",
"metadata": {},
"outputs": [
{
@ -384,7 +384,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bbb07d9b",
"id": "d06cbda8",
"metadata": {},
"outputs": [],
"source": []
@ -406,7 +406,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

View File

@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "43a8508f",
"id": "3168ef63",
"metadata": {},
"outputs": [],
"source": [
@ -35,7 +35,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "650ab8d8",
"id": "ce4d9517",
"metadata": {},
"outputs": [],
"source": [
@ -54,7 +54,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "7e5bbbe7",
"id": "5ed60433",
"metadata": {},
"outputs": [],
"source": [
@ -77,7 +77,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "e2c35751",
"id": "9fefd9fa",
"metadata": {},
"outputs": [],
"source": [
@ -135,7 +135,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "6a0e84e0",
"id": "b6c30ab7",
"metadata": {},
"outputs": [],
"source": [
@ -155,7 +155,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "8a76bd49",
"id": "20cb0504",
"metadata": {},
"outputs": [],
"source": [
@ -211,7 +211,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "95dbd528",
"id": "ec39550d",
"metadata": {},
"outputs": [],
"source": [
@ -230,7 +230,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "f68432e1",
"id": "63509028",
"metadata": {},
"outputs": [],
"source": [
@ -240,7 +240,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "48d57ee7",
"id": "f8dbeac5",
"metadata": {},
"outputs": [],
"source": [
@ -250,7 +250,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "c8cf46a6",
"id": "b479a77c",
"metadata": {},
"outputs": [
{
@ -268,7 +268,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "016a11f0",
"id": "3c7919a6",
"metadata": {},
"outputs": [],
"source": [
@ -278,7 +278,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "77b0373e",
"id": "9592e2ca",
"metadata": {},
"outputs": [
{
@ -296,7 +296,7 @@
{
"cell_type": "code",
"execution_count": 19,
"id": "d9f3bf08",
"id": "7f294d3c",
"metadata": {},
"outputs": [
{
@ -321,7 +321,7 @@
{
"cell_type": "code",
"execution_count": 20,
"id": "25729dda",
"id": "fda2e601",
"metadata": {},
"outputs": [
{
@ -61840,7 +61840,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "303c0850",
"id": "d1125102",
"metadata": {},
"outputs": [],
"source": []
@ -61862,7 +61862,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

View File

@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "30758151",
"id": "7528c5d7",
"metadata": {},
"outputs": [],
"source": [
@ -19,7 +19,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "1365458a",
"id": "5aa0ab63",
"metadata": {},
"outputs": [
{
@ -94,7 +94,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "cef98b83",
"id": "c0453d68",
"metadata": {},
"outputs": [],
"source": [
@ -106,7 +106,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "86f1c9b4",
"id": "685f2966",
"metadata": {},
"outputs": [],
"source": [
@ -146,7 +146,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "ab518f47",
"id": "57b2847d",
"metadata": {},
"outputs": [
{
@ -192,7 +192,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a0c1292b",
"id": "5784fe87",
"metadata": {},
"outputs": [],
"source": []
@ -214,7 +214,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

View File

@ -3,13 +3,22 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "38f12435",
"id": "2288179b",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 768/768 [01:11<00:00, 10.72it/s]\n"
]
}
],
"source": [
"import os\n",
"from glob import glob\n",
"import pandas as pd\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.pipeline import Pipeline\n",
"from sklearn.decomposition import PCA, KernelPCA\n",
"from sklearn.preprocessing import (StandardScaler, \n",
@ -17,6 +26,7 @@
" MaxAbsScaler,\n",
" PowerTransformer,\n",
" Binarizer)\n",
"\n",
"from sklearn.neighbors import KNeighborsClassifier\n",
"from sklearn.model_selection import cross_validate\n",
"from sklearn.metrics import classification_report, accuracy_score\n",
@ -33,7 +43,7 @@
"def load_data(user_filter=None):\n",
" dic_data = []\n",
" \n",
" for p in glob('/opt/iui-datarelease3-sose2021/*.csv'):\n",
" for p in tqdm(glob('/opt/iui-datarelease3-sose2021/*.csv')):\n",
" path = p\n",
" filename = path.split('/')[-1]\n",
" user = int(filename.split('_')[0][1:])\n",
@ -44,6 +54,9 @@
" heightnorm = filename.split('_')[2][len('HeightNormalization'):] == 'True'\n",
" armnorm = filename.split('_')[3][len('ArmNormalization'):] == 'True'\n",
" rep = int(filename.split('.')[0].split('_')[4][len('Repetition'):])\n",
" session = filename.split('_')[5][len('Session'):]\n",
" session = session.split('.')[0]\n",
" \n",
" data = pd.read_csv(path)\n",
" dic_data.append(\n",
" {\n",
@ -53,7 +66,9 @@
" 'heightnorm': heightnorm,\n",
" 'armnorm': armnorm,\n",
" 'rep': rep,\n",
" 'session': session,\n",
" 'data': data \n",
" \n",
" }\n",
" )\n",
" return dic_data\n",
@ -64,7 +79,22 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "fa4a164f",
"id": "3df066af",
"metadata": {},
"outputs": [],
"source": [
"\n",
"# dataP = pd.DataFrame.from_dict(fil_dic_data) #pandas Dataframe Form mit 'data0' nur die daten\n",
"\n",
"# tempP = dataP['data']\n",
"\n",
"# tempP = tempP[0].drop(columns=['Scenario','HeightNormalization','ArmNormalization','LeftHandTrackingAccuracy','RightHandTrackingAccuracy']) #P without String Data\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "30296cad",
"metadata": {},
"outputs": [],
"source": [
@ -76,284 +106,150 @@
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "bded63ab",
"cell_type": "markdown",
"id": "7a808f50",
"metadata": {},
"outputs": [],
"source": [
"# print(fil_dic_data)"
"Test\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "bff8a597",
"id": "dc206ded",
"metadata": {},
"outputs": [],
"source": [
"min_Max = MinMaxScaler()\n",
"standard = StandardScaler()\n",
"max_Abs = MaxAbsScaler()\n",
"binarizer = Binarizer()\n",
"\n"
"binarizer = Binarizer()\n"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "cbd99d06",
"execution_count": 5,
"id": "cf5b5695",
"metadata": {},
"outputs": [],
"source": [
"# print(fil_dic_data)\n",
" # didnt work \n",
"strData = []\n",
"floatData = []\n",
"intData = []\n",
"session_data_1 = []\n",
"session_data_2 = []\n",
"\n",
"dataP = pd.DataFrame.from_dict(fil_dic_data) #pandas Dataframe Form mit 'data0' nur die daten\n",
"user_data_1 = []\n",
"user_data_2 = []\n",
"\n",
"#print (dataP['data'][0])\n",
"data_1 = []\n",
"data_2 = []\n",
"\n",
"for a in fil_dic_data:\n",
" if(a['session'] == '1'): ## Daten aus session 1 für train\n",
" session_data_1.append(a)\n",
" \n",
" if(a['session'] == '2'): ## Daten aus Session 2 zum validaten\n",
" session_data_2.append(a)\n",
"\n",
"tempP = dataP['data']\n",
"for b in session_data_1:\n",
" user_data_1.append(b['user']) ## Label zu 1 \n",
" data_1.append(a['data'])\n",
" \n",
" # print (tempP)\n",
"\n",
"tempP = tempP[0].drop(columns=['Scenario','HeightNormalization','ArmNormalization','LeftHandTrackingAccuracy','RightHandTrackingAccuracy']) #P without String Data\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"# for a in range (0,len(dataPp)):\n",
"# if(dataPp.str.contains('True|False|High|Low')==False ):\n",
"# # dataPp = dataPp.drop(DataPp[a])\n",
"# print ('hello')\n"
"for c in session_data_2:\n",
" user_data_2.append(b['user']) ## Label zu 2\n",
" data_2.append(a['data'])\n",
" \n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "234f6afe",
"metadata": {},
"outputs": [],
"source": [
"min_Max = MinMaxScaler()\n",
"standard = StandardScaler()\n",
"max_Abs = MaxAbsScaler()\n",
"binarizer = Binarizer()\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "04ae81d2",
"execution_count": 6,
"id": "82465bca",
"metadata": {},
"outputs": [
{
"name": "stdout",
"name": "stderr",
"output_type": "stream",
"text": [
"1277\n",
" Unnamed: 0 FrameID participantID Repetition CenterEyeAnchor_pos_X \\\n",
"0 0 0 4 1 0.075814 \n",
"1 1 1 4 1 0.075603 \n",
"2 2 2 4 1 0.075464 \n",
"3 3 3 4 1 0.074985 \n",
"4 4 4 4 1 0.074755 \n",
"... ... ... ... ... ... \n",
"1272 1272 1272 4 1 0.059269 \n",
"1273 1273 1273 4 1 0.058998 \n",
"1274 1274 1274 4 1 0.058876 \n",
"1275 1275 1275 4 1 0.058837 \n",
"1276 1276 1276 4 1 0.058719 \n",
"\n",
" CenterEyeAnchor_pos_Y CenterEyeAnchor_pos_Z CenterEyeAnchor_euler_X \\\n",
"0 1.597426 0.214518 32.14411 \n",
"1 1.596940 0.213788 32.33485 \n",
"2 1.596355 0.213466 32.50544 \n",
"3 1.595917 0.213272 32.65988 \n",
"4 1.595896 0.212891 32.82001 \n",
"... ... ... ... \n",
"1272 1.562853 0.780597 43.60785 \n",
"1273 1.562540 0.780967 43.66858 \n",
"1274 1.562446 0.781218 43.70253 \n",
"1275 1.562278 0.781637 43.72837 \n",
"1276 1.562163 0.781915 43.73775 \n",
"\n",
" CenterEyeAnchor_euler_Y CenterEyeAnchor_euler_Z ... \\\n",
"0 17.57221 355.132000 ... \n",
"1 18.04424 355.151400 ... \n",
"2 18.46541 355.162400 ... \n",
"3 18.85156 355.278000 ... \n",
"4 19.17233 355.326500 ... \n",
"... ... ... ... \n",
"1272 338.90930 6.801289 ... \n",
"1273 338.83770 6.831078 ... \n",
"1274 338.73530 6.853129 ... \n",
"1275 338.65100 6.852663 ... \n",
"1276 338.56400 6.874183 ... \n",
"\n",
" right_Hand_RingTip_euler_X right_Hand_RingTip_euler_Y \\\n",
"0 324.1219 65.17896 \n",
"1 324.1279 65.55900 \n",
"2 323.9291 67.21324 \n",
"3 323.7837 68.33554 \n",
"4 323.6655 69.47017 \n",
"... ... ... \n",
"1272 297.6745 24.27903 \n",
"1273 297.7101 23.77864 \n",
"1274 297.5444 23.05743 \n",
"1275 297.4029 22.36072 \n",
"1276 297.2895 21.69823 \n",
"\n",
" right_Hand_RingTip_euler_Z right_Hand_PinkyTip_pos_X \\\n",
"0 104.17820 0.171209 \n",
"1 107.53830 0.158228 \n",
"2 115.07650 0.156692 \n",
"3 118.63020 0.155604 \n",
"4 122.65200 0.154516 \n",
"... ... ... \n",
"1272 32.62823 0.135538 \n",
"1273 33.12482 0.135347 \n",
"1274 33.56173 0.135177 \n",
"1275 33.99821 0.135037 \n",
"1276 34.43113 0.134919 \n",
"\n",
" right_Hand_PinkyTip_pos_Y right_Hand_PinkyTip_pos_Z \\\n",
"0 1.233351 0.453072 \n",
"1 1.254817 0.449175 \n",
"2 1.242653 0.457048 \n",
"3 1.236654 0.459492 \n",
"4 1.229719 0.461844 \n",
"... ... ... \n",
"1272 1.105558 1.126205 \n",
"1273 1.104719 1.126016 \n",
"1274 1.103936 1.125776 \n",
"1275 1.103254 1.125685 \n",
"1276 1.102556 1.125620 \n",
"\n",
" right_Hand_PinkyTip_euler_X right_Hand_PinkyTip_euler_Y \\\n",
"0 336.9985 58.71567 \n",
"1 337.3785 58.82201 \n",
"2 338.5847 57.22202 \n",
"3 339.3581 55.64667 \n",
"4 339.9531 54.21407 \n",
"... ... ... \n",
"1272 309.9038 24.25421 \n",
"1273 309.9819 23.98718 \n",
"1274 309.9340 23.53447 \n",
"1275 309.9002 23.10301 \n",
"1276 309.8771 22.69119 \n",
"\n",
" right_Hand_PinkyTip_euler_Z Session \n",
"0 89.64570 2 \n",
"1 98.59170 2 \n",
"2 114.27260 2 \n",
"3 121.56910 2 \n",
"4 129.46830 2 \n",
"... ... ... \n",
"1272 27.30666 2 \n",
"1273 28.01053 2 \n",
"1274 28.82001 2 \n",
"1275 29.60149 2 \n",
"1276 30.31748 2 \n",
"\n",
"[1277 rows x 341 columns]\n"
"100%|██████████| 96/96 [00:00<00:00, 575.65it/s]\n",
"100%|██████████| 96/96 [00:00<00:00, 646.85it/s]\n"
]
}
],
"source": [
"print(len(tempP))\n",
"print(tempP)"
"dataF_1 = [] ## Filtered Data session 1\n",
"dataF_2 = [] ## Filtered Data session 2\n",
"\n",
"temp_1 = [] ## Temp Holder für 1\n",
"temp_2 = [] ## Temp Holder für 2\n",
"\n",
"counter = 0 ## Counter für Einspeisen der Daten\n",
"\n",
"\n",
"for a in data_1:\n",
" temp_1.append(pd.DataFrame(a))\n",
"\n",
"for b in data_2:\n",
" temp_2.append(pd.DataFrame(b))\n",
"\n",
"\n",
"for c in tqdm(temp_1):\n",
" dataF_1.append(c.drop(columns=['Scenario','HeightNormalization','ArmNormalization','LeftHandTrackingAccuracy','RightHandTrackingAccuracy','Unnamed: 0', 'FrameID','participantID','Repetition']))\n",
" counter +=1\n",
" \n",
"counter = 0\n",
"\n",
"for d in tqdm(temp_2):\n",
" dataF_2.append(c.drop(columns=['Scenario','HeightNormalization','ArmNormalization','LeftHandTrackingAccuracy','RightHandTrackingAccuracy','Unnamed: 0', 'FrameID','participantID','Repetition']))\n",
" counter +=1\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "ed8fadf5",
"metadata": {},
"outputs": [],
"source": [
"data_min_M = min_Max.fit(tempP)\n",
"data_min_MT = min_Max.fit_transform(tempP)\n",
"\n",
"data_stan = standard.fit(tempP)\n",
"data_stanT = standard.fit_transform(tempP)\n",
"\n",
"data_max_A = max_Abs.fit(tempP)\n",
"data_max_AT = max_Abs.fit_transform(tempP)\n",
"\n",
"data_bin = binarizer.fit(tempP)\n",
"data_binT = binarizer.fit_transform(tempP)"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "d65387c4",
"execution_count": 7,
"id": "a6f7076e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"name": "stderr",
"output_type": "stream",
"text": [
"MinMaxScaler()\n",
"[[0.00000000e+00 0.00000000e+00 0.00000000e+00 ... 1.62054079e-01\n",
" 3.38612629e-01 0.00000000e+00]\n",
" [7.83699060e-04 7.83699060e-04 0.00000000e+00 ... 1.62350807e-01\n",
" 3.79761585e-01 0.00000000e+00]\n",
" [1.56739812e-03 1.56739812e-03 0.00000000e+00 ... 1.57886238e-01\n",
" 4.51889092e-01 0.00000000e+00]\n",
" ...\n",
" [9.98432602e-01 9.98432602e-01 0.00000000e+00 ... 6.38853882e-02\n",
" 5.88324285e-02 0.00000000e+00]\n",
" [9.99216301e-01 9.99216301e-01 0.00000000e+00 ... 6.26814536e-02\n",
" 6.24270056e-02 0.00000000e+00]\n",
" [1.00000000e+00 1.00000000e+00 0.00000000e+00 ... 6.15323220e-02\n",
" 6.57203480e-02 0.00000000e+00]]\n"
"100%|██████████| 96/96 [00:03<00:00, 25.87it/s]\n"
]
}
],
"source": [
"print(data_min_M)\n",
"print(data_min_MT)"
"minD = [] ## normalisierte Daten durch Minmax\n",
"staD = [] ## normalisierte Daten durch Standard\n",
"maxD = [] ## normalisierte Daten durch MaxAbs\n",
"binD = [] ## normalisierte Daten durch binarizer\n",
"\n",
"for i in tqdm(dataF_1):\n",
" minD.append( min_Max.fit_transform(i))\n",
" staD.append(standard.fit_transform(i))\n",
" maxD.append(max_Abs.fit_transform(i))\n",
" binD.append(binarizer.fit_transform(i))\n"
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "c63c4d67",
"execution_count": 8,
"id": "94676652",
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split\n"
"from sklearn.model_selection import train_test_split\n",
"x_train,x_test,y_train,y_test = train_test_split(minD,user_data_1,random_state=2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4cad7f04",
"cell_type": "markdown",
"id": "14a4abe1",
"metadata": {},
"outputs": [],
"source": []
"source": [
"Classi"
]
}
],
"metadata": {
@ -372,7 +268,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.10"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long