jtet/perceptron
Composer 安装命令:
composer require jtet/perceptron
包简介
Simple PHP implementation of a Perceptron.
README 文档
README
What is a Perceptron?
"the perceptron is an algorithm for supervised classification of an input into one of two possible outputs.
It is a type of linear classifier, i.e. a classification algorithm that makes its predictions based on a
linear predictor function combining a set of weights with the feature vector describing a given input."
read more at http://en.wikipedia.org/wiki/Perceptron
Training
while($p->getIterationError() > $x) { for ($i = 0; $i < count($inputVectors); $i++){ $p->train($inputVectors[$i], $outcomes[$i); } }
Test an Input
echo $p->test($inputVector)? "True": "False";
Example
The following code trains the Perceptron to act as a NAND gate
$p = new \JTet\Perceptron\Perceptron(2); $i = 0; while($i < 100000) { $input = array(0, 0); $output = 1; $p->train($input, $output); $input = array(0, 1); $output = 1; $p->train($input, $output); $input = array(1,0); $output = 1; $p->train($input, $output); $input = array(1,1); $output = 0; $p->train($input, $output); $i++; } echo $p->test(array(1,1))? "Incorrect\n": "Correct\n"; echo $p->test(array(0,1))? "Correct\n": "Incorrect\n"; echo $p->test(array(0,0))? "Correct\n": "Incorrect\n"; echo $p->test(array(1,0))? "Correct\n": "Incorrect\n";
Getting Perceptron
Add the following to your composer.json file and run composer update.
"require": {
"jtet/perceptron": "dev-master"
}
License
Perceptron is available for your use under the OSL-3.0 license.
统计信息
- 总下载量: 97
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: OSL-3.0
- 更新时间: 2012-12-12