PHPackages                             lambdacasserole/brainy - 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. lambdacasserole/brainy

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

lambdacasserole/brainy
======================

Neural network implementation in PHP, packaged for Composer.

v1.3(9y ago)144BSD-3-ClausePHP

Since Jan 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/lambdacasserole/brainy)[ Packagist](https://packagist.org/packages/lambdacasserole/brainy)[ RSS](/packages/lambdacasserole-brainy/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

Brainy
======

[](#brainy)

Neural network implementation in PHP, packaged for Composer.

Based heavily on [the Tremani neural network](https://github.com/infostreams/neural-network) by [Edward Akerboom](https://github.com/infostreams) but stripped down, tidied up and packaged for Composer.

Installation
------------

[](#installation)

Install Brainy via Composer like this:

```
composer require lambdacasserole/brainy
```

Or alternatively, if you're using the PHAR (make sure the `php.exe` executable is in your PATH):

```
php composer.phar require lambdacasserole/brainy

```

Usage
-----

[](#usage)

Create a new neural network instance like this:

```
// Create a new neural network with 3 input neurons, one layer of 4 hidden neurons, and 1 output neuron.
$network = new NeuralNetwork(3, 4, 1);
```

Add training data to your new network thusly:

```
// Add training data to the network. In this case, we want the network to learn the 'XOR' function.
$network->addTrainingData([-1, -1, 1], [-1]);
$network->addTrainingData([-1, 1, 1], [1]);
$network->addTrainingData([1, -1, 1], [1]);
$network->addTrainingData([1, 1, 1], [-1]);
```

Then begin training:

```
// Train in a maximum of 1000 epochs to a maximum error rate of 0.01.
$success = $network->train(1000, 0.01);
```

Now put it to work:

```
$output = $network->calculate([-1, -1, 1]); // Gives [-1].
$output = $network->calculate([-1, 1, 1]); // Gives [1].

```

Compatibility
-------------

[](#compatibility)

Uses new array syntax and splats, so won't work on any PHP versions earlier than 5.6.

Further Reading
---------------

[](#further-reading)

The [original repository](https://github.com/infostreams/neural-network) contains more comprehensive documentation, though it may need adjusting slightly due to modifications made to it in this version.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

3387d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/78af2d67ef562ce04be22d01873f1cebc40e56c52677ce0ad3910f55364f2420?d=identicon)[lambdacasserole](/maintainers/lambdacasserole)

---

Top Contributors

[![lambdacasserole](https://avatars.githubusercontent.com/u/5577382?v=4)](https://github.com/lambdacasserole "lambdacasserole (19 commits)")

---

Tags

aicomposerneural-networkpackagistphp

### Embed Badge

![Health badge](/badges/lambdacasserole-brainy/health.svg)

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

###  Alternatives

[csharpru/vault-php

Best Vault client for PHP that you can find

8410.3M4](/packages/csharpru-vault-php)[composer-unused/contracts

Contract repository for composer-unused

115.7M2](/packages/composer-unused-contracts)

PHPackages © 2026

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