Answers for "php get cosine sim"

PHP
0

php get cosine sim

function dotp($arr1, $arr2){
     return array_sum(array_map(create_function('$a, $b', 'return $a * $b;'), $arr1, $arr2));
}
function cosineSim($arr1, $arr2){
	return dotp($arr1,$arr2)/sqrt(dotp($arr1,$arr1)*dotp($arr2,$arr2));
}
Posted by: Guest on February-16-2021

Browse Popular Code Answers by Language