Skip to content

Instantly share code, notes, and snippets.

@jrosell
Last active December 13, 2024 10:05
Show Gist options
  • Save jrosell/667fee58c8ff47a99591fa6122e04ed3 to your computer and use it in GitHub Desktop.
Save jrosell/667fee58c8ff47a99591fa6122e04ed3 to your computer and use it in GitHub Desktop.
# Thanks to @koaning for pointing out this visualization in Stack Overflow https://stackoverflow.com/a/49535509/481463 in this video https://www.youtube.com/watch?v=3M2Gmuh5mtI
library(tidyverse)
library(rayshader)
library(viridis)
df <-
expand_grid(
precision = 1:100 / 100,
recall = 1:100 / 100,
) |>
mutate(
mean = (precision + recall) / 2,
f_1_score = 2*(precision * recall)/(precision + recall)
) |>
glimpse()
gg_mean <- df |>
ggplot() +
geom_tile(aes(x = precision, y = recall, fill = mean)) +
geom_contour(aes(x = precision, y = recall, z = mean)) +
scale_fill_viridis_c(option = "A")
gg_mean
plot_gg(
gg_mean,
multicore = TRUE, width=5, height=5, scale=250, windowsize=c(1400,866),
zoom = 0.55, phi = 30
)
render_snapshot()
gg_f_1_score <- df |>
ggplot() +
geom_tile(aes(x = precision, y = recall, fill = f_1_score)) +
geom_contour(aes(x = precision, y = recall, z = f_1_score)) +
# geom_contour(apes(fill = f_1_score)) +
scale_fill_viridis_c(option = "A")
gg_f_1_score
plot_gg(
gg_f_1_score,
multicore = TRUE, width=5, height=5, scale=250, windowsize=c(1400,866),
zoom = 0.55, phi = 30
)
render_snapshot()
@jrosell
Copy link
Author

jrosell commented Dec 13, 2024

Mean
mean

F1 score
f_1_score png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment