{ "cells": [ { "cell_type": "markdown", "source": [ "## 1. Pobranie zbioru" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 34, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: kaggle in ./venv/lib/python3.11/site-packages (1.6.6)\r\n", "Requirement already satisfied: six>=1.10 in ./venv/lib/python3.11/site-packages (from kaggle) (1.16.0)\r\n", "Requirement already satisfied: certifi in ./venv/lib/python3.11/site-packages (from kaggle) (2024.2.2)\r\n", "Requirement already satisfied: python-dateutil in ./venv/lib/python3.11/site-packages (from kaggle) (2.9.0.post0)\r\n", "Requirement already satisfied: requests in ./venv/lib/python3.11/site-packages (from kaggle) (2.31.0)\r\n", "Requirement already satisfied: tqdm in ./venv/lib/python3.11/site-packages (from kaggle) (4.66.2)\r\n", "Requirement already satisfied: python-slugify in ./venv/lib/python3.11/site-packages (from kaggle) (8.0.4)\r\n", "Requirement already satisfied: urllib3 in ./venv/lib/python3.11/site-packages (from kaggle) (2.2.1)\r\n", "Requirement already satisfied: bleach in ./venv/lib/python3.11/site-packages (from kaggle) (6.1.0)\r\n", "Requirement already satisfied: webencodings in ./venv/lib/python3.11/site-packages (from bleach->kaggle) (0.5.1)\r\n", "Requirement already satisfied: text-unidecode>=1.3 in ./venv/lib/python3.11/site-packages (from python-slugify->kaggle) (1.3)\r\n", "Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.11/site-packages (from requests->kaggle) (3.3.2)\r\n", "Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.11/site-packages (from requests->kaggle) (3.6)\r\n", "\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.0\u001B[0m\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n", "Requirement already satisfied: pandas in ./venv/lib/python3.11/site-packages (2.2.1)\r\n", "Requirement already satisfied: numpy<2,>=1.23.2 in ./venv/lib/python3.11/site-packages (from pandas) (1.26.4)\r\n", "Requirement already satisfied: python-dateutil>=2.8.2 in ./venv/lib/python3.11/site-packages (from pandas) (2.9.0.post0)\r\n", "Requirement already satisfied: pytz>=2020.1 in ./venv/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", "Requirement already satisfied: tzdata>=2022.7 in ./venv/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", "Requirement already satisfied: six>=1.5 in ./venv/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\r\n", "\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.0\u001B[0m\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n" ] } ], "source": [ "!pip install kaggle\n", "!pip install pandas" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:24.425690Z", "start_time": "2024-03-17T20:46:20.152437Z" } } }, { "cell_type": "code", "execution_count": 35, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "powerlifting-database.zip: Skipping, found more recently modified local copy (use --force to force download)\r\n" ] } ], "source": [ "!kaggle datasets download -d open-powerlifting/powerlifting-database" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:25.992367Z", "start_time": "2024-03-17T20:46:24.434212Z" } } }, { "cell_type": "code", "execution_count": 36, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Archive: powerlifting-database.zip\r\n", " inflating: openpowerlifting-2024-01-06-4c732975.csv \r\n", " inflating: openpowerlifting.csv \r\n" ] } ], "source": [ "!unzip -o powerlifting-database.zip" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:33.195703Z", "start_time": "2024-03-17T20:46:25.990819Z" } } }, { "cell_type": "code", "execution_count": 37, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: pandas in ./venv/lib/python3.11/site-packages (2.2.1)\r\n", "Requirement already satisfied: numpy<2,>=1.23.2 in ./venv/lib/python3.11/site-packages (from pandas) (1.26.4)\r\n", "Requirement already satisfied: python-dateutil>=2.8.2 in ./venv/lib/python3.11/site-packages (from pandas) (2.9.0.post0)\r\n", "Requirement already satisfied: pytz>=2020.1 in ./venv/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", "Requirement already satisfied: tzdata>=2022.7 in ./venv/lib/python3.11/site-packages (from pandas) (2024.1)\r\n", "Requirement already satisfied: six>=1.5 in ./venv/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\r\n", "\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.0\u001B[0m\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n", "Requirement already satisfied: seaborn in ./venv/lib/python3.11/site-packages (0.13.2)\r\n", "Requirement already satisfied: numpy!=1.24.0,>=1.20 in ./venv/lib/python3.11/site-packages (from seaborn) (1.26.4)\r\n", "Requirement already satisfied: pandas>=1.2 in ./venv/lib/python3.11/site-packages (from seaborn) (2.2.1)\r\n", "Requirement already satisfied: matplotlib!=3.6.1,>=3.4 in ./venv/lib/python3.11/site-packages (from seaborn) (3.8.3)\r\n", "Requirement already satisfied: contourpy>=1.0.1 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.2.0)\r\n", "Requirement already satisfied: cycler>=0.10 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (0.12.1)\r\n", "Requirement already satisfied: fonttools>=4.22.0 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (4.50.0)\r\n", "Requirement already satisfied: kiwisolver>=1.3.1 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.4.5)\r\n", "Requirement already satisfied: packaging>=20.0 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (24.0)\r\n", "Requirement already satisfied: pillow>=8 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (10.2.0)\r\n", "Requirement already satisfied: pyparsing>=2.3.1 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (3.1.2)\r\n", "Requirement already satisfied: python-dateutil>=2.7 in ./venv/lib/python3.11/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (2.9.0.post0)\r\n", "Requirement already satisfied: pytz>=2020.1 in ./venv/lib/python3.11/site-packages (from pandas>=1.2->seaborn) (2024.1)\r\n", "Requirement already satisfied: tzdata>=2022.7 in ./venv/lib/python3.11/site-packages (from pandas>=1.2->seaborn) (2024.1)\r\n", "Requirement already satisfied: six>=1.5 in ./venv/lib/python3.11/site-packages (from python-dateutil>=2.7->matplotlib!=3.6.1,>=3.4->seaborn) (1.16.0)\r\n", "\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.0\u001B[0m\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n" ] } ], "source": [ "!pip install pandas\n", "!pip install seaborn" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:37.684925Z", "start_time": "2024-03-17T20:46:33.204291Z" } } }, { "cell_type": "code", "execution_count": 62, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/var/folders/82/g0638vys2hs3rk916hlpkdrr0000gn/T/ipykernel_47077/3909872695.py:2: DtypeWarning: Columns (35) have mixed types. Specify dtype option on import or set low_memory=False.\n", " data = pd.read_csv('openpowerlifting.csv')\n" ] } ], "source": [ "import pandas as pd\n", "data = pd.read_csv('openpowerlifting.csv')" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T21:22:11.363229Z", "start_time": "2024-03-17T21:22:03.759530Z" } } }, { "cell_type": "markdown", "source": [ "## 2. Statystyki" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 39, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "RangeIndex: 1423354 entries, 0 to 1423353\n", "Data columns (total 37 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 Name 1423354 non-null object \n", " 1 Sex 1423354 non-null object \n", " 2 Event 1423354 non-null object \n", " 3 Equipment 1423354 non-null object \n", " 4 Age 757527 non-null float64\n", " 5 AgeClass 786800 non-null object \n", " 6 Division 1415176 non-null object \n", " 7 BodyweightKg 1406622 non-null float64\n", " 8 WeightClassKg 1410042 non-null object \n", " 9 Squat1Kg 337580 non-null float64\n", " 10 Squat2Kg 333349 non-null float64\n", " 11 Squat3Kg 323842 non-null float64\n", " 12 Squat4Kg 3696 non-null float64\n", " 13 Best3SquatKg 1031450 non-null float64\n", " 14 Bench1Kg 499779 non-null float64\n", " 15 Bench2Kg 493486 non-null float64\n", " 16 Bench3Kg 478485 non-null float64\n", " 17 Bench4Kg 9505 non-null float64\n", " 18 Best3BenchKg 1276181 non-null float64\n", " 19 Deadlift1Kg 363544 non-null float64\n", " 20 Deadlift2Kg 356023 non-null float64\n", " 21 Deadlift3Kg 339947 non-null float64\n", " 22 Deadlift4Kg 9246 non-null float64\n", " 23 Best3DeadliftKg 1081808 non-null float64\n", " 24 TotalKg 1313184 non-null float64\n", " 25 Place 1423354 non-null object \n", " 26 Wilks 1304407 non-null float64\n", " 27 McCulloch 1304254 non-null float64\n", " 28 Glossbrenner 1304407 non-null float64\n", " 29 IPFPoints 1273286 non-null float64\n", " 30 Tested 1093892 non-null object \n", " 31 Country 388884 non-null object \n", " 32 Federation 1423354 non-null object \n", " 33 Date 1423354 non-null object \n", " 34 MeetCountry 1423354 non-null object \n", " 35 MeetState 941545 non-null object \n", " 36 MeetName 1423354 non-null object \n", "dtypes: float64(22), object(15)\n", "memory usage: 401.8+ MB\n" ] } ], "source": [ "data.head()\n", "data.info()" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:45.574171Z", "start_time": "2024-03-17T20:46:44.513858Z" } } }, { "cell_type": "code", "execution_count": 40, "outputs": [ { "data": { "text/plain": "Sex\nM 1060189\nF 363165\nName: count, dtype: int64" }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data['Sex'].value_counts()" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:45.647881Z", "start_time": "2024-03-17T20:46:45.644775Z" } } }, { "cell_type": "code", "execution_count": 41, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Minimum: -477.5\n", "Maksimum: 575.0\n", "Odchylenie standardowe: 69.23931149707244\n", "Mediana: 167.83\n" ] }, { "data": { "text/plain": "Best3SquatKg\n200.00 15211\n136.08 12626\n190.00 12044\n160.00 12043\n170.00 11993\n ... \n277.30 1\n143.20 1\n129.60 1\n131.80 1\n309.58 1\nName: count, Length: 1907, dtype: int64" }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(f\"Minimum: {data['Best3SquatKg'].min()}\")\n", "print(f\"Maksimum: {data['Best3SquatKg'].max()}\")\n", "print(f\"Odchylenie standardowe: {data['Best3SquatKg'].std()}\")\n", "print(f\"Mediana: {data['Best3SquatKg'].median()}\")\n", "data['Best3SquatKg'].value_counts()" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T20:46:45.729691Z", "start_time": "2024-03-17T20:46:45.650117Z" } } }, { "cell_type": "markdown", "source": [ "## 3. Czyszczenie zbioru" ], "metadata": { "collapsed": false } }, { "cell_type": "markdown", "source": [ "Kolumna country w 73% przypadków jest pusta, dlatego ją usuwam. Podobnie z kolumnami Squat4kg, Bench4kg oraz Deadlift4kg" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 61, "outputs": [ { "data": { "text/plain": " Name Sex Event Equipment Age AgeClass \\\n63986 Kylie Beutler F SBD Wraps 23.0 20-23 \n66457 Kaitlynn Naert F SBD Wraps 13.0 13-15 \n67030 Carol Moorhead F SBD Wraps 55.0 55-59 \n67031 Nancy Lowther F SBD Wraps 58.0 55-59 \n69557 Roger Shaw M SBD Wraps 73.0 70-74 \n646493 Ryan Lapadat M SBD Raw 26.0 24-34 \n646495 Denis Pronin M SBD Multi-ply 20.0 20-23 \n652230 Brooke Zak F SBD Raw 12.5 13-15 \n658136 Brooke Zak F SBD Raw 12.0 5-12 \n658137 Brooke Zak F SBD Raw 12.0 5-12 \n658150 Frank Ferchland M SBD Raw 50.5 50-54 \n658151 Frank Ferchland M SBD Raw 50.5 50-54 \n658152 Frank Ferchland M SBD Raw 50.5 50-54 \n919233 Michael Trentin M SBD Multi-ply 18.0 18-19 \n\n Division BodyweightKg WeightClassKg Squat1Kg ... Wilks \\\n63986 Juniors 20-23 56.00 56 83.91 ... 338.90 \n66457 Teen 13-15 103.69 90+ 43.09 ... 205.66 \n67030 Open 74.39 75 79.38 ... 223.22 \n67031 Open 87.09 90 90.72 ... 260.41 \n69557 Masters 70-79 74.12 75 147.42 ... 311.23 \n646493 Open 81.70 82.5 142.50 ... 347.04 \n646495 Juniors 20-23 76.30 82.5 125.00 ... 313.37 \n652230 Teen 12-13 44.54 48 40.00 ... 223.45 \n658136 Teen 12-13 43.27 44 37.50 ... 234.91 \n658137 Open 43.27 44 37.50 ... 234.91 \n658150 Open 106.87 110 142.50 ... 286.58 \n658151 Law/Fire/Military 106.87 110 142.50 ... 286.58 \n658152 Masters 50-54 106.87 110 142.50 ... 286.58 \n919233 MO-MP 64.45 67.5 117.50 ... 298.34 \n\n McCulloch Glossbrenner IPFPoints Tested Federation Date \\\n63986 338.90 299.77 523.61 Yes WPA 2011-05-21 \n66457 263.24 175.84 359.25 Yes APA 2015-09-19 \n67030 273.44 196.41 374.65 Yes APA 2017-04-22 \n67031 336.19 227.02 449.73 Yes APA 2017-04-22 \n69557 546.53 301.14 443.10 Yes APA 2018-11-17 \n646493 347.04 335.10 505.60 Yes CPO 2008-05-17 \n646495 322.77 303.01 411.52 Yes CPO 2008-05-17 \n652230 286.01 200.16 303.20 Yes RAW 2018-11-09 \n658136 312.43 211.11 318.59 Yes RAW 2018-08-03 \n658137 312.43 211.11 318.59 Yes RAW 2018-08-03 \n658150 323.84 274.82 390.62 Yes RAW 2018-08-03 \n658151 323.84 274.82 390.62 Yes RAW 2018-08-03 \n658152 323.84 274.82 390.62 Yes RAW 2018-08-03 \n919233 316.24 289.83 394.62 Yes CAPO 2001-08-18 \n\n MeetCountry MeetState MeetName \n63986 USA CA World Championships \n66457 USA MI Wolverine Open \n67030 USA MO ShowMe State Raw Championships \n67031 USA MO ShowMe State Raw Championships \n69557 USA MO Midwest Raw Championships \n646493 Canada ON Canadian Championships \n646495 Canada ON Canadian Championships \n652230 USA NC OBX Open \n658136 USA NC Southern Open \n658137 USA NC Southern Open \n658150 USA NC Southern Open \n658151 USA NC Southern Open \n658152 USA NC Southern Open \n919233 Australia WA Nationals \n\n[14 rows x 36 columns]", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
NameSexEventEquipmentAgeAgeClassDivisionBodyweightKgWeightClassKgSquat1Kg...WilksMcCullochGlossbrennerIPFPointsTestedFederationDateMeetCountryMeetStateMeetName
63986Kylie BeutlerFSBDWraps23.020-23Juniors 20-2356.005683.91...338.90338.90299.77523.61YesWPA2011-05-21USACAWorld Championships
66457Kaitlynn NaertFSBDWraps13.013-15Teen 13-15103.6990+43.09...205.66263.24175.84359.25YesAPA2015-09-19USAMIWolverine Open
67030Carol MoorheadFSBDWraps55.055-59Open74.397579.38...223.22273.44196.41374.65YesAPA2017-04-22USAMOShowMe State Raw Championships
67031Nancy LowtherFSBDWraps58.055-59Open87.099090.72...260.41336.19227.02449.73YesAPA2017-04-22USAMOShowMe State Raw Championships
69557Roger ShawMSBDWraps73.070-74Masters 70-7974.1275147.42...311.23546.53301.14443.10YesAPA2018-11-17USAMOMidwest Raw Championships
646493Ryan LapadatMSBDRaw26.024-34Open81.7082.5142.50...347.04347.04335.10505.60YesCPO2008-05-17CanadaONCanadian Championships
646495Denis ProninMSBDMulti-ply20.020-23Juniors 20-2376.3082.5125.00...313.37322.77303.01411.52YesCPO2008-05-17CanadaONCanadian Championships
652230Brooke ZakFSBDRaw12.513-15Teen 12-1344.544840.00...223.45286.01200.16303.20YesRAW2018-11-09USANCOBX Open
658136Brooke ZakFSBDRaw12.05-12Teen 12-1343.274437.50...234.91312.43211.11318.59YesRAW2018-08-03USANCSouthern Open
658137Brooke ZakFSBDRaw12.05-12Open43.274437.50...234.91312.43211.11318.59YesRAW2018-08-03USANCSouthern Open
658150Frank FerchlandMSBDRaw50.550-54Open106.87110142.50...286.58323.84274.82390.62YesRAW2018-08-03USANCSouthern Open
658151Frank FerchlandMSBDRaw50.550-54Law/Fire/Military106.87110142.50...286.58323.84274.82390.62YesRAW2018-08-03USANCSouthern Open
658152Frank FerchlandMSBDRaw50.550-54Masters 50-54106.87110142.50...286.58323.84274.82390.62YesRAW2018-08-03USANCSouthern Open
919233Michael TrentinMSBDMulti-ply18.018-19MO-MP64.4567.5117.50...298.34316.24289.83394.62YesCAPO2001-08-18AustraliaWANationals
\n

14 rows × 36 columns

\n
" }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.drop(columns=['Country'])" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T21:21:57.260136Z", "start_time": "2024-03-17T21:21:57.252428Z" } } }, { "cell_type": "markdown", "source": [ "Wartości NaN zamieniam na 0." ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 63, "outputs": [], "source": [ "data.fillna(0, inplace=True)" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T21:22:23.496536Z", "start_time": "2024-03-17T21:22:20.502125Z" } } }, { "cell_type": "markdown", "source": [ "## 4. Podział zbioru na podzbiory\n", "Używam proporcji 8:1:1 (train:dev:test)" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 67, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting scikit-learn\r\n", " Downloading scikit_learn-1.4.1.post1-cp311-cp311-macosx_10_9_x86_64.whl (11.6 MB)\r\n", "\u001B[2K \u001B[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001B[0m \u001B[32m11.6/11.6 MB\u001B[0m \u001B[31m33.5 MB/s\u001B[0m eta \u001B[36m0:00:00\u001B[0m00:01\u001B[0m0:01\u001B[0m\r\n", "\u001B[?25hRequirement already satisfied: numpy<2.0,>=1.19.5 in ./venv/lib/python3.11/site-packages (from scikit-learn) (1.26.4)\r\n", "Collecting scipy>=1.6.0\r\n", " Downloading scipy-1.12.0-cp311-cp311-macosx_10_9_x86_64.whl (38.9 MB)\r\n", "\u001B[2K \u001B[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001B[0m \u001B[32m38.9/38.9 MB\u001B[0m \u001B[31m14.1 MB/s\u001B[0m eta \u001B[36m0:00:00\u001B[0m00:01\u001B[0m00:01\u001B[0m\r\n", "\u001B[?25hCollecting joblib>=1.2.0\r\n", " Using cached joblib-1.3.2-py3-none-any.whl (302 kB)\r\n", "Collecting threadpoolctl>=2.0.0\r\n", " Downloading threadpoolctl-3.3.0-py3-none-any.whl (17 kB)\r\n", "Installing collected packages: threadpoolctl, scipy, joblib, scikit-learn\r\n", "Successfully installed joblib-1.3.2 scikit-learn-1.4.1.post1 scipy-1.12.0 threadpoolctl-3.3.0\r\n", "\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.0\u001B[0m\r\n", "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\r\n" ] } ], "source": [ "!pip install scikit-learn" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T21:25:18.706896Z", "start_time": "2024-03-17T21:25:03.710247Z" } } }, { "cell_type": "code", "execution_count": 70, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", "openpowerlifting_train, openpowerlifting_test = train_test_split(data, test_size=0.1, random_state=1)\n", "openpowerlifting_train, openpowerlifting_dev = train_test_split(openpowerlifting_train, test_size=1/9, random_state=1)\n" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T21:34:45.563021Z", "start_time": "2024-03-17T21:34:41.224064Z" } } }, { "cell_type": "code", "execution_count": 72, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wielkość zbioru train: 1138682\n", "Wielkość zbioru dev: 142336\n", "Wielkość zbioru test: 142336\n" ] } ], "source": [ "print(\"Wielkość zbioru train: \", len(openpowerlifting_train))\n", "print(\"Wielkość zbioru dev: \", len(openpowerlifting_dev))\n", "print(\"Wielkość zbioru test: \", len(openpowerlifting_test))" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T21:35:31.899647Z", "start_time": "2024-03-17T21:35:31.894090Z" } } }, { "cell_type": "markdown", "source": [ "## 5. Normalizacja" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 83, "outputs": [ { "data": { "text/plain": " Name Sex Event Equipment Age AgeClass Division \\\n0 Abbie Murphy F SBD Wraps 0.661353 24-34 F-OR \n1 Abbie Tuong F SBD Wraps 0.661353 24-34 F-OR \n2 Ainslee Hooper F B Raw 1.255975 40-44 F-OR \n3 Amy Moldenhauer F SBD Wraps 0.337014 20-23 F-OR \n4 Andrea Rowan F SBD Wraps 1.526258 45-49 F-OR \n... ... .. ... ... ... ... ... \n1423349 Marian Cafalik M SBD Raw 2.364134 60-64 Masters 2 \n1423350 Marian Piwowarczyk M SBD Raw 2.093852 55-59 Masters 2 \n1423351 Andrzej Bryniarski M SBD Raw 2.472248 60-64 Masters 2 \n1423352 Stanisław Goroczko M SBD Raw 2.526304 60-64 Masters 2 \n1423353 Jan Sowa M SBD Raw 2.904700 70-74 Masters 2 \n\n BodyweightKg WeightClassKg Squat1Kg ... McCulloch Glossbrenner \\\n0 -0.944800 60 0.611664 ... 324.16 286.42 \n1 -0.997210 60 0.842750 ... 378.07 334.16 \n2 -1.122189 56 -0.312682 ... 38.56 34.12 \n3 -0.936736 60 -1.525886 ... 345.61 305.37 \n4 0.837161 110 1.073837 ... 338.91 274.56 \n... ... ... ... ... ... ... \n1423349 -0.392472 74 1.536010 ... 438.27 316.52 \n1423350 -0.795631 66 0.727207 ... 372.60 295.66 \n1423351 0.450129 105 1.304923 ... 382.36 264.22 \n1423352 -0.098167 83 -2.219146 ... 0.00 0.00 \n1423353 -0.049788 83 -1.641430 ... 0.00 0.00 \n\n IPFPoints Tested Country Federation Date MeetCountry \\\n0 511.15 0 0 GPC-AUS 2018-10-27 Australia \n1 595.65 0 0 GPC-AUS 2018-10-27 Australia \n2 313.97 0 0 GPC-AUS 2018-10-27 Australia \n3 547.04 0 0 GPC-AUS 2018-10-27 Australia \n4 550.08 0 0 GPC-AUS 2018-10-27 Australia \n... ... ... ... ... ... ... \n1423349 469.67 Yes 0 PZKFiTS 2017-04-01 Poland \n1423350 423.03 Yes Poland PZKFiTS 2017-04-01 Poland \n1423351 378.84 Yes 0 PZKFiTS 2017-04-01 Poland \n1423352 0.00 Yes 0 PZKFiTS 2017-04-01 Poland \n1423353 0.00 Yes 0 PZKFiTS 2017-04-01 Poland \n\n MeetState MeetName \n0 VIC Melbourne Cup \n1 VIC Melbourne Cup \n2 VIC Melbourne Cup \n3 VIC Melbourne Cup \n4 VIC Melbourne Cup \n... ... ... \n1423349 0 Polish Classic Powerlifting Cup \n1423350 0 Polish Classic Powerlifting Cup \n1423351 0 Polish Classic Powerlifting Cup \n1423352 0 Polish Classic Powerlifting Cup \n1423353 0 Polish Classic Powerlifting Cup \n\n[1423354 rows x 37 columns]", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
NameSexEventEquipmentAgeAgeClassDivisionBodyweightKgWeightClassKgSquat1Kg...McCullochGlossbrennerIPFPointsTestedCountryFederationDateMeetCountryMeetStateMeetName
0Abbie MurphyFSBDWraps0.66135324-34F-OR-0.944800600.611664...324.16286.42511.1500GPC-AUS2018-10-27AustraliaVICMelbourne Cup
1Abbie TuongFSBDWraps0.66135324-34F-OR-0.997210600.842750...378.07334.16595.6500GPC-AUS2018-10-27AustraliaVICMelbourne Cup
2Ainslee HooperFBRaw1.25597540-44F-OR-1.12218956-0.312682...38.5634.12313.9700GPC-AUS2018-10-27AustraliaVICMelbourne Cup
3Amy MoldenhauerFSBDWraps0.33701420-23F-OR-0.93673660-1.525886...345.61305.37547.0400GPC-AUS2018-10-27AustraliaVICMelbourne Cup
4Andrea RowanFSBDWraps1.52625845-49F-OR0.8371611101.073837...338.91274.56550.0800GPC-AUS2018-10-27AustraliaVICMelbourne Cup
..................................................................
1423349Marian CafalikMSBDRaw2.36413460-64Masters 2-0.392472741.536010...438.27316.52469.67Yes0PZKFiTS2017-04-01Poland0Polish Classic Powerlifting Cup
1423350Marian PiwowarczykMSBDRaw2.09385255-59Masters 2-0.795631660.727207...372.60295.66423.03YesPolandPZKFiTS2017-04-01Poland0Polish Classic Powerlifting Cup
1423351Andrzej BryniarskiMSBDRaw2.47224860-64Masters 20.4501291051.304923...382.36264.22378.84Yes0PZKFiTS2017-04-01Poland0Polish Classic Powerlifting Cup
1423352Stanisław GoroczkoMSBDRaw2.52630460-64Masters 2-0.09816783-2.219146...0.000.000.00Yes0PZKFiTS2017-04-01Poland0Polish Classic Powerlifting Cup
1423353Jan SowaMSBDRaw2.90470070-74Masters 2-0.04978883-1.641430...0.000.000.00Yes0PZKFiTS2017-04-01Poland0Polish Classic Powerlifting Cup
\n

1423354 rows × 37 columns

\n
" }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sklearn.preprocessing import StandardScaler\n", "\n", "scaled_features = data.copy()\n", "col_names = ['Age', 'BodyweightKg', 'Squat1Kg', 'Squat2Kg', 'Squat3Kg', 'Squat4Kg', 'Best3SquatKg', 'Bench1Kg', 'Bench2Kg', 'Bench3Kg', 'Bench4Kg', 'Best3BenchKg', 'Deadlift1Kg', 'Deadlift2Kg', 'Deadlift3Kg', 'Deadlift4Kg', 'Best3DeadliftKg', 'TotalKg']\n", "features = scaled_features[col_names]\n", "scaler = StandardScaler().fit(features.values)\n", "features = scaler.transform(features.values)\n", "scaled_features[col_names] = features\n", "scaled_features" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-03-17T23:21:17.202879Z", "start_time": "2024-03-17T23:21:12.896847Z" } } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }