PHP code example of vexo / compare

1. Go to this page and download the library: Download vexo/compare library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vexo / compare example snippets




declare(strict_types=1);

use Vexo\Compare\Distance;
use Vexo\Compare\Similarity;

$one = [0.21, -0.32, 0.01];
$two = [0.42, -0.11, -0.02];

// Get the euclidean distance between vector one and two
$distance = euclidean($one, $two);

// Get the average of cosine distances between vector one and two
$similarity = Similarity\cosine($one, $two);