[email protected] commited on
Commit
9926092
·
1 Parent(s): e447c36

Revised pie chart. Added content (ufc definition, extraction date, snippets of preliminary extracted and cached data, workflow and definition

Browse files
README.md CHANGED
@@ -2,20 +2,57 @@
2
 
3
  A web scraping project that extracts fight and fighter data from [ufcstats.com](http://ufcstats.com), transforms it into structured wide-format tables, and enriches it with historical performance statistics.
4
 
 
 
5
  ## Project Overview
6
 
7
  This tool performs the following:
8
 
9
- - Scrapes data from `ufcstats.com` including:
10
  - Fighter profiles (name, height, reach, stance, etc.)
11
  - Fight outcomes and statistics (strikes, takedowns, control time, etc.)
12
  - Event information (event title, date, winner)
13
- - Transforms the raw data into a clean wide-format table:
14
  - Each row represents **one fight**
15
  - Contains data for **both fighters** in separate columns
16
  - Computes **cumulative performance metrics** for each fighter across fights to enable longitudinal analysis
17
-
18
- ## Output Example
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  Below is a simplified example of what the dataset looks like. Each row represents one fight and includes data for both fighters.
21
 
@@ -28,11 +65,11 @@ Below is a simplified example of what the dataset looks like. Each row represent
28
  - Fighter stats: height, reach, weight, age, stance, striking/takedown accuracy & defense
29
  - Fight stats: control time, knockdowns, strike breakdown (head/body/leg, distance/clinch/ground)
30
  - Derived metrics: cumulative win %, strike absorption rate, etc.
31
- - The uploaded dataset includes only the first 200 rows. The full dataset and processing scripts are not shared to respect the intellectual property of the source website.
32
 
33
  The full schema includes both raw data and calculated performance metrics to support deep analysis or model training.
34
 
35
- ## Quick Statistics
36
 
37
  ![Summary Statistics](assets/summary_statistics.jpg)
38
 
@@ -51,6 +88,7 @@ The full schema includes both raw data and calculated performance metrics to sup
51
 
52
  ![Fighters with the Most Wins](assets/top_fighters_win_pct.jpg)
53
 
 
54
  ## Sample Analysis
55
 
56
  ![Fighter's Historical Performance Statistics](assets/sample_fighter_historical_performance.jpg)
 
2
 
3
  A web scraping project that extracts fight and fighter data from [ufcstats.com](http://ufcstats.com), transforms it into structured wide-format tables, and enriches it with historical performance statistics.
4
 
5
+ The UFC (Ultimate Fighting Championship) is a premier mixed martial arts (MMA) promotion showcasing elite-level fighters across multiple weight classes.
6
+
7
  ## Project Overview
8
 
9
  This tool performs the following:
10
 
11
+ - Scrapes **all available** data from `ufcstats.com` including:
12
  - Fighter profiles (name, height, reach, stance, etc.)
13
  - Fight outcomes and statistics (strikes, takedowns, control time, etc.)
14
  - Event information (event title, date, winner)
15
+ - Transforms the raw data into a clean wide-format table, where:
16
  - Each row represents **one fight**
17
  - Contains data for **both fighters** in separate columns
18
  - Computes **cumulative performance metrics** for each fighter across fights to enable longitudinal analysis
19
+ - Converts units from U.S. customary to metric system (e.g., inches to centimeters, pounds to kilograms) to support European-format data handling
20
+
21
+ Note: The original dataset does not include cumulative or historical statistics for each fighter prior to a given fight (e.g., total significant strikes, takedowns, or submission attempts). To enable performance analysis, these metrics are calculated separately based on each fighter’s fight history up to that point. However, to keep the dataset compact, these intermediate cumulative values are not stored in the final output—only the derived pre-fight performance metrics are retained.
22
+ Data was last extracted on March 10, 2025.
23
+
24
+ ## Libraries Used
25
+ - Data Consolidation: argparse, json, os, re
26
+ - Web Scraping: BeautifulSoup, requests, time
27
+ - Data Analysis & Transformation: pandas, numpy, math
28
+
29
+ ## Workflow
30
+ 1. Scrape web data from [ufcstats.com] using custom scripts.
31
+ 2. Cache all raw HTML and JSON files locally for reproducibility and offline access
32
+ 3. Transform scraped data into structured format:
33
+ - Flatten nested data
34
+ - Convert units (from U.S. customary to EU metric system)
35
+ 4. Compute the following historical performance statistics by calculating cumulative strikes, takedowns, opponent's strikes and defence, etc per fighter before each fight.
36
+ - Significant Strikes Absorbed per Minute (SApM)
37
+ - Average Takedowns Landed per 15 Minutes (TD Avg.)
38
+ - Significant Strikes Landed per Minute (SLpM)
39
+ - Average Submissions Landed per 15 Minutes (Sub. Avg.)
40
+ - Significant Striking Accuracy (Str. Acc.)
41
+ - Takedown Accuracy (TD Acc.)
42
+ - Takedown Defense (TD Def.)
43
+ - Significant Strike Defense (Str. Def.)
44
+
45
+ ## Sample of Preliminary Extracts Cached to JSON
46
+ 1. 📄 [sample_fight_urls.json](./sample_fight_urls.json)
47
+ ![All Available Fight Urls](assets/sample_fight_urls.jpg)
48
+
49
+ 2. 📄 [sample_constant_info.json](./sample_constant_info.json)
50
+ ![Fighter Basic Information](assets/sample_constant_info.jpg)
51
+
52
+ 3. 📄 [sample_Aalon_Cruz_vs_Spike_Carlyle_0bcb04163f8d8ead.json](./sample_Aalon_Cruz_vs_Spike_Carlyle_0bcb04163f8d8ead.json)
53
+ ![Fight Statistics](assets/sample_fight_info.jpg)
54
+
55
+ ## Sample of Final Output
56
 
57
  Below is a simplified example of what the dataset looks like. Each row represents one fight and includes data for both fighters.
58
 
 
65
  - Fighter stats: height, reach, weight, age, stance, striking/takedown accuracy & defense
66
  - Fight stats: control time, knockdowns, strike breakdown (head/body/leg, distance/clinch/ground)
67
  - Derived metrics: cumulative win %, strike absorption rate, etc.
68
+ - The uploaded dataset (**ufc_fights_data_first_200**) includes only the first 200 rows. The full dataset and processing scripts are not shared to respect the intellectual property of the source website.
69
 
70
  The full schema includes both raw data and calculated performance metrics to support deep analysis or model training.
71
 
72
+ ## Quick Statistics of the Extracted Data
73
 
74
  ![Summary Statistics](assets/summary_statistics.jpg)
75
 
 
88
 
89
  ![Fighters with the Most Wins](assets/top_fighters_win_pct.jpg)
90
 
91
+
92
  ## Sample Analysis
93
 
94
  ![Fighter's Historical Performance Statistics](assets/sample_fighter_historical_performance.jpg)
assets/sample_constant_info.jpg ADDED

Git LFS Details

  • SHA256: c1f61bdbdee474b8151696cfad0645d0ba7def6084d37c0dffe0f7188dcd8b6b
  • Pointer size: 130 Bytes
  • Size of remote file: 38.4 kB
assets/sample_fight_info.jpg ADDED

Git LFS Details

  • SHA256: 59dff4365bc345601b94a4645e706bcbcd1f3ff3b2eef116b1bb7af8435696a8
  • Pointer size: 130 Bytes
  • Size of remote file: 76.4 kB
assets/sample_fight_urls.jpg ADDED

Git LFS Details

  • SHA256: 654bc5699e80f1e7f5442d6d107e43db24e7a3a8cd0280f37101597b2452491c
  • Pointer size: 131 Bytes
  • Size of remote file: 177 kB
assets/win_method_distribution.jpg CHANGED

Git LFS Details

  • SHA256: e7e79bf86ee53961da2eaa5b1961d39ef5c0da8941cf07aca56f4c560ab09050
  • Pointer size: 130 Bytes
  • Size of remote file: 19.4 kB

Git LFS Details

  • SHA256: 133451efe71299d3e64ff20f82ea10a818f1dc7ba4562987e7f74fbdf4a72130
  • Pointer size: 130 Bytes
  • Size of remote file: 39.6 kB
sample_Aalon_Cruz_vs_Spike_Carlyle_0bcb04163f8d8ead.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "http://ufcstats.com/fight-details/0bcb04163f8d8ead": {
3
+ "name": "UFC Fight Night: Benavidez vs. Figueiredo",
4
+ "winner": "Spike Carlyle",
5
+ "weight_class": "Featherweight Bout",
6
+ "winning_method": "KO/TKO",
7
+ "total_rounds": "1",
8
+ "total_seconds": 85,
9
+ "date": "2020-02-29"
10
+ },
11
+ "http://ufcstats.com/fighter-details/003d82fa384ca1d0": {
12
+ "name": "Aalon Cruz",
13
+ "knockdown": 0,
14
+ "landed_significant_strikes": 2,
15
+ "total_significant_strikes": 12,
16
+ "success_takedown": 0,
17
+ "total_attempted_takedown": 1,
18
+ "submission_attempt": 0,
19
+ "control_time_in_seconds": 5,
20
+ "significant_strikes_breakdown": {
21
+ "head": 2,
22
+ "head_total": 4,
23
+ "body": 0,
24
+ "body_total": 4,
25
+ "leg": 0,
26
+ "leg_total": 4,
27
+ "distance": 2,
28
+ "distance_total": 12,
29
+ "clinch": 0,
30
+ "clinch_total": 0,
31
+ "ground": 0,
32
+ "ground_total": 0
33
+ }
34
+ },
35
+ "http://ufcstats.com/fighter-details/be68b375707dcb85": {
36
+ "name": "Spike Carlyle",
37
+ "knockdown": 0,
38
+ "landed_significant_strikes": 20,
39
+ "total_significant_strikes": 29,
40
+ "success_takedown": 0,
41
+ "total_attempted_takedown": 0,
42
+ "submission_attempt": 0,
43
+ "control_time_in_seconds": 7,
44
+ "significant_strikes_breakdown": {
45
+ "head": 19,
46
+ "head_total": 27,
47
+ "body": 0,
48
+ "body_total": 1,
49
+ "leg": 1,
50
+ "leg_total": 1,
51
+ "distance": 2,
52
+ "distance_total": 6,
53
+ "clinch": 4,
54
+ "clinch_total": 5,
55
+ "ground": 14,
56
+ "ground_total": 18
57
+ }
58
+ }
59
+ }
sample_constant_info.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "http://ufcstats.com/fighter-details/93fe7332d16c6ad9": {
3
+ "name": "Tom Aaron",
4
+ "nickname": "",
5
+ "height_cm": null,
6
+ "weight_lbs": 155.0,
7
+ "reach_cm": null,
8
+ "stance": "",
9
+ "birthdate": "1978-07-13"
10
+ },
11
+ "http://ufcstats.com/fighter-details/15df64c02b6b0fde": {
12
+ "name": "Danny Abbadi",
13
+ "nickname": "The Assassin",
14
+ "height_cm": 180.34,
15
+ "weight_lbs": 155.0,
16
+ "reach_cm": null,
17
+ "stance": "Orthodox",
18
+ "birthdate": "1983-07-03"
19
+ },
20
+ "http://ufcstats.com/fighter-details/59a9d6dac61c2540": {
21
+ "name": "Nariman Abbasov",
22
+ "nickname": "Bayraktar",
23
+ "height_cm": 172.72,
24
+ "weight_lbs": 155.0,
25
+ "reach_cm": 167.64000000000001,
26
+ "stance": "Orthodox",
27
+ "birthdate": "1994-02-01"
28
+ },
29
+ "http://ufcstats.com/fighter-details/b361180739bed4b0": {
30
+ "name": "David Abbott",
31
+ "nickname": "Tank",
32
+ "height_cm": 182.88,
33
+ "weight_lbs": 265.0,
34
+ "reach_cm": null,
35
+ "stance": "Switch",
36
+ "birthdate": "--"
37
+ },
38
+ "http://ufcstats.com/fighter-details/3329d692aea4dc28": {
39
+ "name": "Hamdy Abdelwahab",
40
+ "nickname": "The Hammer",
41
+ "height_cm": 187.96,
42
+ "weight_lbs": 264.0,
43
+ "reach_cm": 182.88,
44
+ "stance": "Southpaw",
45
+ "birthdate": "1993-01-22"
46
+ },
47
+ "http://ufcstats.com/fighter-details/841695e02c99a521": {
48
+ "name": "Mansur Abdul-Malik",
49
+ "nickname": "",
50
+ "height_cm": 187.96,
51
+ "weight_lbs": 185.0,
52
+ "reach_cm": 200.66,
53
+ "stance": "Orthodox",
54
+ "birthdate": "1997-10-07"
55
+ },
56
+ "http://ufcstats.com/fighter-details/2f5cbecbbe18bac4": {
57
+ "name": "Shamil Abdurakhimov",
58
+ "nickname": "Abrek",
59
+ "height_cm": 190.5,
60
+ "weight_lbs": 235.0,
61
+ "reach_cm": 193.04,
62
+ "stance": "Orthodox",
63
+ "birthdate": "1981-09-02"
64
+ },
65
+ "http://ufcstats.com/fighter-details/c0ed7b208197e8de": {
66
+ "name": "Hiroyuki Abe",
67
+ "nickname": "Abe Ani",
68
+ "height_cm": 167.64,
69
+ "weight_lbs": 145.0,
70
+ "reach_cm": null,
71
+ "stance": "Orthodox",
72
+ "birthdate": "--"
73
+ },
74
+ "http://ufcstats.com/fighter-details/5140122c3eecd307": {
75
+ "name": "Daichi Abe",
76
+ "nickname": "",
77
+ "height_cm": 180.34,
78
+ "weight_lbs": 170.0,
79
+ "reach_cm": 180.34,
80
+ "stance": "Orthodox",
81
+ "birthdate": "1991-11-27"
82
+ },
83
+ "http://ufcstats.com/fighter-details/c9f6385af6df66d7": {
84
+ "name": "Papy Abedi",
85
+ "nickname": "Makambo",
86
+ "height_cm": 180.34,
87
+ "weight_lbs": 185.0,
88
+ "reach_cm": null,
89
+ "stance": "Southpaw",
90
+ "birthdate": "1978-06-30"
91
+ },
92
+ "http://ufcstats.com/fighter-details/aa6e591c2a2cdecd": {
93
+ "name": "Ricardo Abreu",
94
+ "nickname": "Demente",
95
+ "height_cm": 180.34,
96
+ "weight_lbs": 185.0,
97
+ "reach_cm": null,
98
+ "stance": "Orthodox",
99
+ "birthdate": "1984-04-27"
100
+ }
101
+ }
sample_fight_urls.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "http://ufcstats.com/fighter-details/93fe7332d16c6ad9",
3
+ "http://ufcstats.com/fighter-details/15df64c02b6b0fde",
4
+ "http://ufcstats.com/fighter-details/59a9d6dac61c2540",
5
+ "http://ufcstats.com/fighter-details/b361180739bed4b0",
6
+ "http://ufcstats.com/fighter-details/3329d692aea4dc28",
7
+ "http://ufcstats.com/fighter-details/841695e02c99a521",
8
+ "http://ufcstats.com/fighter-details/2f5cbecbbe18bac4",
9
+ "http://ufcstats.com/fighter-details/c0ed7b208197e8de",
10
+ "http://ufcstats.com/fighter-details/5140122c3eecd307",
11
+ "http://ufcstats.com/fighter-details/c9f6385af6df66d7",
12
+ "http://ufcstats.com/fighter-details/aa6e591c2a2cdecd",
13
+ "http://ufcstats.com/fighter-details/7279654c7674cd24",
14
+ "http://ufcstats.com/fighter-details/f689bd7bbd14b392",
15
+ "http://ufcstats.com/fighter-details/1c5879330d42255f",
16
+ "http://ufcstats.com/fighter-details/989b85f6540c86b1",
17
+ "http://ufcstats.com/fighter-details/2620f3eb21c79614",
18
+ "http://ufcstats.com/fighter-details/83b00f7597e5ac83",
19
+ "http://ufcstats.com/fighter-details/a77633a989013265",
20
+ "http://ufcstats.com/fighter-details/79cb2a690b9ba5e8",
21
+ "http://ufcstats.com/fighter-details/1338e2c7480bdf9e",
22
+ "http://ufcstats.com/fighter-details/0e9869d712e81f8f",
23
+ "http://ufcstats.com/fighter-details/7a846fcbf182a7c8",
24
+ "http://ufcstats.com/fighter-details/ebc5af72ad5a28cb",
25
+ "http://ufcstats.com/fighter-details/a08ddd04eaffd81d",
26
+ "http://ufcstats.com/fighter-details/26f4288e83188c61",
27
+ "http://ufcstats.com/fighter-details/44aa652b181bcf68",
28
+ "http://ufcstats.com/fighter-details/501821d7fb7b95c1",
29
+ "http://ufcstats.com/fighter-details/6cadc0a0ba7dc015",
30
+ "http://ufcstats.com/fighter-details/8f382b3baa954d2a",
31
+ "http://ufcstats.com/fighter-details/cf946e03ba2e7666",
32
+ "http://ufcstats.com/fighter-details/c051c2e12d692b8a",
33
+ "http://ufcstats.com/fighter-details/ae071698e1a3ccd4",
34
+ "http://ufcstats.com/fighter-details/0978385b2bd9ef9b",
35
+ "http://ufcstats.com/fighter-details/9e3dbb9c68ed5d1a",
36
+ "http://ufcstats.com/fighter-details/49dea784f6cfed71",
37
+ "http://ufcstats.com/fighter-details/2eada40ac8801559",
38
+ "http://ufcstats.com/fighter-details/16690d100f995f8f",
39
+ "http://ufcstats.com/fighter-details/b0550072e5f0afa7",
40
+ "http://ufcstats.com/fighter-details/1fc64507a0cb38cf",
41
+ "http://ufcstats.com/fighter-details/38b50fd1e1b5b656",
42
+ "http://ufcstats.com/fighter-details/597499ac7a5aac62",
43
+ "http://ufcstats.com/fighter-details/1cf1310684a841f5",
44
+ "http://ufcstats.com/fighter-details/7578cc6bd750206b",
45
+ "http://ufcstats.com/fighter-details/2144954270be834d",
46
+ "http://ufcstats.com/fighter-details/1897b7b913736a7c",
47
+ "http://ufcstats.com/fighter-details/6d35bf94f7d30241",
48
+ "http://ufcstats.com/fighter-details/9b28292abe3166d5",
49
+ "http://ufcstats.com/fighter-details/7bd94b60d7521e4a",
50
+ "http://ufcstats.com/fighter-details/c482c8605455a213",
51
+ "http://ufcstats.com/fighter-details/184b955181bdef52",
52
+ "http://ufcstats.com/fighter-details/e76d9f656ceb82ab",
53
+ "http://ufcstats.com/fighter-details/dd1b90eea08887f6",
54
+ "http://ufcstats.com/fighter-details/39f62b833e4cf126",
55
+ "http://ufcstats.com/fighter-details/2f95a3c6d58b2aad",
56
+ "http://ufcstats.com/fighter-details/7c6e87729e824ef4",
57
+ "http://ufcstats.com/fighter-details/1e38bba6738b7b10",
58
+ "http://ufcstats.com/fighter-details/d26934530dc5b248",
59
+ "http://ufcstats.com/fighter-details/578ef12674df1e6a",
60
+ "http://ufcstats.com/fighter-details/c487223b0289bda9",
61
+ "http://ufcstats.com/fighter-details/7460ddef986d3144",
62
+ "http://ufcstats.com/fighter-details/d0f3959b4a9747e6",
63
+ "http://ufcstats.com/fighter-details/6fd953151d981979",
64
+ "http://ufcstats.com/fighter-details/103e2e33a60683e1",
65
+ "http://ufcstats.com/fighter-details/d35298b6df168456",
66
+ "http://ufcstats.com/fighter-details/fe5a9547479396ab",
67
+ "http://ufcstats.com/fighter-details/7a15f3694c5cbc02",
68
+ "http://ufcstats.com/fighter-details/0541480fbf719d86",
69
+ "http://ufcstats.com/fighter-details/8fd76e1b49c00ae2",
70
+ "http://ufcstats.com/fighter-details/11583163f45c7b31",
71
+ "http://ufcstats.com/fighter-details/d53482bef23235ba",
72
+ "http://ufcstats.com/fighter-details/b757c73f443d4fca",
73
+ "http://ufcstats.com/fighter-details/4b37a0bc2ab4cae1",
74
+ "http://ufcstats.com/fighter-details/41b34b7f11f6d085",
75
+ "http://ufcstats.com/fighter-details/9abc648e76c4493a",
76
+ "http://ufcstats.com/fighter-details/669a3cb6e394f515",
77
+ "http://ufcstats.com/fighter-details/e17770faae3ca54c",
78
+ "http://ufcstats.com/fighter-details/e70de1859b7ee78e",
79
+ "http://ufcstats.com/fighter-details/ca28cdf526d6b6e9",
80
+ "http://ufcstats.com/fighter-details/b07aed698fba8624",
81
+ "http://ufcstats.com/fighter-details/6db394bf6c3b017c",
82
+ "http://ufcstats.com/fighter-details/6ebe96a116e79e52",
83
+ "http://ufcstats.com/fighter-details/1e13936d708bcff7",
84
+ "http://ufcstats.com/fighter-details/040a74bb0a465c54",
85
+ "http://ufcstats.com/fighter-details/2f181c0467965b98",
86
+ "http://ufcstats.com/fighter-details/adf9a901308fb8e3",
87
+ "http://ufcstats.com/fighter-details/c4fe2e9a06ea5bcb"
88
+ ]