PHPackages                             jtet/perceptron - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jtet/perceptron

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jtet/perceptron
===============

Simple PHP implementation of a Perceptron.

13976PHP

Since Feb 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jtet/Perceptron)[ Packagist](https://packagist.org/packages/jtet/perceptron)[ RSS](/packages/jtet-perceptron/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Perceptron
==========

[](#perceptron)

[![Build Status](https://camo.githubusercontent.com/9ceb15ebb0bf34fdc87008a7e455f226aa420326d516364cf3c8d5a7ff67bd9f/68747470733a2f2f6170692e7472617669732d63692e6f72672f6a7465742f50657263657074726f6e2e706e673f6272616e6368)](https://travis-ci.org/jtet/Perceptron)

What is a Perceptron?
---------------------

[](#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

Training
--------

[](#training)

```
while($p->getIterationError() > $x)
{
    for ($i = 0; $i < count($inputVectors); $i++){
        $p->train($inputVectors[$i], $outcomes[$i);
    }
}
```

Test an Input
-------------

[](#test-an-input)

```
echo $p->test($inputVector)? "True": "False";
```

Example
-------

[](#example)

The following code trains the Perceptron to act as a [NAND gate](http://en.wikipedia.org/wiki/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
------------------

[](#getting-perceptron)

Add the following to your [composer.json](http://getcomposer.org) file and run `composer update`.

```
"require": {
        "jtet/perceptron": "dev-master"
    }

```

License
-------

[](#license)

Perceptron is available for your use under the [OSL-3.0](http://www.spdx.org/licenses/OSL-3.0#licenseText) license.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab3c0e5b31b7eb948e92c5f4874d90b0cc0bbba134b842b7b23b111cea8039c3?d=identicon)[jtet](/maintainers/jtet)

---

Top Contributors

[![jtet](https://avatars.githubusercontent.com/u/2342345?v=4)](https://github.com/jtet "jtet (21 commits)")

### Embed Badge

![Health badge](/badges/jtet-perceptron/health.svg)

```
[![Health](https://phpackages.com/badges/jtet-perceptron/health.svg)](https://phpackages.com/packages/jtet-perceptron)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
