Classify and score

Options with jev_choice(), ordered levels with jev_score(), plus confidence when you need it.

jev_choice() picks one label from a list you define. jev_score() places the row on an ordered rubric and returns a probability-weighted index (0 .. n-1). jev_score_norm() rescales that to 0..1 so two rubrics can be compared.

sql
SELECT jev_choice(tickets, 'which team should handle this?',
                  ARRAY['billing', 'technical', 'security', 'sales']) AS team,
       count(*)
FROM tickets
GROUP BY 1;

SELECT name,
       jev_score(products, 'how luxurious is this product?',
                 ARRAY['budget', 'mid-range', 'premium', 'luxury']) AS luxury
FROM products
ORDER BY luxury DESC;

Name the options the way you would brief a person. Vague buckets ('other', 'misc') collect leftovers; prefer a closed set you can act on.

When you need the model's certainty, or the raw probabilities:

sql
SELECT subject,
       jev_choice(tickets, 'which team should handle this?',
                  ARRAY['billing', 'technical', 'sales']) AS team,
       jev_confidence(tickets, 'which team should handle this?',
                      'choice', ARRAY['billing', 'technical', 'sales']) AS conf
FROM tickets;

SELECT jev_eval(products, 'how luxurious is this product?',
                'score', ARRAY['budget', 'mid-range', 'premium', 'luxury']);

jev_eval returns jsonb (probabilities, legend, confidence). Exact fields are in Functions. For a boolean cut rather than a class, use Filter and rank.