File size: 11,888 Bytes
bd26863 ab18d14 1715583 ab18d14 3060f0d ab18d14 1715583 649b5dc 1715583 ab18d14 1715583 ab18d14 1715583 bd26863 87dfcb1 3060f0d ebca39c ab18d14 3060f0d ab18d14 3060f0d 37cd4de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
from datasets import Dataset, DatasetBuilder, DatasetInfo, Features, Value, SplitGenerator
import pandas as pd
class Euro2020Dataset(DatasetBuilder):
VERSION = "1.0.0"
def _info(self):
return DatasetInfo(
description="Your dataset description here.",
features=Features({
"HomeTeamName": Value("string"),
"AwayTeamName": Value("string"),
"DateandTimeCET": Value("string"),
"MatchID": Value("int64"),
"RoundName": Value("string"),
"Stage": Value("string"),
"MatchDay": Value("int64"),
"Session": Value("int64"),
"MatchMinute": Value("int64"),
"InjuryTime": Value("int64"),
"NumberofPhases": Value("int64"),
"Phase": Value("int64"),
"ScoreHome": Value("int64"),
"ScoreAway": Value("int64"),
"MatchStatus": Value("string"),
"StadiumID": Value("int64"),
"NumberofMatchesRefereedPostMatch": Value("int64"),
"TotalNumberofMatchesRefereed": Value("int64"),
"NumberofMatchesRefereedinGroupStage": Value("int64"),
"NumberofMatchesRefereedinKnockoutStage": Value("int64"),
"AssistantRefereeWebName": Value("string"),
"Humidity": Value("int64"),
"Temperature": Value("int64"),
"WindSpeed": Value("int64"),
"MatchEvent": Features({
"1-First Half": Features({
"Event": Value("string"),
"Minute": Value("int"),
"Phase": Value("int"),
"InjuryMinute": Value("int"),
"TeamFromID": Value("float"),
"TeamToID": Value("float"),
"PlayerFromID": Value("float"),
"PlayerToID": Value("float"),
"Time": Value("string"),
"MatchEventAttribute": Value("float"),
}),
"2-Second Half": Features({
"Event": Value("string"),
"Minute": Value("int"),
"Phase": Value("int"),
"InjuryMinute": Value("int"),
"TeamFromID": Value("float"),
"TeamToID": Value("float"),
"PlayerFromID": Value("float"),
"PlayerToID": Value("float"),
"Time": Value("string"),
"MatchEventAttribute": Value("float"),
}),
"3-Extra Time First Half": Features({
"Event": Value("string"),
"Minute": Value("int"),
"Phase": Value("int"),
"InjuryMinute": Value("int"),
"TeamFromID": Value("float"),
"TeamToID": Value("float"),
"PlayerFromID": Value("float"),
"PlayerToID": Value("float"),
"Time": Value("string"),
"MatchEventAttribute": Value("float"),
}),
"4-Extra Time Second Half": Features({
"Event": Value("string"),
"Minute": Value("int"),
"Phase": Value("int"),
"InjuryMinute": Value("int"),
"TeamFromID": Value("float"),
"TeamToID": Value("float"),
"PlayerFromID": Value("float"),
"PlayerToID": Value("float"),
"Time": Value("string"),
"MatchEventAttribute": Value("float"),
}),
"5-Penalty Shootout": Features({
"Event": Value("string"),
"Minute": Value("int"),
"Phase": Value("int"),
"InjuryMinute": Value("int"),
"TeamFromID": Value("float"),
"TeamToID": Value("float"),
"PlayerFromID": Value("float"),
"PlayerToID": Value("float"),
"Time": Value("string"),
"MatchEventAttribute": Value("float"),
}),
}),
"TeamLineUps" = Features({
"HomeTeamLineUp": Features({
"Starting11": Sequence(Features({
"Country": Value("string"),
"ID": Value("int"),
"OfficialName": Value("string"),
"OfficialSurname": Value("string"),
"ShortName": Value("string"),
"Role": Value("string"),
"JerseyNumber": Value("string"),
"IsGoalkeeper": Value("string"),
"JerseyName": Value("string"),
"IsCaptain": Value("string"),
"TacticX": Value("string"),
"TacticY": Value("string"),
"Numorder": Value("string"),
"IsBooked": Value("float"),
})),
"Benched Players": Sequence(Features({
"Country": Value("string"),
"ID": Value("int"),
"OfficialName": Value("string"),
"OfficialSurname": Value("string"),
"ShortName": Value("string"),
"Role": Value("string"),
"JerseyNumber": Value("string"),
"IsGoalkeeper": Value("string"),
"JerseyName": Value("string"),
"IsCaptain": Value("string"),
"TacticX": Value("string"),
"TacticY": Value("string"),
"Numorder": Value("string"),
"IsBooked": Value("float"),
})),
"Staff": Sequence(Features({
"Country": Value("string"),
"ID": Value("int"),
"OfficialName": Value("string"),
"OfficialSurname": Value("string"),
"ShortName": Value("string"),
"Role": Value("string"),
})),
}),
"AwayTeamLineUps": Features({
"Starting11": Sequence(Features({
"Country": Value("string"),
"ID": Value("int"),
"OfficialName": Value("string"),
"OfficialSurname": Value("string"),
"ShortName": Value("string"),
"Role": Value("string"),
"JerseyNumber": Value("string"),
"IsGoalkeeper": Value("string"),
"JerseyName": Value("string"),
"IsCaptain": Value("string"),
"TacticX": Value("string"),
"TacticY": Value("string"),
"Numorder": Value("string"),
"IsBooked": Value("float"),
})),
"Benched Players": Sequence(Features({
"Country": Value("string"),
"ID": Value("int"),
"OfficialName": Value("string"),
"OfficialSurname": Value("string"),
"ShortName": Value("string"),
"Role": Value("string"),
"JerseyNumber": Value("string"),
"IsGoalkeeper": Value("string"),
"JerseyName": Value("string"),
"IsCaptain": Value("string"),
"TacticX": Value("string"),
"TacticY": Value("string"),
"Numorder": Value("string"),
"IsBooked": Value("float"),
})),
"Staff": Sequence(Features({
"Country": Value("string"),
"ID": Value("int"),
"OfficialName": Value("string"),
"OfficialSurname": Value("string"),
"ShortName": Value("string"),
"Role": Value("string"),
})),
}),
}),
"TeamStats": Value("dict"),
"PlayerStats": Value("dict"),
"PlayerPreMatchInfo": Value("dict"),
}),
supervised_keys=None,
homepage="Optional dataset homepage",
license= "",
citation="Optional citation"
)
def _split_generators(self, dl_manager):
# Since the final processed dataset is a single CSV file that combines the content from numerous rows to only 51 rows,
# with each row representing the information of each game, I will just use a single 'train' split and no need for test / validation.
path = "/Users/chuhanguo/Desktop/Winter 2024/STA 663/Euro2020.csv"
return [
SplitGenerator(
name="train",
gen_kwargs={"filepath": path}
),
]
def _generate_examples(self, path):
data = pd.read_csv(path)
for idx, row in data.iterrows():
yield idx, {
"HomeTeamName": row["HomeTeamName"],
"AwayTeamName": row["AwayTeamName"],
"DateandTimeCET": row["DateandTimeCET"],
"MatchID": row["MatchID"],
"RoundName": row["RoundName"],
"Stage": row["Stage"],
"MatchDay": row["MatchDay"],
"Session": row["Session"],
"MatchMinute": row["MatchMinute"],
"InjuryTime": row["InjuryTime"],
"NumberofPhases": row["NumberofPhases"],
"Phase": row["Phase"],
"ScoreHome": row["ScoreHome"],
"ScoreAway": row["ScoreAway"],
"MatchStatus": row["MatchStatus"],
"StadiumID": row["StadiumID"],
"NumberofMatchesRefereedPostMatch": row["NumberofMatchesRefereedPostMatch"],
"TotalNumberofMatchesRefereed": row["TotalNumberofMatchesRefereed"],
"NumberofMatchesRefereedinGroupStage": row["NumberofMatchesRefereedinGroupStage"],
"NumberofMatchesRefereedinKnockoutStage": row["NumberofMatchesRefereedinKnockoutStage"],
"AssistantRefereeWebName": row["AssistantRefereeWebName"],
"Humidity": row["Humidity"],
"Temperature": row["Temperature"],
"WindSpeed": row["WindSpeed"],
"MatchEvent": row["MatchEvent"],
"TeamLineUps": row["TeamLineUps"],
"TeamStats": row["TeamStats"],
"PlayerStats": row["PlayerStats"],
"PlayerPreMatchInfo": row["PlayerPreMatchInfo"],
}
|