Skip to content

Instantly share code, notes, and snippets.

@gogl92
Created December 19, 2018 23:04
Show Gist options
  • Save gogl92/b8c4a90e8b213b5e7a3dc34bc609a311 to your computer and use it in GitHub Desktop.
Save gogl92/b8c4a90e8b213b5e7a3dc34bc609a311 to your computer and use it in GitHub Desktop.
Inquid Machine Learning
<?php
namespace app\components;
use yii\base\Component;
use Phpml\Classification\KNearestNeighbors;
class InquidML extends Component
{
public function example(){
$samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];
$labels = ['a', 'a', 'a', 'b', 'b', 'b'];
/*
* Persona A
* Persona B
*/
$classifier = new KNearestNeighbors();
$classifier->train($samples, $labels);
return $classifier->predict([2, 1]);
// return 'b'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment