PHP Class Phpml\Classification\KNearestNeighbors

Inheritance: implements Classifier, use trait Phpml\Helper\Trainable, use trait Phpml\Helper\Predictable
Mostra file Open project: php-ai/php-ml Class Usage Examples

Public Methods

Method Description
__construct ( integer $k = 3, Phpml\Math\Distance $distanceMetric = null )

Protected Methods

Method Description
predictSample ( array $sample ) : mixed

Private Methods

Method Description
kNeighborsDistances ( array $sample ) : array

Method Details

__construct() public method

public __construct ( integer $k = 3, Phpml\Math\Distance $distanceMetric = null )
$k integer
$distanceMetric Phpml\Math\Distance (if null then Euclidean distance as default)

predictSample() protected method

protected predictSample ( array $sample ) : mixed
$sample array
return mixed