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

Made --report and --leaderboard use different precision. #95

Merged
merged 1 commit into from
Jun 13, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ add_custom_command(
$$\(find ${protobuf_BINARY_DIR} -name \"*.o\" ! -ipath \"*/google/protobuf/compiler/main.cc.o\"\)
-o ${zimtohrli_goohrli_object}
COMMAND ${CMAKE_AR} rcs ${zimtohrli_goohrli_archive} ${zimtohrli_goohrli_object}
DEPENDS zimtohrli_goohrli_glue
DEPENDS zimtohrli_goohrli_glue zimtohrli_base zimtohrli_visqol_adapter
)
add_custom_target(zimtohrli_goohrli ALL DEPENDS ${zimtohrli_goohrli_archive})

Expand Down
2 changes: 1 addition & 1 deletion go/bin/score/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
board, err := bundles.Leaderboard()
board, err := bundles.Leaderboard(15)
if err != nil {
log.Fatal(err)
}
Expand Down
9 changes: 6 additions & 3 deletions go/data/study.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ Created at %s

fmt.Fprintf(res, "## Global leaderboard across all studies\n\n")

board, err := r.Leaderboard()
board, err := r.Leaderboard(2)
if err != nil {
return "", err
}
Expand All @@ -628,6 +628,7 @@ Created at %s

// MSEScore is MSE for a score type across a set of studies.
type MSEScore struct {
Decimals int
ScoreType ScoreType
MSE float64
MinScore float64
Expand All @@ -641,7 +642,8 @@ type MSEScores []MSEScore
func (m MSEScores) String() string {
table := Table{Row{"Score type", "MSE", "Min score", "Max score", "Mean score"}, nil}
for _, score := range m {
table = append(table, Row{string(score.ScoreType), fmt.Sprintf("%.2f", score.MSE), fmt.Sprintf("%.2f", score.MinScore), fmt.Sprintf("%.2f", score.MaxScore), fmt.Sprintf("%.2f", score.MeanScore)})
precisionString := fmt.Sprintf("%%.%df", score.Decimals)
table = append(table, Row{string(score.ScoreType), fmt.Sprintf(precisionString, score.MSE), fmt.Sprintf(precisionString, score.MinScore), fmt.Sprintf(precisionString, score.MaxScore), fmt.Sprintf(precisionString, score.MeanScore)})
}
return fmt.Sprintf("### Mean square error (1 - Spearman correlation, or 1 - accuracy) per score type\n\n%s", table.String())
}
Expand All @@ -659,7 +661,7 @@ func (m MSEScores) Swap(i, j int) {
}

// Leaderboard returns the sorted mean squared errors for each score type that is represented in all bundles.
func (r ReferenceBundles) Leaderboard() (MSEScores, error) {
func (r ReferenceBundles) Leaderboard(decimals int) (MSEScores, error) {
representedScoreTypes := map[ScoreType]int{}
for index, bundle := range r {
if index == 0 {
Expand Down Expand Up @@ -726,6 +728,7 @@ func (r ReferenceBundles) Leaderboard() (MSEScores, error) {
numStudiesRecpripcal := 1.0 / float64(len(r))
for scoreType, squareSum := range sumOfSquares {
result = append(result, MSEScore{
Decimals: decimals,
ScoreType: scoreType,
MSE: squareSum * numStudiesRecpripcal,
MeanScore: sums[scoreType] * numStudiesRecpripcal,
Expand Down
Binary file modified go/goohrli/goohrli.a
Binary file not shown.
Loading