Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

default.js 725 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  1. // Default scoring function that weights metrics by geometric mean
  2. module.exports = (namedScores, context) => {
  3. const scores = {};
  4. for (const [key, value] of Object.entries(namedScores)) {
  5. scores[key] = value || 0;
  6. }
  7. const totalScore = Math.pow(
  8. Object.values(scores).reduce((acc, score) => acc * score, 1),
  9. 1 / Object.keys(scores).length,
  10. );
  11. console.log('Default scoring function (JavaScript):', namedScores, 'Total score:', totalScore);
  12. const threshold = context?.threshold ?? 0.7;
  13. return {
  14. pass: totalScore >= threshold,
  15. score: totalScore,
  16. reason: `Weighted score calculation: ${Object.entries(scores)
  17. .map(([key, value]) => `${key}: ${value}`)
  18. .join(', ')}`,
  19. };
  20. };
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...