mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-11 08:10:56 +00:00
cs fixer
This commit is contained in:
parent
e1854d44a2
commit
6296e44db0
@ -11,7 +11,6 @@ use Phpml\Helper\Optimizer\GD;
|
|||||||
use Phpml\Classification\Classifier;
|
use Phpml\Classification\Classifier;
|
||||||
use Phpml\Preprocessing\Normalizer;
|
use Phpml\Preprocessing\Normalizer;
|
||||||
use Phpml\IncrementalEstimator;
|
use Phpml\IncrementalEstimator;
|
||||||
use Phpml\Helper\PartiallyTrainable;
|
|
||||||
|
|
||||||
class Perceptron implements Classifier, IncrementalEstimator
|
class Perceptron implements Classifier, IncrementalEstimator
|
||||||
{
|
{
|
||||||
@ -95,7 +94,7 @@ class Perceptron implements Classifier, IncrementalEstimator
|
|||||||
* @param array $targets
|
* @param array $targets
|
||||||
* @param array $labels
|
* @param array $labels
|
||||||
*/
|
*/
|
||||||
public function partialTrain(array $samples, array $targets, array $labels = array())
|
public function partialTrain(array $samples, array $targets, array $labels = [])
|
||||||
{
|
{
|
||||||
return $this->trainByLabel($samples, $targets, $labels);
|
return $this->trainByLabel($samples, $targets, $labels);
|
||||||
}
|
}
|
||||||
@ -107,7 +106,6 @@ class Perceptron implements Classifier, IncrementalEstimator
|
|||||||
*/
|
*/
|
||||||
public function trainBinary(array $samples, array $targets, array $labels)
|
public function trainBinary(array $samples, array $targets, array $labels)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->normalizer) {
|
if ($this->normalizer) {
|
||||||
$this->normalizer->transform($samples);
|
$this->normalizer->transform($samples);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ trait OneVsRest
|
|||||||
* @param array $allLabels All training set labels
|
* @param array $allLabels All training set labels
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function trainByLabel(array $samples, array $targets, array $allLabels = array())
|
protected function trainByLabel(array $samples, array $targets, array $allLabels = [])
|
||||||
{
|
{
|
||||||
|
|
||||||
// Overwrites the current value if it exist. $allLabels must be provided for each partialTrain run.
|
// Overwrites the current value if it exist. $allLabels must be provided for each partialTrain run.
|
||||||
@ -129,14 +129,13 @@ trait OneVsRest
|
|||||||
*/
|
*/
|
||||||
private function binarizeTargets($targets, $label)
|
private function binarizeTargets($targets, $label)
|
||||||
{
|
{
|
||||||
|
|
||||||
$notLabel = "not_$label";
|
$notLabel = "not_$label";
|
||||||
foreach ($targets as $key => $target) {
|
foreach ($targets as $key => $target) {
|
||||||
$targets[$key] = $target == $label ? $label : $notLabel;
|
$targets[$key] = $target == $label ? $label : $notLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
$labels = array($label, $notLabel);
|
$labels = [$label, $notLabel];
|
||||||
return array($targets, $labels);
|
return [$targets, $labels];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,5 +12,5 @@ interface IncrementalEstimator
|
|||||||
* @param array $targets
|
* @param array $targets
|
||||||
* @param array $labels
|
* @param array $labels
|
||||||
*/
|
*/
|
||||||
public function partialTrain(array $samples, array $targets, array $labels = array());
|
public function partialTrain(array $samples, array $targets, array $labels = []);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ namespace Phpml\SupportVectorMachine;
|
|||||||
|
|
||||||
use Phpml\Helper\Trainable;
|
use Phpml\Helper\Trainable;
|
||||||
|
|
||||||
|
|
||||||
class SupportVectorMachine
|
class SupportVectorMachine
|
||||||
{
|
{
|
||||||
use Trainable;
|
use Trainable;
|
||||||
|
Loading…
Reference in New Issue
Block a user