PHP code example of wellingtonbarbosa / knn
1. Go to this page and download the library: Download wellingtonbarbosa/knn 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/ */
wellingtonbarbosa / knn example snippets
WellingtonBarbosa\Knn\Knn;
//Performs Euclidean distance calculation
$results = $knn->calculate();
//Multiple items
foreach($recomendation as $key) {
echo "Euclidian distances for item (" . $key . ") =>> " . $result[$key];
echo "<br>";
foreach($itemsToCompare[$key] as $item) {
echo $item . " | ";
}
echo "<hr>";
}
//Single item
echo "Recomended item: " . $recomendation;
echo "<br>";
foreach($itemsToCompare[$key] as $item) {
echo $item . " | ";
}