UEFA_Euro_2020_Data / Integration
ForzaJuve1's picture
Update Integration
87dfcb1 verified
raw
history blame
6.36 kB
from datasets import 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": Value("dict"),
"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 wil just use a single 'train' split and no need for test / validation.
Euro2020_df = pd.read_csv("/Users/chuhanguo/Desktop/Winter 2024/STA 663/Euro2020.csv")
train_path = "ForzaJuve1/UEFA_Euro_2020_Data/Euro2020.csv"
Euro2020_df.to_csv(train_path, index = False)
return [
SplitGenerator(
name="train",
gen_kwargs={"filepath": train_path}
),
]
#def _generate_examples(self, filepath):
#Here we read the CSV file and yield examples
#data = pd.read_csv(filepath)
#for idx, row in data.iterrows():
#yield idx, {
#"PlayerID": row["PlayerID"],
#"PlayerName": row["PlayerName"],
#"PlayerSurname": row["PlayerSurname"],
#"IsGoalkeeper": row["IsGoalkeeper"],
#"PlayedTime": row["PlayedTime"],
#"StatsID": row["StatsID"],
#"StatsName": row["StatsName"],
#"Value": row["Value"],
#"Rank": row["Rank"],
# Make sure to include all fields defined in _info
#}