more data

This commit is contained in:
LukaszChrostowski 2023-11-27 14:35:00 +01:00
parent a98353e257
commit 89d4e48c96
5 changed files with 10216 additions and 22 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
data/.DS_Store vendored

Binary file not shown.

View File

@ -1,19 +1,19 @@
"","minute","position_name","shot_body_part_name","shot_type_name","shot_outcome_name","shot_technique_name","shot_one_on_one","shot_first_time","shot_aerial_won","shot_saved_to_post","shot_deflected","shot_saved_off_target","shot_open_goal","shot_follows_dribble","shot_redirect","x1","y1","number_of_players","kick_off","angle","is_goal"
"1",11,"Right Wing","Left Foot","Open Play","Blocked","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,93.2,44.4,9,FALSE,0.0640059213742957,0
"2",13,"Right Wing","Left Foot","Open Play","Saved","Lob",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,100.3,42.8,1,FALSE,0.061730105843871,0
"3",21,"Right Center Forward","Right Foot","Open Play","Blocked","Normal",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,110.1,28,1,FALSE,0.0624299048089645,0
"4",25,"Left Midfield","Left Foot","Open Play","Off T","Half Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,108.8,25,5,FALSE,0.0638870054917821,0
"5",32,"Center Forward","Left Foot","Open Play","Goal","Lob",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,107.1,42.5,2,FALSE,0.0590398311560372,1
"6",38,"Right Back","Left Foot","Open Play","Goal","Normal",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,107.7,47.3,6,FALSE,0.0569702959919461,1
"7",42,"Right Wing","Left Foot","Free Kick","Off T","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,87.3,45.3,11,FALSE,0.0660566548690278,0
"8",47,"Right Wing","Head","Open Play","Saved","Normal",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,112,32.2,1,FALSE,0.060353615283394,0
"9",49,"Right Defensive Midfield","Right Foot","Free Kick","Off T","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,84.7,35.2,11,FALSE,0.0736787207689688,0
"10",58,"Right Wing","Right Foot","Open Play","Blocked","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,115.6,51.7,2,FALSE,0.052762547731953,0
"11",65,"Right Center Forward","Right Foot","Open Play","Goal","Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,104.3,37.6,3,FALSE,0.0620981693525753,1
"12",69,"Left Wing","Right Foot","Open Play","Saved","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,101.2,24.7,4,FALSE,0.068243631613985,0
"13",71,"Right Center Forward","Right Foot","Open Play","Saved","Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,115.5,44.1,1,FALSE,0.0553048979119624,0
"14",73,"Left Wing","Left Foot","Open Play","Blocked","Normal",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,108.3,33.4,6,FALSE,0.0617057300721472,0
"15",73,"Center Forward","Right Foot","Open Play","Off T","Normal",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,107.7,39.4,6,FALSE,0.0599333680981008,0
"16",76,"Center Forward","Right Foot","Open Play","Off T","Half Volley",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,108.7,52.1,1,FALSE,0.0547568224463756,0
"17",79,"Left Center Forward","Right Foot","Open Play","Off T","Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,113.9,34.4,4,FALSE,0.0588824107265361,0
"18",89,"Right Center Forward","Left Foot","Open Play","Off T","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,100.2,51.6,7,FALSE,0.0577379599935821,0
"","minute","position_name","shot_body_part_name","shot_type_name","shot_outcome_name","shot_technique_name","shot_one_on_one","shot_first_time","shot_aerial_won","shot_saved_to_post","shot_deflected","shot_saved_off_target","shot_open_goal","shot_follows_dribble","shot_redirect","x1","y1","number_of_players_opponents","number_of_players_teammates","kick_off","angle","is_goal"
"1",11,"Right Wing","Left Foot","Open Play","Blocked","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,93.2,44.4,9,5,FALSE,0.0640059213742957,0
"2",13,"Right Wing","Left Foot","Open Play","Saved","Lob",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,100.3,42.8,1,0,FALSE,0.061730105843871,0
"3",21,"Right Center Forward","Right Foot","Open Play","Blocked","Normal",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,110.1,28,1,0,FALSE,0.0624299048089645,0
"4",25,"Left Midfield","Left Foot","Open Play","Off T","Half Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,108.8,25,5,2,FALSE,0.0638870054917821,0
"5",32,"Center Forward","Left Foot","Open Play","Goal","Lob",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,107.1,42.5,2,1,FALSE,0.0590398311560372,1
"6",38,"Right Back","Left Foot","Open Play","Goal","Normal",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,107.7,47.3,6,4,FALSE,0.0569702959919461,1
"7",42,"Right Wing","Left Foot","Free Kick","Off T","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,87.3,45.3,11,7,FALSE,0.0660566548690278,0
"8",47,"Right Wing","Head","Open Play","Saved","Normal",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,112,32.2,1,0,FALSE,0.060353615283394,0
"9",49,"Right Defensive Midfield","Right Foot","Free Kick","Off T","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,84.7,35.2,11,6,FALSE,0.0736787207689688,0
"10",58,"Right Wing","Right Foot","Open Play","Blocked","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,115.6,51.7,2,0,FALSE,0.052762547731953,0
"11",65,"Right Center Forward","Right Foot","Open Play","Goal","Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,104.3,37.6,3,0,FALSE,0.0620981693525753,1
"12",69,"Left Wing","Right Foot","Open Play","Saved","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,101.2,24.7,4,0,FALSE,0.068243631613985,0
"13",71,"Right Center Forward","Right Foot","Open Play","Saved","Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,115.5,44.1,1,0,FALSE,0.0553048979119624,0
"14",73,"Left Wing","Left Foot","Open Play","Blocked","Normal",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,108.3,33.4,6,1,FALSE,0.0617057300721472,0
"15",73,"Center Forward","Right Foot","Open Play","Off T","Normal",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,107.7,39.4,6,2,FALSE,0.0599333680981008,0
"16",76,"Center Forward","Right Foot","Open Play","Off T","Half Volley",TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,108.7,52.1,1,0,FALSE,0.0547568224463756,0
"17",79,"Left Center Forward","Right Foot","Open Play","Off T","Volley",FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,113.9,34.4,4,1,FALSE,0.0588824107265361,0
"18",89,"Right Center Forward","Left Foot","Open Play","Off T","Normal",FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,100.2,51.6,7,2,FALSE,0.0577379599935821,0
1 minute position_name shot_body_part_name shot_type_name shot_outcome_name shot_technique_name shot_one_on_one shot_first_time shot_aerial_won shot_saved_to_post shot_deflected shot_saved_off_target shot_open_goal shot_follows_dribble shot_redirect x1 y1 number_of_players number_of_players_opponents number_of_players_teammates kick_off angle is_goal
2 1 11 Right Wing Left Foot Open Play Blocked Normal FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 93.2 44.4 9 5 FALSE 0.0640059213742957 0
3 2 13 Right Wing Left Foot Open Play Saved Lob TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 100.3 42.8 1 0 FALSE 0.061730105843871 0
4 3 21 Right Center Forward Right Foot Open Play Blocked Normal TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 110.1 28 1 0 FALSE 0.0624299048089645 0
5 4 25 Left Midfield Left Foot Open Play Off T Half Volley FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 108.8 25 5 2 FALSE 0.0638870054917821 0
6 5 32 Center Forward Left Foot Open Play Goal Lob FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 107.1 42.5 2 1 FALSE 0.0590398311560372 1
7 6 38 Right Back Left Foot Open Play Goal Normal FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 107.7 47.3 6 4 FALSE 0.0569702959919461 1
8 7 42 Right Wing Left Foot Free Kick Off T Normal FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 87.3 45.3 11 7 FALSE 0.0660566548690278 0
9 8 47 Right Wing Head Open Play Saved Normal TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 112 32.2 1 0 FALSE 0.060353615283394 0
10 9 49 Right Defensive Midfield Right Foot Free Kick Off T Normal FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 84.7 35.2 11 6 FALSE 0.0736787207689688 0
11 10 58 Right Wing Right Foot Open Play Blocked Normal FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 115.6 51.7 2 0 FALSE 0.052762547731953 0
12 11 65 Right Center Forward Right Foot Open Play Goal Volley FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 104.3 37.6 3 0 FALSE 0.0620981693525753 1
13 12 69 Left Wing Right Foot Open Play Saved Normal FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 101.2 24.7 4 0 FALSE 0.068243631613985 0
14 13 71 Right Center Forward Right Foot Open Play Saved Volley FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 115.5 44.1 1 0 FALSE 0.0553048979119624 0
15 14 73 Left Wing Left Foot Open Play Blocked Normal FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 108.3 33.4 6 1 FALSE 0.0617057300721472 0
16 15 73 Center Forward Right Foot Open Play Off T Normal FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 107.7 39.4 6 2 FALSE 0.0599333680981008 0
17 16 76 Center Forward Right Foot Open Play Off T Half Volley TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 108.7 52.1 1 0 FALSE 0.0547568224463756 0
18 17 79 Left Center Forward Right Foot Open Play Off T Volley FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 113.9 34.4 4 1 FALSE 0.0588824107265361 0
19 18 89 Right Center Forward Left Foot Open Play Off T Normal FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 100.2 51.6 7 2 FALSE 0.0577379599935821 0

10166
data/data4.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@ -115,7 +115,7 @@ get_shots2 <- function(json_file) {
data$y1 <- df_temp[,2]
tryCatch({ # TODO reduce error cases
data$number_of_players <- mapply(function(sublist, x1_threshold) {
data$number_of_players_opponents <- mapply(function(sublist, x1_threshold) {
# Extracting the first location value and converting it to numeric
first_location_values <- sapply(sublist$location, function(loc) as.numeric(loc[1]))
@ -133,6 +133,26 @@ get_shots2 <- function(json_file) {
print(paste("An error occurred:", e$message))
})
tryCatch({ # TODO reduce error cases
data$number_of_players_teammates <- mapply(function(sublist, x1_threshold) {
# Extracting the first location value and converting it to numeric
first_location_values <- sapply(sublist$location, function(loc) as.numeric(loc[1]))
if ("teammate" %in% names(sublist)) {
# Filtering and counting
res <- sum(sublist$teammate & first_location_values > x1_threshold) # error here
} else {
res <- 0
}
res
}, data$shot$freeze_frame, data$x1)
},
error = function(e) {
# handle the error
print(paste("An error occurred:", e$message))
})
data$shot <- data$shot %>% select(-freeze_frame, -statsbomb_xg, -key_pass_id)
data$shot$body_part <- data$shot$body_part %>% select(-id)
data$shot$technique <- data$shot$technique %>% select(-id)
@ -223,9 +243,17 @@ get_shots2 <- function(json_file) {
file_names <- list.files(path = "data/la_liga_events/", pattern = "*.json")
data_list <- lapply(paste("data/la_liga_events/", file_names, sep = ""), get_shots2)
combined_data <- do.call(rbind, data_list[1:10])
combined_data <- do.call(rbind, data_list)
# sample data
data_test <- get_shots2("data/la_liga_events/303377.json")
write.csv(data_test, file = "data/data_test.csv")
write.csv(data_test, file = "data/data3_test.csv")
##################### The fourth dataset ##############################
data4 <- read.csv("data/data4.csv", nrows = 1000)
data1 <- read.csv("data/data1.csv", nrows = 1000)
data2 <- read.csv("data/data2.csv", nrows = 1000)
data3 <- read.csv("data/data3_test.csv", nrows = 1000)