From 6296e44db08a9f8677cd3a1e5f216845e4ead3d9 Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Wed, 19 Apr 2017 22:28:07 +0200 Subject: [PATCH] cs fixer --- src/Phpml/Classification/Linear/Perceptron.php | 4 +--- src/Phpml/Helper/OneVsRest.php | 7 +++---- src/Phpml/IncrementalEstimator.php | 2 +- src/Phpml/SupportVectorMachine/SupportVectorMachine.php | 7 +++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Phpml/Classification/Linear/Perceptron.php b/src/Phpml/Classification/Linear/Perceptron.php index 2cf96cc..91ffacf 100644 --- a/src/Phpml/Classification/Linear/Perceptron.php +++ b/src/Phpml/Classification/Linear/Perceptron.php @@ -11,7 +11,6 @@ use Phpml\Helper\Optimizer\GD; use Phpml\Classification\Classifier; use Phpml\Preprocessing\Normalizer; use Phpml\IncrementalEstimator; -use Phpml\Helper\PartiallyTrainable; class Perceptron implements Classifier, IncrementalEstimator { @@ -95,7 +94,7 @@ class Perceptron implements Classifier, IncrementalEstimator * @param array $targets * @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); } @@ -107,7 +106,6 @@ class Perceptron implements Classifier, IncrementalEstimator */ public function trainBinary(array $samples, array $targets, array $labels) { - if ($this->normalizer) { $this->normalizer->transform($samples); } diff --git a/src/Phpml/Helper/OneVsRest.php b/src/Phpml/Helper/OneVsRest.php index 98269cd..e207c46 100644 --- a/src/Phpml/Helper/OneVsRest.php +++ b/src/Phpml/Helper/OneVsRest.php @@ -44,7 +44,7 @@ trait OneVsRest * @param array $allLabels All training set labels * @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. @@ -129,14 +129,13 @@ trait OneVsRest */ private function binarizeTargets($targets, $label) { - $notLabel = "not_$label"; foreach ($targets as $key => $target) { $targets[$key] = $target == $label ? $label : $notLabel; } - $labels = array($label, $notLabel); - return array($targets, $labels); + $labels = [$label, $notLabel]; + return [$targets, $labels]; } diff --git a/src/Phpml/IncrementalEstimator.php b/src/Phpml/IncrementalEstimator.php index df18872..fc6912d 100644 --- a/src/Phpml/IncrementalEstimator.php +++ b/src/Phpml/IncrementalEstimator.php @@ -12,5 +12,5 @@ interface IncrementalEstimator * @param array $targets * @param array $labels */ - public function partialTrain(array $samples, array $targets, array $labels = array()); + public function partialTrain(array $samples, array $targets, array $labels = []); } diff --git a/src/Phpml/SupportVectorMachine/SupportVectorMachine.php b/src/Phpml/SupportVectorMachine/SupportVectorMachine.php index 27b9e5a..f3828b4 100644 --- a/src/Phpml/SupportVectorMachine/SupportVectorMachine.php +++ b/src/Phpml/SupportVectorMachine/SupportVectorMachine.php @@ -6,12 +6,11 @@ namespace Phpml\SupportVectorMachine; use Phpml\Helper\Trainable; - class SupportVectorMachine { - use Trainable; - - /** + use Trainable; + + /** * @var int */ private $type;