-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval_report.go
More file actions
42 lines (38 loc) · 1.08 KB
/
Copy patheval_report.go
File metadata and controls
42 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package contexting
import (
"encoding/json"
"fmt"
)
func printEvalSummary(summary EvalSummary) {
fmt.Printf("Cases: %d (scored=%d, invalid=%d)\n", summary.Cases, summary.ScoredCases, summary.FailedCases)
fmt.Printf("Hit@1: %.2f%% (%d)\n", summary.HitAt1*100, summary.Top1Hits)
fmt.Printf("Hit@3: %.2f%% (%d)\n", summary.HitAt3*100, summary.Top3Hits)
fmt.Printf("Hit@5: %.2f%% (%d)\n", summary.HitAt5*100, summary.Top5Hits)
fmt.Printf("MRR: %.4f\n", summary.MRR)
}
func printFailedCases(results []EvalResult) {
printed := 0
for _, result := range results {
if result.MatchedAt > 0 {
continue
}
if printed == 0 {
fmt.Println("Misses:")
}
printed++
fmt.Printf("- query=%q expected=%v\n", result.Case.Query, result.Case.ExpectAny)
for i, candidate := range result.TopPaths {
fmt.Printf(" %d) %s score=%d\n", i+1, candidate.Path, candidate.Score)
}
}
if printed == 0 {
fmt.Println("Misses: none")
}
}
func resultsToJSONEval(value any) (string, error) {
bytes, err := json.MarshalIndent(value, "", " ")
if err != nil {
return "", err
}
return string(bytes), nil
}