Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boxes in bias_leaderboard #845

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions experiments/ClimaEarth/user_io/leaderboard/cmip_rmse.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Statistics: median
import Statistics: median, quantile

const RMSE_FILE_PATHS = Dict()

Expand Down Expand Up @@ -75,7 +75,25 @@ function RSME_stats(vecRMSEs)
SON = minimum(abs.(SON)),
)

(; best_single_model = best_single_model(vecRMSEs), median_model, worst_model, best_model)
quantile25 = RMSEs(;
model_name = "Quantile 0.25",
ANN = quantile(ANN, 0.25),
DJF = quantile(DJF, 0.25),
JJA = quantile(JJA, 0.25),
MAM = quantile(MAM, 0.25),
SON = quantile(SON, 0.25),
)

quantile75 = RMSEs(;
model_name = "Quantile 0.75",
ANN = quantile(ANN, 0.75),
DJF = quantile(DJF, 0.75),
JJA = quantile(JJA, 0.75),
MAM = quantile(MAM, 0.75),
SON = quantile(SON, 0.75),
)

(; best_single_model = best_single_model(vecRMSEs), median_model, worst_model, best_model, quantile25, quantile75)
end
szy21 marked this conversation as resolved.
Show resolved Hide resolved

for short_name in short_names
Expand Down
45 changes: 31 additions & 14 deletions experiments/ClimaEarth/user_io/leaderboard/compare_with_obs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function plot_leaderboard(rmses; output_path)
loc_squares = length(rmses) + 1
ax_squares = CairoMakie.Axis(
fig[loc_squares, 1],
yticks = (1:num_variables, var_names),
yticks = (1:num_variables, reverse(var_names)),
xticks = ([3, NUM_BOXES + 3], ["CliMA", "Best model"]),
aspect = NUM_BOXES * NUM_MODELS,
)
Expand Down Expand Up @@ -116,29 +116,46 @@ function plot_leaderboard(rmses; output_path)
# Against other models
(; best_single_model, median_model, worst_model, best_model) = COMPARISON_RMSEs[short_name]

squares[begin:NUM_BOXES, var_num] .= values(rmse) ./ values(median_model)
squares[(NUM_BOXES + 1):end, var_num] .= values(best_single_model) ./ values(median_model)
squares[begin:NUM_BOXES, end - var_num + 1] .= values(rmse) ./ values(median_model)
squares[(NUM_BOXES + 1):end, end - var_num + 1] .= values(best_single_model) ./ values(median_model)

CairoMakie.errorbars!(
CairoMakie.scatter!(
ax,
1:5,
values(median_model),
values(best_model),
values(worst_model),
whiskerwidth = 10,
label = median_model.model_name,
color = :black,
linewidth = 0.5,
marker = :hline,
markersize = 15,
)

categories = vcat(map(_ -> collect(1:5), 1:length(OTHER_MODELS_RMSEs[short_name]))...)

CairoMakie.boxplot!(
ax,
categories,
vcat(values.(OTHER_MODELS_RMSEs[short_name])...);
whiskerwidth = 1,
width = 0.35,
mediancolor = :black,
color = :gray,
whiskerlinewidth = 1,
)

# If we want to plot other models
# for model in OTHER_MODELS_RMSEs[short_name]
# CairoMakie.scatter!(ax, 1:5, values(model), marker = :hline)
# end

CairoMakie.scatter!(
ax,
1:5,
values(median_model),
label = median_model.model_name,
color = :black,
marker = :hline,
values(rmse),
label = rmse.model_name,
marker = :star5,
markersize = 20,
color = :orange,
)
CairoMakie.scatter!(ax, 1:5, values(best_single_model), label = best_single_model.model_name)
CairoMakie.scatter!(ax, 1:5, values(rmse), label = rmse.model_name, marker = :star5)

# Add a fake extra point to center the legend a little better
CairoMakie.scatter!(ax, [6.5], [0.1], markersize = 0.01)
Expand Down
Loading