承接 jtet/perceptron 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jtet/perceptron

Composer 安装命令:

composer require jtet/perceptron

包简介

Simple PHP implementation of a Perceptron.

README 文档

README

Build Status

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

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2012-12-12