Update dependecies and coding style fixes

This commit is contained in:
Arkadiusz Kondas 2017-03-05 16:45:48 +01:00
parent c6fbb83573
commit 39747efdc1
2 changed files with 97 additions and 100 deletions

178
composer.lock generated
View File

@ -251,27 +251,27 @@
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "v1.6.2", "version": "v1.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "6c52c2722f8460122f96f86346600e1077ce22cb" "reference": "93d39f1f7f9326d746203c7c056f300f7f126073"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073",
"reference": "6c52c2722f8460122f96f86346600e1077ce22cb", "reference": "93d39f1f7f9326d746203c7c056f300f7f126073",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/instantiator": "^1.0.2", "doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0", "php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2",
"sebastian/comparator": "^1.1", "sebastian/comparator": "^1.1|^2.0",
"sebastian/recursion-context": "^1.0|^2.0" "sebastian/recursion-context": "^1.0|^2.0|^3.0"
}, },
"require-dev": { "require-dev": {
"phpspec/phpspec": "^2.0", "phpspec/phpspec": "^2.5|^3.2",
"phpunit/phpunit": "^4.8 || ^5.6.5" "phpunit/phpunit": "^4.8 || ^5.6.5"
}, },
"type": "library", "type": "library",
@ -310,27 +310,29 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2016-11-21T14:58:47+00:00" "time": "2017-03-02T20:05:34+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "5.0.0", "version": "5.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "e7d7a4acca58e45bdfd00221563d131cfb04ba96" "reference": "531553c4795a1df54114342d68ca337d5d81c8a0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e7d7a4acca58e45bdfd00221563d131cfb04ba96", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/531553c4795a1df54114342d68ca337d5d81c8a0",
"reference": "e7d7a4acca58e45bdfd00221563d131cfb04ba96", "reference": "531553c4795a1df54114342d68ca337d5d81c8a0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*",
"ext-xmlwriter": "*",
"php": "^7.0", "php": "^7.0",
"phpunit/php-file-iterator": "^1.3", "phpunit/php-file-iterator": "^1.3",
"phpunit/php-text-template": "^1.2", "phpunit/php-text-template": "^1.2",
"phpunit/php-token-stream": "^1.4.2", "phpunit/php-token-stream": "^1.4.11 || ^2.0",
"sebastian/code-unit-reverse-lookup": "^1.0", "sebastian/code-unit-reverse-lookup": "^1.0",
"sebastian/environment": "^2.0", "sebastian/environment": "^2.0",
"sebastian/version": "^2.0" "sebastian/version": "^2.0"
@ -340,8 +342,7 @@
"phpunit/phpunit": "^6.0" "phpunit/phpunit": "^6.0"
}, },
"suggest": { "suggest": {
"ext-dom": "*", "ext-xdebug": "^2.5.1"
"ext-xmlwriter": "*"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -372,7 +373,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2017-02-02T10:35:41+00:00" "time": "2017-03-01T09:14:18+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -464,25 +465,30 @@
}, },
{ {
"name": "phpunit/php-timer", "name": "phpunit/php-timer",
"version": "1.0.8", "version": "1.0.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git", "url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
"reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": "^5.3.3 || ^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4|~5" "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": { "autoload": {
"classmap": [ "classmap": [
"src/" "src/"
@ -504,20 +510,20 @@
"keywords": [ "keywords": [
"timer" "timer"
], ],
"time": "2016-05-12T18:03:57+00:00" "time": "2017-02-26T11:10:40+00:00"
}, },
{ {
"name": "phpunit/php-token-stream", "name": "phpunit/php-token-stream",
"version": "1.4.9", "version": "1.4.11",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git", "url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "3b402f65a4cc90abf6e1104e388b896ce209631b" "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b", "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7",
"reference": "3b402f65a4cc90abf6e1104e388b896ce209631b", "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -553,20 +559,20 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"time": "2016-11-15T14:06:22+00:00" "time": "2017-02-27T10:12:30+00:00"
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "6.0.1", "version": "6.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "93a57ef4b0754737ac73604c5f51abf675d925d8" "reference": "47ee3fa1bca5c50f1d25105201eb20df777bd7b6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/93a57ef4b0754737ac73604c5f51abf675d925d8", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/47ee3fa1bca5c50f1d25105201eb20df777bd7b6",
"reference": "93a57ef4b0754737ac73604c5f51abf675d925d8", "reference": "47ee3fa1bca5c50f1d25105201eb20df777bd7b6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -583,12 +589,12 @@
"phpunit/php-text-template": "^1.2", "phpunit/php-text-template": "^1.2",
"phpunit/php-timer": "^1.0.6", "phpunit/php-timer": "^1.0.6",
"phpunit/phpunit-mock-objects": "^4.0", "phpunit/phpunit-mock-objects": "^4.0",
"sebastian/comparator": "^1.2.4", "sebastian/comparator": "^1.2.4 || ^2.0",
"sebastian/diff": "^1.2", "sebastian/diff": "^1.2",
"sebastian/environment": "^2.0", "sebastian/environment": "^2.0",
"sebastian/exporter": "^2.0", "sebastian/exporter": "^2.0 || ^3.0",
"sebastian/global-state": "^1.1", "sebastian/global-state": "^1.1 || ^2.0",
"sebastian/object-enumerator": "^2.0", "sebastian/object-enumerator": "^2.0 || ^3.0",
"sebastian/resource-operations": "^1.0", "sebastian/resource-operations": "^1.0",
"sebastian/version": "^2.0" "sebastian/version": "^2.0"
}, },
@ -635,27 +641,27 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2017-02-03T11:40:20+00:00" "time": "2017-03-02T15:24:03+00:00"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
"version": "4.0.0", "version": "4.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "3819745c44f3aff9518fd655f320c4535d541af7" "reference": "eabce450df194817a7d7e27e19013569a903a2bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3819745c44f3aff9518fd655f320c4535d541af7", "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/eabce450df194817a7d7e27e19013569a903a2bf",
"reference": "3819745c44f3aff9518fd655f320c4535d541af7", "reference": "eabce450df194817a7d7e27e19013569a903a2bf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/instantiator": "^1.0.2", "doctrine/instantiator": "^1.0.2",
"php": "^7.0", "php": "^7.0",
"phpunit/php-text-template": "^1.2", "phpunit/php-text-template": "^1.2",
"sebastian/exporter": "^2.0" "sebastian/exporter": "^3.0"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<6.0" "phpunit/phpunit": "<6.0"
@ -694,27 +700,27 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2017-02-02T10:36:38+00:00" "time": "2017-03-03T06:30:20+00:00"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",
"version": "1.0.0", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
"reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.6" "php": "^5.6 || ^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~5" "phpunit/phpunit": "^5.7 || ^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -739,34 +745,34 @@
], ],
"description": "Looks up which function or method a line of code belongs to", "description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2016-02-13T06:45:14+00:00" "time": "2017-03-04T06:30:41+00:00"
}, },
{ {
"name": "sebastian/comparator", "name": "sebastian/comparator",
"version": "1.2.4", "version": "2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git", "url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" "reference": "20f84f468cb67efee293246e6a09619b891f55f0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/20f84f468cb67efee293246e6a09619b891f55f0",
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "reference": "20f84f468cb67efee293246e6a09619b891f55f0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3", "php": "^7.0",
"sebastian/diff": "~1.2", "sebastian/diff": "^1.2",
"sebastian/exporter": "~1.2 || ~2.0" "sebastian/exporter": "^3.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.4" "phpunit/phpunit": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.2.x-dev" "dev-master": "2.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -803,7 +809,7 @@
"compare", "compare",
"equality" "equality"
], ],
"time": "2017-01-29T09:50:25+00:00" "time": "2017-03-03T06:26:08+00:00"
}, },
{ {
"name": "sebastian/diff", "name": "sebastian/diff",
@ -909,30 +915,30 @@
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",
"version": "2.0.0", "version": "3.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git", "url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" "reference": "b82d077cb3459e393abcf4867ae8f7230dcb51f6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/b82d077cb3459e393abcf4867ae8f7230dcb51f6",
"reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", "reference": "b82d077cb3459e393abcf4867ae8f7230dcb51f6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3", "php": "^7.0",
"sebastian/recursion-context": "~2.0" "sebastian/recursion-context": "^3.0"
}, },
"require-dev": { "require-dev": {
"ext-mbstring": "*", "ext-mbstring": "*",
"phpunit/phpunit": "~4.4" "phpunit/phpunit": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "3.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -972,7 +978,7 @@
"export", "export",
"exporter" "exporter"
], ],
"time": "2016-11-19T08:54:04+00:00" "time": "2017-03-03T06:25:06+00:00"
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
@ -1027,29 +1033,29 @@
}, },
{ {
"name": "sebastian/object-enumerator", "name": "sebastian/object-enumerator",
"version": "2.0.0", "version": "3.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git", "url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35" "reference": "de6e32f7192dfea2e4bedc892434f4830b5c5794"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/de6e32f7192dfea2e4bedc892434f4830b5c5794",
"reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", "reference": "de6e32f7192dfea2e4bedc892434f4830b5c5794",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.6", "php": "^7.0",
"sebastian/recursion-context": "~2.0" "sebastian/recursion-context": "^3.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~5" "phpunit/phpunit": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "3.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -1069,32 +1075,32 @@
], ],
"description": "Traverses array structures and object graphs to enumerate all referenced objects", "description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/", "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2016-11-19T07:35:10+00:00" "time": "2017-03-03T06:21:01+00:00"
}, },
{ {
"name": "sebastian/recursion-context", "name": "sebastian/recursion-context",
"version": "2.0.0", "version": "3.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git", "url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8",
"reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": "^7.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.4" "phpunit/phpunit": "^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "3.0.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -1122,7 +1128,7 @@
], ],
"description": "Provides functionality to recursively process PHP variables", "description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context", "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2016-11-19T07:33:16+00:00" "time": "2017-03-03T06:23:57+00:00"
}, },
{ {
"name": "sebastian/resource-operations", "name": "sebastian/resource-operations",

View File

@ -25,15 +25,6 @@ class DecisionStump extends WeightedClassifier
*/ */
protected $binaryLabels; protected $binaryLabels;
/**
* Sample weights : If used the optimization on the decision value
* will take these weights into account. If not given, all samples
* will be weighed with the same value of 1
*
* @var array
*/
protected $weights = null;
/** /**
* Lowest error rate obtained while training/optimizing the model * Lowest error rate obtained while training/optimizing the model
* *
@ -96,6 +87,7 @@ class DecisionStump extends WeightedClassifier
/** /**
* @param array $samples * @param array $samples
* @param array $targets * @param array $targets
* @throws \Exception
*/ */
protected function trainBinary(array $samples, array $targets) protected function trainBinary(array $samples, array $targets)
{ {
@ -213,12 +205,11 @@ class DecisionStump extends WeightedClassifier
} }
/** /**
*
* @param int $col * @param int $col
* *
* @return array * @return array
*/ */
protected function getBestNominalSplit(int $col) protected function getBestNominalSplit(int $col) : array
{ {
$values = array_column($this->samples, $col); $values = array_column($this->samples, $col);
$valueCounts = array_count_values($values); $valueCounts = array_count_values($values);
@ -235,7 +226,7 @@ class DecisionStump extends WeightedClassifier
'prob' => $prob, 'column' => $col, 'prob' => $prob, 'column' => $col,
'trainingErrorRate' => $errorRate]; 'trainingErrorRate' => $errorRate];
} }
}// for }
} }
return $split; return $split;
@ -275,7 +266,7 @@ class DecisionStump extends WeightedClassifier
* *
* @return array * @return array
*/ */
protected function calculateErrorRate(float $threshold, string $operator, array $values) protected function calculateErrorRate(float $threshold, string $operator, array $values) : array
{ {
$wrong = 0.0; $wrong = 0.0;
$prob = []; $prob = [];
@ -325,7 +316,7 @@ class DecisionStump extends WeightedClassifier
* *
* @return float * @return float
*/ */
protected function predictProbability(array $sample, $label) protected function predictProbability(array $sample, $label) : float
{ {
$predicted = $this->predictSampleBinary($sample); $predicted = $this->predictSampleBinary($sample);
if (strval($predicted) == strval($label)) { if (strval($predicted) == strval($label)) {