Add PHPStan and level to max (#168)

* tests: update to PHPUnit 6.0 with rector

* fix namespaces on tests

* composer + tests: use standard test namespace naming

* update travis

* resolve conflict

* phpstan lvl 2

* phpstan lvl 3

* phpstan lvl 4

* phpstan lvl 5

* phpstan lvl 6

* phpstan lvl 7

* level max

* resolve conflict

* [cs] clean empty docs

* composer: bump to PHPUnit 6.4

* cleanup

* composer + travis: add phpstan

* phpstan lvl 1

* composer: update dev deps

* phpstan fixes

* update Contributing with new tools

* docs: link fixes, PHP version update

* composer: drop php-cs-fixer, cs already handled by ecs

* ecs: add old set rules

* [cs] apply rest of rules
This commit is contained in:
Tomáš Votruba 2018-01-06 13:09:33 +01:00 committed by Arkadiusz Kondas
parent fbbe5c5761
commit a348111e97
103 changed files with 365 additions and 284 deletions

32
.php_cs
View File

@ -1,32 +0,0 @@
<?php
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
'cast_spaces' => true,
'concat_space' => ['spacing' => 'none'],
'declare_strict_types' => true,
'method_separation' => true,
'no_blank_lines_after_class_opening' => true,
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'phpdoc_align' => true,
'phpdoc_no_access' => true,
'phpdoc_separation' => true,
'pre_increment' => true,
'single_quote' => true,
'trim_array_spaces' => true,
'single_blank_line_before_namespace' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
)
->setRiskyAllowed(true)
->setUsingCache(false);

View File

@ -31,6 +31,7 @@ install:
script: script:
- vendor/bin/phpunit $PHPUNIT_FLAGS - vendor/bin/phpunit $PHPUNIT_FLAGS
- if [[ $STATIC_ANALYSIS != "" ]]; then vendor/bin/ecs check src tests; fi - if [[ $STATIC_ANALYSIS != "" ]]; then vendor/bin/ecs check src tests; fi
- if [[ $STATIC_ANALYSIS != "" ]]; then vendor/bin/phpstan.phar analyse src tests --level max --configuration phpstan.neon; fi
after_success: after_success:
- | - |

View File

@ -6,31 +6,40 @@ code base clean, unified and future proof.
## Branch ## Branch
You should only open pull requests against the master branch. You should only open pull requests against the `master` branch.
## Unit-Tests ## Unit-Tests
Please try to add a test for your pull-request. You can run the unit-tests by calling: Please try to add a test for your pull-request. You can run the unit-tests by calling:
``` ```bash
bin/phpunit vendor/bin/phpunit
``` ```
## Travis ## Travis
GitHub automatically run your pull request through Travis CI against PHP 7. GitHub automatically run your pull request through Travis CI.
If you break the tests, I cannot merge your code, so please make sure that your code is working If you break the tests, I cannot merge your code, so please make sure that your code is working before opening up a Pull-Request.
before opening up a Pull-Request.
## Merge ## Merge
Please allow me time to review your pull requests. I will give my best to review everything as fast as possible, but cannot always live up to my own expectations. Please allow me time to review your pull requests. I will give my best to review everything as fast as possible, but cannot always live up to my own expectations.
## Coding Standards ## Coding Standards & Static Analysis
When contributing code to PHP-ML, you must follow its coding standards. It's as easy as executing `./bin/php-cs-fixer fix` in root directory. When contributing code to PHP-ML, you must follow its coding standards. To do that, just run:
```bash
vendor/bin/ecs check src tests --fix
```
[More about EasyCodingStandard](https://github.com/Symplify/EasyCodingStandard)
Code has to also pass static analysis by [PHPStan](https://github.com/phpstan/phpstan):
```bash
vendor/bin/phpstan.phar analyse src tests --level max --configuration phpstan.neon
```
More about PHP-CS-Fixer: [http://cs.sensiolabs.org/](http://cs.sensiolabs.org/)
## Documentation ## Documentation

View File

@ -11,19 +11,24 @@
"email": "arkadiusz.kondas@gmail.com" "email": "arkadiusz.kondas@gmail.com"
} }
], ],
"autoload": {
"psr-4": {
"Phpml\\": "src/Phpml"
}
},
"require": { "require": {
"php": "^7.1" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6.4", "phpunit/phpunit": "^6.4",
"friendsofphp/php-cs-fixer": "^2.4", "symplify/easy-coding-standard": "v3.0.0-RC3",
"symplify/easy-coding-standard": "dev-master as 2.5", "symplify/coding-standard": "v3.0.0-RC3",
"symplify/coding-standard": "dev-master as 2.5", "symplify/package-builder": "v3.0.0-RC3",
"symplify/package-builder": "dev-master#3604bea as 2.5" "phpstan/phpstan-shim": "^0.8"
},
"autoload": {
"psr-4": {
"Phpml\\": "src/Phpml"
}
},
"autoload-dev": {
"psr-4": {
"Phpml\\Tests\\": "tests/Phpml"
}
} }
} }

184
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "0b709f785c1e62498755f557e49e1ba4", "content-hash": "032ab1160f58aff496453a86648f7012",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {
@ -247,16 +247,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v2.8.1", "version": "v2.8.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "04f71e56e03ba2627e345e8c949c80dcef0e683e" "reference": "b331701944cbe492e466d2b46b2880068803eb08"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/04f71e56e03ba2627e345e8c949c80dcef0e683e", "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/b331701944cbe492e466d2b46b2880068803eb08",
"reference": "04f71e56e03ba2627e345e8c949c80dcef0e683e", "reference": "b331701944cbe492e466d2b46b2880068803eb08",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -323,7 +323,7 @@
} }
], ],
"description": "A tool to automatically fix PHP code style", "description": "A tool to automatically fix PHP code style",
"time": "2017-11-09T13:31:39+00:00" "time": "2017-11-19T22:51:25+00:00"
}, },
{ {
"name": "gecko-packages/gecko-php-unit", "name": "gecko-packages/gecko-php-unit",
@ -1219,16 +1219,16 @@
}, },
{ {
"name": "phpspec/prophecy", "name": "phpspec/prophecy",
"version": "v1.7.2", "version": "1.7.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpspec/prophecy.git", "url": "https://github.com/phpspec/prophecy.git",
"reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
"reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1240,7 +1240,7 @@
}, },
"require-dev": { "require-dev": {
"phpspec/phpspec": "^2.5|^3.2", "phpspec/phpspec": "^2.5|^3.2",
"phpunit/phpunit": "^4.8 || ^5.6.5" "phpunit/phpunit": "^4.8.35 || ^5.7"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1278,7 +1278,43 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2017-09-04T11:05:03+00:00" "time": "2017-11-24T13:59:53+00:00"
},
{
"name": "phpstan/phpstan-shim",
"version": "0.8.5",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-shim.git",
"reference": "0b174a61fd99dea61f15ea6bd3bc424389f273d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-shim/zipball/0b174a61fd99dea61f15ea6bd3bc424389f273d4",
"reference": "0b174a61fd99dea61f15ea6bd3bc424389f273d4",
"shasum": ""
},
"require": {
"php": "~7.0"
},
"provide": {
"phpstan/phpstan": "0.8"
},
"bin": [
"phpstan.phar"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.8-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan Phar distribution",
"time": "2017-10-24T04:16:00+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -1346,16 +1382,16 @@
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
"version": "1.4.2", "version": "1.4.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" "reference": "8ebba84e5bd74fc5fdeb916b38749016c7232f93"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/8ebba84e5bd74fc5fdeb916b38749016c7232f93",
"reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "reference": "8ebba84e5bd74fc5fdeb916b38749016c7232f93",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1389,7 +1425,7 @@
"filesystem", "filesystem",
"iterator" "iterator"
], ],
"time": "2016-10-03T07:40:28+00:00" "time": "2017-11-24T15:00:59+00:00"
}, },
{ {
"name": "phpunit/php-text-template", "name": "phpunit/php-text-template",
@ -2418,7 +2454,7 @@
}, },
{ {
"name": "symfony/config", "name": "symfony/config",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/config.git", "url": "https://github.com/symfony/config.git",
@ -2480,16 +2516,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "099302cc53e57cbb7414fd9f3ace40e5e2767c0b" "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/099302cc53e57cbb7414fd9f3ace40e5e2767c0b", "url": "https://api.github.com/repos/symfony/console/zipball/63cd7960a0a522c3537f6326706d7f3b8de65805",
"reference": "099302cc53e57cbb7414fd9f3ace40e5e2767c0b", "reference": "63cd7960a0a522c3537f6326706d7f3b8de65805",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2544,11 +2580,11 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-12T16:53:41+00:00" "time": "2017-11-16T15:24:32+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
@ -2604,7 +2640,7 @@
}, },
{ {
"name": "symfony/dependency-injection", "name": "symfony/dependency-injection",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/dependency-injection.git", "url": "https://github.com/symfony/dependency-injection.git",
@ -2674,7 +2710,7 @@
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
@ -2737,7 +2773,7 @@
}, },
{ {
"name": "symfony/filesystem", "name": "symfony/filesystem",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/filesystem.git", "url": "https://github.com/symfony/filesystem.git",
@ -2786,7 +2822,7 @@
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
@ -2835,7 +2871,7 @@
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
@ -2888,16 +2924,16 @@
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "371ed63691c1ee8749613a6b48cf0e0cfa2b01e7" "reference": "a2a942172b742217ab2ccd9399494af2aa17c766"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/371ed63691c1ee8749613a6b48cf0e0cfa2b01e7", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/a2a942172b742217ab2ccd9399494af2aa17c766",
"reference": "371ed63691c1ee8749613a6b48cf0e0cfa2b01e7", "reference": "a2a942172b742217ab2ccd9399494af2aa17c766",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2970,11 +3006,11 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-11-13T19:37:21+00:00" "time": "2017-11-16T18:14:43+00:00"
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/options-resolver.git", "url": "https://github.com/symfony/options-resolver.git",
@ -3201,7 +3237,7 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
@ -3250,7 +3286,7 @@
}, },
{ {
"name": "symfony/stopwatch", "name": "symfony/stopwatch",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/stopwatch.git", "url": "https://github.com/symfony/stopwatch.git",
@ -3299,7 +3335,7 @@
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.3.12", "version": "v3.3.13",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",
@ -3354,16 +3390,16 @@
}, },
{ {
"name": "symplify/coding-standard", "name": "symplify/coding-standard",
"version": "dev-master", "version": "v3.0.0-RC3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Symplify/CodingStandard.git", "url": "https://github.com/Symplify/CodingStandard.git",
"reference": "309fd562066cdc86b81375ff080b1ee2f900778e" "reference": "0a3958f1cb6ce733def98f3abdf52a4e6c723879"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Symplify/CodingStandard/zipball/309fd562066cdc86b81375ff080b1ee2f900778e", "url": "https://api.github.com/repos/Symplify/CodingStandard/zipball/0a3958f1cb6ce733def98f3abdf52a4e6c723879",
"reference": "309fd562066cdc86b81375ff080b1ee2f900778e", "reference": "0a3958f1cb6ce733def98f3abdf52a4e6c723879",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3382,6 +3418,11 @@
"symplify/package-builder": "^2.5|^3.0" "symplify/package-builder": "^2.5|^3.0"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symplify\\CodingStandard\\": "src", "Symplify\\CodingStandard\\": "src",
@ -3394,20 +3435,20 @@
"MIT" "MIT"
], ],
"description": "Set of Symplify rules for PHP_CodeSniffer.", "description": "Set of Symplify rules for PHP_CodeSniffer.",
"time": "2017-11-16 00:38:24" "time": "2017-11-18T01:05:00+00:00"
}, },
{ {
"name": "symplify/easy-coding-standard", "name": "symplify/easy-coding-standard",
"version": "dev-master", "version": "v3.0.0-RC3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Symplify/EasyCodingStandard.git", "url": "https://github.com/Symplify/EasyCodingStandard.git",
"reference": "4bac5271050f063b4455bd870cc215e0db57ddf8" "reference": "7f2e7728a184c72945da482b23eb05b796f6502c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Symplify/EasyCodingStandard/zipball/4bac5271050f063b4455bd870cc215e0db57ddf8", "url": "https://api.github.com/repos/Symplify/EasyCodingStandard/zipball/7f2e7728a184c72945da482b23eb05b796f6502c",
"reference": "4bac5271050f063b4455bd870cc215e0db57ddf8", "reference": "7f2e7728a184c72945da482b23eb05b796f6502c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3440,6 +3481,11 @@
"bin/easy-coding-standard.php" "bin/easy-coding-standard.php"
], ],
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symplify\\EasyCodingStandard\\": "src", "Symplify\\EasyCodingStandard\\": "src",
@ -3455,20 +3501,20 @@
"MIT" "MIT"
], ],
"description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer.", "description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer.",
"time": "2017-11-16 15:36:21" "time": "2017-11-18T14:13:17+00:00"
}, },
{ {
"name": "symplify/package-builder", "name": "symplify/package-builder",
"version": "dev-master", "version": "v3.0.0-RC3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Symplify/PackageBuilder.git", "url": "https://github.com/Symplify/PackageBuilder.git",
"reference": "3604beadddfdee295b978d87475a834810a0ffd4" "reference": "c86f75165ed2370563a9d4ff6604bbb24cffd5e5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Symplify/PackageBuilder/zipball/3604beadddfdee295b978d87475a834810a0ffd4", "url": "https://api.github.com/repos/Symplify/PackageBuilder/zipball/c86f75165ed2370563a9d4ff6604bbb24cffd5e5",
"reference": "3604beadddfdee295b978d87475a834810a0ffd4", "reference": "c86f75165ed2370563a9d4ff6604bbb24cffd5e5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3486,6 +3532,11 @@
"tracy/tracy": "^2.4" "tracy/tracy": "^2.4"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symplify\\PackageBuilder\\": "src" "Symplify\\PackageBuilder\\": "src"
@ -3496,7 +3547,7 @@
"MIT" "MIT"
], ],
"description": "Dependency Injection, Console and Kernel toolkit for Symplify packages.", "description": "Dependency Injection, Console and Kernel toolkit for Symplify packages.",
"time": "2017-11-16T01:05:48+00:00" "time": "2017-11-17T13:58:38+00:00"
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
@ -3656,31 +3707,12 @@
"time": "2016-11-23T20:04:58+00:00" "time": "2016-11-23T20:04:58+00:00"
} }
], ],
"aliases": [ "aliases": [],
{
"alias": "2.5",
"alias_normalized": "2.5.0.0",
"version": "9999999-dev",
"package": "symplify/easy-coding-standard"
},
{
"alias": "2.5",
"alias_normalized": "2.5.0.0",
"version": "9999999-dev",
"package": "symplify/coding-standard"
},
{
"alias": "2.5",
"alias_normalized": "2.5.0.0",
"version": "9999999-dev",
"package": "symplify/package-builder"
}
],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"symplify/easy-coding-standard": 20, "symplify/easy-coding-standard": 5,
"symplify/coding-standard": 20, "symplify/coding-standard": 5,
"symplify/package-builder": 20 "symplify/package-builder": 5
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,

View File

@ -17,11 +17,11 @@
Fresh approach to Machine Learning in PHP. Algorithms, Cross Validation, Neural Network, Preprocessing, Feature Extraction and much more in one library. Fresh approach to Machine Learning in PHP. Algorithms, Cross Validation, Neural Network, Preprocessing, Feature Extraction and much more in one library.
PHP-ML requires PHP >= 7.0. PHP-ML requires PHP >= 7.1.
Simple example of classification: Simple example of classification:
```php ```php
require_once 'vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
use Phpml\Classification\KNearestNeighbors; use Phpml\Classification\KNearestNeighbors;
@ -54,57 +54,57 @@ Example scripts are available in a separate repository [php-ai/php-ml-examples](
## Features ## Features
* Association rule Lerning * Association rule Lerning
* [Apriori](machine-learning/association/apriori/) * [Apriori](machine-learning/association/apriori.md)
* Classification * Classification
* [SVC](machine-learning/classification/svc/) * [SVC](machine-learning/classification/svc.md)
* [k-Nearest Neighbors](machine-learning/classification/k-nearest-neighbors/) * [k-Nearest Neighbors](machine-learning/classification/k-nearest-neighbors.md)
* [Naive Bayes](machine-learning/classification/naive-bayes/) * [Naive Bayes](machine-learning/classification/naive-bayes.md)
* Regression * Regression
* [Least Squares](machine-learning/regression/least-squares/) * [Least Squares](machine-learning/regression/least-squares.md)
* [SVR](machine-learning/regression/svr/) * [SVR](machine-learning/regression/svr.md)
* Clustering * Clustering
* [k-Means](machine-learning/clustering/k-means/) * [k-Means](machine-learning/clustering/k-means.md)
* [DBSCAN](machine-learning/clustering/dbscan/) * [DBSCAN](machine-learning/clustering/dbscan.md)
* Metric * Metric
* [Accuracy](machine-learning/metric/accuracy/) * [Accuracy](machine-learning/metric/accuracy.md)
* [Confusion Matrix](machine-learning/metric/confusion-matrix/) * [Confusion Matrix](machine-learning/metric/confusion-matrix.md)
* [Classification Report](machine-learning/metric/classification-report/) * [Classification Report](machine-learning/metric/classification-report.md)
* Workflow * Workflow
* [Pipeline](machine-learning/workflow/pipeline) * [Pipeline](machine-learning/workflow/pipeline)
* Neural Network * Neural Network
* [Multilayer Perceptron Classifier](machine-learning/neural-network/multilayer-perceptron-classifier/) * [Multilayer Perceptron Classifier](machine-learning/neural-network/multilayer-perceptron-classifier.md)
* Cross Validation * Cross Validation
* [Random Split](machine-learning/cross-validation/random-split/) * [Random Split](machine-learning/cross-validation/random-split.md)
* [Stratified Random Split](machine-learning/cross-validation/stratified-random-split/) * [Stratified Random Split](machine-learning/cross-validation/stratified-random-split.md)
* Preprocessing * Preprocessing
* [Normalization](machine-learning/preprocessing/normalization/) * [Normalization](machine-learning/preprocessing/normalization.md)
* [Imputation missing values](machine-learning/preprocessing/imputation-missing-values/) * [Imputation missing values](machine-learning/preprocessing/imputation-missing-values.md)
* Feature Extraction * Feature Extraction
* [Token Count Vectorizer](machine-learning/feature-extraction/token-count-vectorizer/) * [Token Count Vectorizer](machine-learning/feature-extraction/token-count-vectorizer.md)
* [Tf-idf Transformer](machine-learning/feature-extraction/tf-idf-transformer/) * [Tf-idf Transformer](machine-learning/feature-extraction/tf-idf-transformer.md)
* Datasets * Datasets
* [Array](machine-learning/datasets/array-dataset/) * [Array](machine-learning/datasets/array-dataset.md)
* [CSV](machine-learning/datasets/csv-dataset/) * [CSV](machine-learning/datasets/csv-dataset.md)
* [Files](machine-learning/datasets/files-dataset/) * [Files](machine-learning/datasets/files-dataset.md)
* Ready to use: * Ready to use:
* [Iris](machine-learning/datasets/demo/iris/) * [Iris](machine-learning/datasets/demo/iris.md)
* [Wine](machine-learning/datasets/demo/wine/) * [Wine](machine-learning/datasets/demo/wine.md)
* [Glass](machine-learning/datasets/demo/glass/) * [Glass](machine-learning/datasets/demo/glass.md)
* Models management * Models management
* [Persistency](machine-learning/model-manager/persistency/) * [Persistency](machine-learning/model-manager/persistency.md)
* Math * Math
* [Distance](math/distance/) * [Distance](math/distance.md)
* [Matrix](math/matrix/) * [Matrix](math/matrix.md)
* [Set](math/set/) * [Set](math/set.md)
* [Statistic](math/statistic/) * [Statistic](math/statistic.md)
## Contribute ## Contribute
- Issue Tracker: github.com/php-ai/php-ml/issues - Issue Tracker: [github.com/php-ai/php-ml/issues](https://github.com/php-ai/php-ml/issues)
- Source Code: github.com/php-ai/php-ml - Source Code: [github.com/php-ai/php-ml](https://github.com/php-ai/php-ml)
You can find more about contributing in [CONTRIBUTING.md](CONTRIBUTING.md). You can find more about contributing in [CONTRIBUTING.md](../CONTRIBUTING.md).
## License ## License

View File

@ -11,6 +11,25 @@ includes:
#- vendor/symplify/easy-coding-standard/config/common/strict.neon #- vendor/symplify/easy-coding-standard/config/common/strict.neon
checkers: checkers:
# spacing
- PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer
- PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer
- PhpCsFixer\Fixer\CastNotation\CastSpacesFixer
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
spacing: none
- PhpCsFixer\Fixer\ClassNotation\MethodSeparationFixer
- PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer
PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer:
positions: ['inside', 'outside']
PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer:
align_double_arrow: false
align_equals: false
# phpdoc
- PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer
- PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer
# Symplify
- Symplify\CodingStandard\Fixer\Import\ImportNamespacedNameFixer - Symplify\CodingStandard\Fixer\Import\ImportNamespacedNameFixer
- Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer - Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer
- Symplify\CodingStandard\Fixer\Property\ArrayPropertyDefaultValueFixer - Symplify\CodingStandard\Fixer\Property\ArrayPropertyDefaultValueFixer

19
phpstan.neon Normal file
View File

@ -0,0 +1,19 @@
parameters:
ignoreErrors:
- '#Phpml\\Dataset\\FilesDataset::__construct\(\) does not call parent constructor from Phpml\\Dataset\\ArrayDataset#'
- '#Parameter \#2 \$predictedLabels of static method Phpml\\Metric\\Accuracy::score\(\) expects mixed\[\], mixed\[\]\|string given#'
# should be always defined
- '#Undefined variable: \$j#'
# bugged
- '#expects [a-z\\\|\[\]]*, [a-z\\\|\(\)\[\]]*\[\] given#'
# mock
- '#Parameter \#1 \$node of class Phpml\\NeuralNetwork\\Node\\Neuron\\Synapse constructor expects Phpml\\NeuralNetwork\\Node, Phpml\\NeuralNetwork\\Node\\Neuron\|PHPUnit_Framework_MockObject_MockObject given#'
- '#Parameter \#1 \$(activationFunction|synapse) of class Phpml\\NeuralNetwork\\Node\\Neuron constructor expects Phpml\\NeuralNetwork\\ActivationFunction|null, Phpml\\NeuralNetwork\\ActivationFunction\\BinaryStep|PHPUnit_Framework_MockObject_MockObject given#'
# probably known value
- '#Method Phpml\\Classification\\DecisionTree::getBestSplit\(\) should return Phpml\\Classification\\DecisionTree\\DecisionTreeLeaf but returns Phpml\\Classification\\DecisionTree\\DecisionTreeLeaf\|null#'
- '#Method Phpml\\Classification\\Linear\\DecisionStump::getBestNumericalSplit\(\) should return mixed\[\] but returns \(float\|int\|mixed\|string\)\[\]\|null#'
- '#Method Phpml\\Classification\\Linear\\DecisionStump::getBestNominalSplit\(\) should return mixed\[\] but returns mixed\[\]\|null#'

View File

@ -244,6 +244,7 @@ class Apriori implements Associator
foreach ((array) $this->samples as $sample) { foreach ((array) $this->samples as $sample) {
if ($this->subset($sample, $candidate)) { if ($this->subset($sample, $candidate)) {
$candidates[] = $candidate; $candidates[] = $candidate;
continue 2; continue 2;
} }
} }

View File

@ -59,14 +59,14 @@ class DecisionTree implements Classifier
private $selectedFeatures = []; private $selectedFeatures = [];
/** /**
* @var array * @var array|null
*/ */
private $featureImportances = null; private $featureImportances;
/** /**
* @var array * @var array|null
*/ */
private $columnNames = null; private $columnNames;
public function __construct(int $maxDepth = 10) public function __construct(int $maxDepth = 10)
{ {

View File

@ -9,7 +9,7 @@ use Phpml\Math\Comparison;
class DecisionTreeLeaf class DecisionTreeLeaf
{ {
/** /**
* @var string * @var string|int
*/ */
public $value; public $value;
@ -52,7 +52,7 @@ class DecisionTreeLeaf
public $classValue = ''; public $classValue = '';
/** /**
* @var bool * @var bool|int
*/ */
public $isTerminal = false; public $isTerminal = false;

View File

@ -31,7 +31,7 @@ class Bagging implements Classifier
protected $numClassifier; protected $numClassifier;
/** /**
* @var Classifier * @var string
*/ */
protected $classifier = DecisionTree::class; protected $classifier = DecisionTree::class;

View File

@ -21,7 +21,7 @@ class Adaline extends Perceptron
/** /**
* Training type may be either 'Batch' or 'Online' learning * Training type may be either 'Batch' or 'Online' learning
* *
* @var string * @var string|int
*/ */
protected $trainingType; protected $trainingType;

View File

@ -224,7 +224,7 @@ class DecisionStump extends WeightedClassifier
foreach ($distinctVals as $val) { foreach ($distinctVals as $val) {
[$errorRate, $prob] = $this->calculateErrorRate($targets, $val, $operator, $values); [$errorRate, $prob] = $this->calculateErrorRate($targets, $val, $operator, $values);
if ($split == null || $split['trainingErrorRate'] < $errorRate) { if ($split === null || $split['trainingErrorRate'] < $errorRate) {
$split = [ $split = [
'value' => $val, 'value' => $val,
'operator' => $operator, 'operator' => $operator,

View File

@ -119,19 +119,25 @@ class LogisticRegression extends Adaline
* *
* @throws \Exception * @throws \Exception
*/ */
protected function runTraining(array $samples, array $targets) protected function runTraining(array $samples, array $targets): void
{ {
$callback = $this->getCostFunction(); $callback = $this->getCostFunction();
switch ($this->trainingType) { switch ($this->trainingType) {
case self::BATCH_TRAINING: case self::BATCH_TRAINING:
return $this->runGradientDescent($samples, $targets, $callback, true); $this->runGradientDescent($samples, $targets, $callback, true);
return;
case self::ONLINE_TRAINING: case self::ONLINE_TRAINING:
return $this->runGradientDescent($samples, $targets, $callback, false); $this->runGradientDescent($samples, $targets, $callback, false);
return;
case self::CONJUGATE_GRAD_TRAINING: case self::CONJUGATE_GRAD_TRAINING:
return $this->runConjugateGradient($samples, $targets, $callback); $this->runConjugateGradient($samples, $targets, $callback);
return;
default: default:
throw new Exception('Logistic regression has invalid training type: %s.', $this->trainingType); throw new Exception('Logistic regression has invalid training type: %s.', $this->trainingType);
@ -143,7 +149,7 @@ class LogisticRegression extends Adaline
*/ */
protected function runConjugateGradient(array $samples, array $targets, Closure $gradientFunc): void protected function runConjugateGradient(array $samples, array $targets, Closure $gradientFunc): void
{ {
if (empty($this->optimizer)) { if ($this->optimizer === null) {
$this->optimizer = (new ConjugateGradient($this->featureCount)) $this->optimizer = (new ConjugateGradient($this->featureCount))
->setMaxIterations($this->maxIterations); ->setMaxIterations($this->maxIterations);
} }

View File

@ -19,7 +19,7 @@ class Perceptron implements Classifier, IncrementalEstimator
use Predictable, OneVsRest; use Predictable, OneVsRest;
/** /**
* @var \Phpml\Helper\Optimizer\Optimizer * @var \Phpml\Helper\Optimizer\Optimizer|GD|StochasticGD|null
*/ */
protected $optimizer; protected $optimizer;
@ -34,7 +34,7 @@ class Perceptron implements Classifier, IncrementalEstimator
protected $featureCount = 0; protected $featureCount = 0;
/** /**
* @var array * @var array|null
*/ */
protected $weights = []; protected $weights = [];
@ -67,8 +67,8 @@ class Perceptron implements Classifier, IncrementalEstimator
* Initalize a perceptron classifier with given learning rate and maximum * Initalize a perceptron classifier with given learning rate and maximum
* number of iterations used while training the perceptron * number of iterations used while training the perceptron
* *
* @param float $learningRate Value between 0.0(exclusive) and 1.0(inclusive) * @param float $learningRate Value between 0.0(exclusive) and 1.0(inclusive)
* @param int $maxIterations Must be at least 1 * @param int $maxIterations Must be at least 1
* *
* @throws \Exception * @throws \Exception
*/ */
@ -178,7 +178,7 @@ class Perceptron implements Classifier, IncrementalEstimator
{ {
$class = $isBatch ? GD::class : StochasticGD::class; $class = $isBatch ? GD::class : StochasticGD::class;
if (empty($this->optimizer)) { if ($this->optimizer === null) {
$this->optimizer = (new $class($this->featureCount)) $this->optimizer = (new $class($this->featureCount))
->setLearningRate($this->learningRate) ->setLearningRate($this->learningRate)
->setMaxIterations($this->maxIterations) ->setMaxIterations($this->maxIterations)

View File

@ -48,12 +48,15 @@ class Point implements ArrayAccess
*/ */
public function getClosest(array $points) public function getClosest(array $points)
{ {
$minPoint = null;
foreach ($points as $point) { foreach ($points as $point) {
$distance = $this->getDistanceWith($point, false); $distance = $this->getDistanceWith($point, false);
if (!isset($minDistance)) { if (!isset($minDistance)) {
$minDistance = $distance; $minDistance = $distance;
$minPoint = $point; $minPoint = $point;
continue; continue;
} }

View File

@ -45,7 +45,7 @@ class Space extends SplObjectStorage
} }
/** /**
* @param null $data * @param null $data
*/ */
public function addPoint(array $coordinates, $data = null): void public function addPoint(array $coordinates, $data = null): void
{ {
@ -124,10 +124,12 @@ class Space extends SplObjectStorage
switch ($initMethod) { switch ($initMethod) {
case KMeans::INIT_RANDOM: case KMeans::INIT_RANDOM:
$clusters = $this->initializeRandomClusters($clustersNumber); $clusters = $this->initializeRandomClusters($clustersNumber);
break; break;
case KMeans::INIT_KMEANS_PLUS_PLUS: case KMeans::INIT_KMEANS_PLUS_PLUS:
$clusters = $this->initializeKMPPClusters($clustersNumber); $clusters = $this->initializeKMPPClusters($clustersNumber);
break; break;
default: default:
@ -200,6 +202,7 @@ class Space extends SplObjectStorage
} }
$clusters[] = new Cluster($this, $point->getCoordinates()); $clusters[] = new Cluster($this, $point->getCoordinates());
break; break;
} }
} }

View File

@ -30,7 +30,7 @@ class KernelPCA extends PCA
/** /**
* Gamma value used by the kernel * Gamma value used by the kernel
* *
* @var float * @var float|null
*/ */
protected $gamma; protected $gamma;

View File

@ -15,7 +15,7 @@ class TokenCountVectorizer implements Transformer
private $tokenizer; private $tokenizer;
/** /**
* @var StopWords * @var StopWords|null
*/ */
private $stopWords; private $stopWords;

View File

@ -33,7 +33,7 @@ trait OneVsRest
// Clears previous stuff. // Clears previous stuff.
$this->reset(); $this->reset();
$this->trainBylabel($samples, $targets); $this->trainByLabel($samples, $targets);
} }
/** /**

View File

@ -15,9 +15,9 @@ class GD extends StochasticGD
/** /**
* Number of samples given * Number of samples given
* *
* @var int * @var int|null
*/ */
protected $sampleCount = null; protected $sampleCount;
public function runOptimization(array $samples, array $targets, Closure $gradientCb): array public function runOptimization(array $samples, array $targets, Closure $gradientCb): array
{ {

View File

@ -31,7 +31,7 @@ class StochasticGD extends Optimizer
* Callback function to get the gradient and cost value * Callback function to get the gradient and cost value
* for a specific set of theta (ϴ) and a pair of sample & target * for a specific set of theta (ϴ) and a pair of sample & target
* *
* @var \Closure * @var \Closure|null
*/ */
protected $gradientCb = null; protected $gradientCb = null;
@ -144,7 +144,7 @@ class StochasticGD extends Optimizer
* The cost function to minimize and the gradient of the function are to be * The cost function to minimize and the gradient of the function are to be
* handled by the callback function provided as the third parameter of the method. * handled by the callback function provided as the third parameter of the method.
*/ */
public function runOptimization(array $samples, array $targets, Closure $gradientCb): array public function runOptimization(array $samples, array $targets, Closure $gradientCb): ?array
{ {
$this->samples = $samples; $this->samples = $samples;
$this->targets = $targets; $this->targets = $targets;
@ -181,7 +181,7 @@ class StochasticGD extends Optimizer
// Solution in the pocket is better than or equal to the last state // Solution in the pocket is better than or equal to the last state
// so, we use this solution // so, we use this solution
return $this->theta = $bestTheta; return $this->theta = (array) $bestTheta;
} }
/** /**

View File

@ -88,6 +88,8 @@ class EigenvalueDecomposition
private $cdivi; private $cdivi;
private $A;
/** /**
* Constructor: Check for symmetry, then construct the eigenvalue decomposition * Constructor: Check for symmetry, then construct the eigenvalue decomposition
*/ */

View File

@ -212,9 +212,9 @@ class LUDecomposition
/** /**
* Is the matrix nonsingular? * Is the matrix nonsingular?
* *
* @return true if U, and hence A, is nonsingular. * @return bool true if U, and hence A, is nonsingular.
*/ */
public function isNonsingular() public function isNonsingular(): bool
{ {
for ($j = 0; $j < $this->n; ++$j) { for ($j = 0; $j < $this->n; ++$j) {
if ($this->LU[$j][$j] == 0) { if ($this->LU[$j][$j] == 0) {

View File

@ -15,7 +15,7 @@ class Set implements IteratorAggregate
private $elements = []; private $elements = [];
/** /**
* @param string[]|int[]|float[] $elements * @param string[]|int[]|float[]|bool[] $elements
*/ */
public function __construct(array $elements = []) public function __construct(array $elements = [])
{ {
@ -83,7 +83,7 @@ class Set implements IteratorAggregate
} }
/** /**
* @param string|int|float $element * @param string|int|float|bool $element
*/ */
public function add($element): self public function add($element): self
{ {
@ -91,7 +91,7 @@ class Set implements IteratorAggregate
} }
/** /**
* @param string[]|int[]|float[] $elements * @param string[]|int[]|float[]|bool[] $elements
*/ */
public function addAll(array $elements): self public function addAll(array $elements): self
{ {

View File

@ -91,6 +91,7 @@ class ClassificationReport
$values = array_filter($this->{$metric}); $values = array_filter($this->{$metric});
if (empty($values)) { if (empty($values)) {
$this->average[$metric] = 0.0; $this->average[$metric] = 0.0;
continue; continue;
} }

View File

@ -26,14 +26,14 @@ abstract class MultilayerPerceptron extends LayeredNetwork implements Estimator,
protected $classes = []; protected $classes = [];
/** /**
* @var ActivationFunction * @var ActivationFunction|null
*/ */
protected $activationFunction; protected $activationFunction;
/** /**
* @var Backpropagation * @var Backpropagation
*/ */
protected $backpropagation = null; protected $backpropagation;
/** /**
* @var int * @var int
@ -50,6 +50,11 @@ abstract class MultilayerPerceptron extends LayeredNetwork implements Estimator,
*/ */
private $learningRate; private $learningRate;
/**
* @var int
*/
private $iterations;
/** /**
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */

View File

@ -24,13 +24,11 @@ class Neuron implements Node
/** /**
* @var float * @var float
*/ */
protected $output; protected $output = 0.0;
public function __construct(?ActivationFunction $activationFunction = null) public function __construct(?ActivationFunction $activationFunction = null)
{ {
$this->activationFunction = $activationFunction ?: new Sigmoid(); $this->activationFunction = $activationFunction ?: new Sigmoid();
$this->synapses = [];
$this->output = 0;
} }
public function addSynapse(Synapse $synapse): void public function addSynapse(Synapse $synapse): void
@ -48,8 +46,8 @@ class Neuron implements Node
public function getOutput(): float public function getOutput(): float
{ {
if ($this->output === 0) { if ($this->output === 0.0) {
$sum = 0; $sum = 0.0;
foreach ($this->synapses as $synapse) { foreach ($this->synapses as $synapse) {
$sum += $synapse->getOutput(); $sum += $synapse->getOutput();
} }
@ -62,6 +60,6 @@ class Neuron implements Node
public function reset(): void public function reset(): void
{ {
$this->output = 0; $this->output = 0.0;
} }
} }

View File

@ -15,14 +15,14 @@ class Backpropagation
private $learningRate; private $learningRate;
/** /**
* @var array * @var array|null
*/ */
private $sigmas = null; private $sigmas;
/** /**
* @var array * @var array|null
*/ */
private $prevSigmas = null; private $prevSigmas;
public function __construct(float $learningRate) public function __construct(float $learningRate)
{ {

View File

@ -33,8 +33,7 @@ class Imputer implements Preprocessor
private $samples = []; private $samples = [];
/** /**
* @param mixed $missingValue * @param mixed $missingValue
* @param array|null $samples
*/ */
public function __construct($missingValue, Strategy $strategy, int $axis = self::AXIS_COLUMN, array $samples = []) public function __construct($missingValue, Strategy $strategy, int $axis = self::AXIS_COLUMN, array $samples = [])
{ {

View File

@ -9,6 +9,8 @@ class DataTransformer
public static function trainingSet(array $samples, array $labels, bool $targets = false): string public static function trainingSet(array $samples, array $labels, bool $targets = false): string
{ {
$set = ''; $set = '';
$numericLabels = [];
if (!$targets) { if (!$targets) {
$numericLabels = self::numericLabels($labels); $numericLabels = self::numericLabels($labels);
} }

View File

@ -37,7 +37,7 @@ class SupportVectorMachine
private $degree; private $degree;
/** /**
* @var float * @var float|null
*/ */
private $gamma; private $gamma;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification; namespace Phpml\Tests\Association;
use Phpml\Association\Apriori; use Phpml\Association\Apriori;
use Phpml\ModelManager; use Phpml\ModelManager;
@ -173,8 +173,8 @@ class AprioriTest extends TestCase
/** /**
* Invokes objects method. Private/protected will be set accessible. * Invokes objects method. Private/protected will be set accessible.
* *
* @param string $method Method name to be called * @param string $method Method name to be called
* @param array $params Array of params to be passed * @param array $params Array of params to be passed
* *
* @return mixed * @return mixed
*/ */

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\DecisionTree; namespace Phpml\Tests\Classification\DecisionTree;
use Phpml\Classification\DecisionTree\DecisionTreeLeaf; use Phpml\Classification\DecisionTree\DecisionTreeLeaf;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification; namespace Phpml\Tests\Classification;
use Phpml\Classification\DecisionTree; use Phpml\Classification\DecisionTree;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\Ensemble; namespace Phpml\Tests\Classification\Ensemble;
use Phpml\Classification\Ensemble\AdaBoost; use Phpml\Classification\Ensemble\AdaBoost;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\Ensemble; namespace Phpml\Tests\Classification\Ensemble;
use Phpml\Classification\DecisionTree; use Phpml\Classification\DecisionTree;
use Phpml\Classification\Ensemble\Bagging; use Phpml\Classification\Ensemble\Bagging;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\Ensemble; namespace Phpml\Tests\Classification\Ensemble;
use Phpml\Classification\DecisionTree; use Phpml\Classification\DecisionTree;
use Phpml\Classification\Ensemble\RandomForest; use Phpml\Classification\Ensemble\RandomForest;
@ -21,6 +21,7 @@ class RandomForestTest extends BaggingTest
$this->assertEquals(1, 1); $this->assertEquals(1, 1);
} }
} }
protected function getClassifier($numBaseClassifiers = 50) protected function getClassifier($numBaseClassifiers = 50)
{ {
$classifier = new RandomForest($numBaseClassifiers); $classifier = new RandomForest($numBaseClassifiers);

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification; namespace Phpml\Tests\Classification;
use Phpml\Classification\KNearestNeighbors; use Phpml\Classification\KNearestNeighbors;
use Phpml\Math\Distance\Chebyshev; use Phpml\Math\Distance\Chebyshev;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\Linear; namespace Phpml\Tests\Classification\Linear;
use Phpml\Classification\Linear\Adaline; use Phpml\Classification\Linear\Adaline;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\Linear; namespace Phpml\Tests\Classification\Linear;
use Phpml\Classification\Linear\DecisionStump; use Phpml\Classification\Linear\DecisionStump;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification\Linear; namespace Phpml\Tests\Classification\Linear;
use Phpml\Classification\Linear\Perceptron; use Phpml\Classification\Linear\Perceptron;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification; namespace Phpml\Tests\Classification;
use Phpml\Classification\MLPClassifier; use Phpml\Classification\MLPClassifier;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification; namespace Phpml\Tests\Classification;
use Phpml\Classification\NaiveBayes; use Phpml\Classification\NaiveBayes;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Classification; namespace Phpml\Tests\Classification;
use Phpml\Classification\SVC; use Phpml\Classification\SVC;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Clustering; namespace Phpml\Tests\Clustering;
use Phpml\Clustering\DBSCAN; use Phpml\Clustering\DBSCAN;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Clustering; namespace Phpml\Tests\Clustering;
use Phpml\Clustering\FuzzyCMeans; use Phpml\Clustering\FuzzyCMeans;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Clustering; namespace Phpml\Tests\Clustering;
use Phpml\Clustering\KMeans; use Phpml\Clustering\KMeans;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\CrossValidation; namespace Phpml\Tests\CrossValidation;
use Phpml\CrossValidation\RandomSplit; use Phpml\CrossValidation\RandomSplit;
use Phpml\Dataset\ArrayDataset; use Phpml\Dataset\ArrayDataset;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\CrossValidation; namespace Phpml\Tests\CrossValidation;
use Phpml\CrossValidation\StratifiedRandomSplit; use Phpml\CrossValidation\StratifiedRandomSplit;
use Phpml\Dataset\ArrayDataset; use Phpml\Dataset\ArrayDataset;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Dataset; namespace Phpml\Tests\Dataset;
use Phpml\Dataset\ArrayDataset; use Phpml\Dataset\ArrayDataset;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Dataset; namespace Phpml\Tests\Dataset;
use Phpml\Dataset\CsvDataset; use Phpml\Dataset\CsvDataset;
use Phpml\Exception\FileException; use Phpml\Exception\FileException;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Dataset\Demo; namespace Phpml\Tests\Dataset\Demo;
use Phpml\Dataset\Demo\GlassDataset; use Phpml\Dataset\Demo\GlassDataset;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Dataset\Demo; namespace Phpml\Tests\Dataset\Demo;
use Phpml\Dataset\Demo\IrisDataset; use Phpml\Dataset\Demo\IrisDataset;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Dataset\Demo; namespace Phpml\Tests\Dataset\Demo;
use Phpml\Dataset\Demo\WineDataset; use Phpml\Dataset\Demo\WineDataset;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Dataset; namespace Phpml\Tests\Dataset;
use Phpml\Dataset\FilesDataset; use Phpml\Dataset\FilesDataset;
use Phpml\Exception\DatasetException; use Phpml\Exception\DatasetException;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\DimensionReduction; namespace Phpml\Tests\DimensionReduction;
use Phpml\DimensionReduction\KernelPCA; use Phpml\DimensionReduction\KernelPCA;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\DimensionReduction; namespace Phpml\Tests\DimensionReduction;
use Phpml\Dataset\Demo\IrisDataset; use Phpml\Dataset\Demo\IrisDataset;
use Phpml\DimensionReduction\LDA; use Phpml\DimensionReduction\LDA;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\DimensionReduction; namespace Phpml\Tests\DimensionReduction;
use Phpml\DimensionReduction\PCA; use Phpml\DimensionReduction\PCA;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\FeatureExtraction; namespace Phpml\Tests\FeatureExtraction;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\FeatureExtraction\StopWords; use Phpml\FeatureExtraction\StopWords;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\FeatureExtraction; namespace Phpml\Tests\FeatureExtraction;
use Phpml\FeatureExtraction\TfIdfTransformer; use Phpml\FeatureExtraction\TfIdfTransformer;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\FeatureExtraction; namespace Phpml\Tests\FeatureExtraction;
use Phpml\FeatureExtraction\StopWords; use Phpml\FeatureExtraction\StopWords;
use Phpml\FeatureExtraction\TokenCountVectorizer; use Phpml\FeatureExtraction\TokenCountVectorizer;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Math; namespace Phpml\Tests\Math;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Comparison; use Phpml\Math\Comparison;
@ -11,8 +11,8 @@ use PHPUnit\Framework\TestCase;
class ComparisonTest extends TestCase class ComparisonTest extends TestCase
{ {
/** /**
* @param mixed $a * @param mixed $a
* @param mixed $b * @param mixed $b
* *
* @dataProvider provideData * @dataProvider provideData
*/ */

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Math\Distance;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Distance\Chebyshev; use Phpml\Math\Distance\Chebyshev;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Math\Distance;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Distance\Euclidean; use Phpml\Math\Distance\Euclidean;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Math\Distance;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Distance\Manhattan; use Phpml\Math\Distance\Manhattan;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Math\Distance;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Distance\Minkowski; use Phpml\Math\Distance\Minkowski;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace test\Phpml\Math\Kernel; namespace Phpml\Tests\Math\Kernel;
use Phpml\Math\Kernel\RBF; use Phpml\Math\Kernel\RBF;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Math\LinearAlgebra; namespace Phpml\Tests\Math\LinearAlgebra;
use Phpml\Math\LinearAlgebra\EigenvalueDecomposition; use Phpml\Math\LinearAlgebra\EigenvalueDecomposition;
use Phpml\Math\Matrix; use Phpml\Math\Matrix;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Math; namespace Phpml\Tests\Math;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Exception\MatrixException; use Phpml\Exception\MatrixException;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Math; namespace Phpml\Tests\Math;
use Phpml\Math\Product; use Phpml\Math\Product;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Math; namespace Phpml\Tests\Math;
use Phpml\Math\Set; use Phpml\Math\Set;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace test\Phpml\Math\StandardDeviation; namespace Phpml\Tests\Math\Statistic;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Statistic\Correlation; use Phpml\Math\Statistic\Correlation;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Math\Statistic; namespace Phpml\Tests\Math\Statistic;
use Phpml\Math\Statistic\Covariance; use Phpml\Math\Statistic\Covariance;
use Phpml\Math\Statistic\Mean; use Phpml\Math\Statistic\Mean;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace test\Phpml\Math\StandardDeviation; namespace Phpml\Tests\Math\Statistic;
use Phpml\Math\Statistic\Gaussian; use Phpml\Math\Statistic\Gaussian;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace test\Phpml\Math\StandardDeviation; namespace Phpml\Tests\Math\Statistic;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Statistic\Mean; use Phpml\Math\Statistic\Mean;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace test\Phpml\Math\StandardDeviation; namespace Phpml\Tests\Math\Statistic;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\Math\Statistic\StandardDeviation; use Phpml\Math\Statistic\StandardDeviation;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Metric;
use Phpml\Classification\SVC; use Phpml\Classification\SVC;
use Phpml\CrossValidation\RandomSplit; use Phpml\CrossValidation\RandomSplit;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Metric;
use Phpml\Metric\ClassificationReport; use Phpml\Metric\ClassificationReport;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Metric; namespace Phpml\Tests\Metric;
use Phpml\Metric\ConfusionMatrix; use Phpml\Metric\ConfusionMatrix;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests; namespace Phpml\Tests;
use Phpml\Exception\FileException; use Phpml\Exception\FileException;
use Phpml\ModelManager; use Phpml\ModelManager;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\ActivationFunction; namespace Phpml\Tests\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\BinaryStep; use Phpml\NeuralNetwork\ActivationFunction\BinaryStep;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\ActivationFunction; namespace Phpml\Tests\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\Gaussian; use Phpml\NeuralNetwork\ActivationFunction\Gaussian;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\ActivationFunction; namespace Phpml\Tests\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\HyperbolicTangent; use Phpml\NeuralNetwork\ActivationFunction\HyperbolicTangent;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\ActivationFunction; namespace Phpml\Tests\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\PReLU; use Phpml\NeuralNetwork\ActivationFunction\PReLU;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\ActivationFunction; namespace Phpml\Tests\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\Sigmoid; use Phpml\NeuralNetwork\ActivationFunction\Sigmoid;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\ActivationFunction; namespace Phpml\Tests\NeuralNetwork\ActivationFunction;
use Phpml\NeuralNetwork\ActivationFunction\ThresholdedReLU; use Phpml\NeuralNetwork\ActivationFunction\ThresholdedReLU;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork; namespace Phpml\Tests\NeuralNetwork;
use Phpml\Exception\InvalidArgumentException; use Phpml\Exception\InvalidArgumentException;
use Phpml\NeuralNetwork\Layer; use Phpml\NeuralNetwork\Layer;

View File

@ -2,12 +2,13 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\Network; namespace Phpml\Tests\NeuralNetwork\Network;
use Phpml\NeuralNetwork\Layer; use Phpml\NeuralNetwork\Layer;
use Phpml\NeuralNetwork\Network\LayeredNetwork; use Phpml\NeuralNetwork\Network\LayeredNetwork;
use Phpml\NeuralNetwork\Node\Input; use Phpml\NeuralNetwork\Node\Input;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;
class LayeredNetworkTest extends TestCase class LayeredNetworkTest extends TestCase
{ {
@ -44,7 +45,10 @@ class LayeredNetworkTest extends TestCase
$this->assertEquals([0.5], $network->getOutput()); $this->assertEquals([0.5], $network->getOutput());
} }
private function getLayeredNetworkMock(): LayeredNetwork /**
* @return LayeredNetwork|PHPUnit_Framework_MockObject_MockObject
*/
private function getLayeredNetworkMock()
{ {
return $this->getMockForAbstractClass(LayeredNetwork::class); return $this->getMockForAbstractClass(LayeredNetwork::class);
} }

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\Node; namespace Phpml\Tests\NeuralNetwork\Node;
use Phpml\NeuralNetwork\Node\Bias; use Phpml\NeuralNetwork\Node\Bias;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\Node; namespace Phpml\Tests\NeuralNetwork\Node;
use Phpml\NeuralNetwork\Node\Input; use Phpml\NeuralNetwork\Node\Input;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\Node\Neuron; namespace Phpml\Tests\NeuralNetwork\Node\Neuron;
use Phpml\NeuralNetwork\Node\Neuron; use Phpml\NeuralNetwork\Node\Neuron;
use Phpml\NeuralNetwork\Node\Neuron\Synapse; use Phpml\NeuralNetwork\Node\Neuron\Synapse;
@ -41,8 +41,10 @@ class SynapseTest extends TestCase
/** /**
* @param int|float $output * @param int|float $output
*
* @return Neuron|PHPUnit_Framework_MockObject_MockObject
*/ */
private function getNodeMock($output = 1): PHPUnit_Framework_MockObject_MockObject private function getNodeMock($output = 1)
{ {
$node = $this->getMockBuilder(Neuron::class)->getMock(); $node = $this->getMockBuilder(Neuron::class)->getMock();
$node->method('getOutput')->willReturn($output); $node->method('getOutput')->willReturn($output);

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\NeuralNetwork\Node; namespace Phpml\Tests\NeuralNetwork\Node;
use Phpml\NeuralNetwork\ActivationFunction\BinaryStep; use Phpml\NeuralNetwork\ActivationFunction\BinaryStep;
use Phpml\NeuralNetwork\Node\Neuron; use Phpml\NeuralNetwork\Node\Neuron;
@ -22,6 +22,7 @@ class NeuronTest extends TestCase
public function testNeuronActivationFunction(): void public function testNeuronActivationFunction(): void
{ {
/** @var BinaryStep|PHPUnit_Framework_MockObject_MockObject $activationFunction */
$activationFunction = $this->getMockBuilder(BinaryStep::class)->getMock(); $activationFunction = $this->getMockBuilder(BinaryStep::class)->getMock();
$activationFunction->method('compute')->with(0)->willReturn($output = 0.69); $activationFunction->method('compute')->with(0)->willReturn($output = 0.69);

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests; namespace Phpml\Tests;
use Phpml\Classification\SVC; use Phpml\Classification\SVC;
use Phpml\FeatureExtraction\TfIdfTransformer; use Phpml\FeatureExtraction\TfIdfTransformer;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Preprocessing; namespace Phpml\Tests\Preprocessing;
use Phpml\Preprocessing\Imputer; use Phpml\Preprocessing\Imputer;
use Phpml\Preprocessing\Imputer\Strategy\MeanStrategy; use Phpml\Preprocessing\Imputer\Strategy\MeanStrategy;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Preprocessing; namespace Phpml\Tests\Preprocessing;
use Phpml\Exception\NormalizerException; use Phpml\Exception\NormalizerException;
use Phpml\Preprocessing\Normalizer; use Phpml\Preprocessing\Normalizer;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Regression; namespace Phpml\Tests\Regression;
use Phpml\ModelManager; use Phpml\ModelManager;
use Phpml\Regression\LeastSquares; use Phpml\Regression\LeastSquares;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\Regression; namespace Phpml\Tests\Regression;
use Phpml\ModelManager; use Phpml\ModelManager;
use Phpml\Regression\SVR; use Phpml\Regression\SVR;

View File

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace tests\Phpml\SupportVectorMachine; namespace Phpml\Tests\SupportVectorMachine;
use Phpml\SupportVectorMachine\DataTransformer; use Phpml\SupportVectorMachine\DataTransformer;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

Some files were not shown because too many files have changed in this diff Show More