Created
April 14, 2017 15:12
-
-
Save dmonllao/6bd9d1cf5d26cd9cddf7ee0b148ddb86 to your computer and use it in GitHub Desktop.
php-ml linear classifier performance comparison (https://github.com/php-ai/php-ml/pull/78)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RESULTS: | |
➜ php-ml-fork git:(partial-train) ✗ php memory-usage.php | |
string(18) "perceptron: 522368" | |
string(15) "adaline: 490576" | |
string(16) "logistic: 484832" | |
➜ php-ml-fork git:(cost-values-key) ✗ php memory-usage.php | |
string(17) "perceptron: 77312" | |
string(14) "adaline: 45520" | |
string(15) "logistic: 32864" | |
SCRIPT: | |
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
use Phpml\Dataset\Demo\WineDataset; | |
use Phpml\Classification\Linear\Perceptron; | |
use Phpml\Classification\Linear\Adaline; | |
use Phpml\Classification\Linear\LogisticRegression; | |
$dataset = new WineDataset(); | |
$classifiers['perceptron'] = new Perceptron(); | |
$classifiers['adaline'] = new Adaline(); | |
$classifiers['logistic'] = new LogisticRegression(); | |
foreach ($classifiers as $name => $classifier) { | |
$mem1 = memory_get_usage(false); | |
$classifier->train($dataset->getSamples(), $dataset->getTargets()); | |
$mem2 = memory_get_usage(false); | |
var_dump($name . ': ' . ($mem2 - $mem1)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment