add confidence to tooltip only

This commit is contained in:
Josh Hawkins 2024-10-17 08:11:43 -05:00
parent 1445a17e27
commit 8c0781ad4a

View File

@ -189,6 +189,21 @@ export default function SearchView({
setSelectedIndex(0);
}, [searchTerm, searchFilter]);
// confidence score
const zScoreToConfidence = (score: number) => {
// Normalizing is not needed for similarity searches
// Sigmoid function for normalized: 1 / (1 + e^x)
// Cosine for similarity
if (searchFilter) {
const notNormalized = searchFilter?.search_type?.includes("similarity");
const confidence = notNormalized ? 1 - score : 1 / (1 + Math.exp(score));
return Math.round(confidence * 100);
}
};
// update search detail when results change
useEffect(() => {
@ -422,7 +437,8 @@ export default function SearchView({
</TooltipTrigger>
<TooltipPortal>
<TooltipContent>
Matched {value.search_source}
Matched {value.search_source} at{" "}
{zScoreToConfidence(value.search_distance)}%
</TooltipContent>
</TooltipPortal>
</Tooltip>