Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fieg/markov
Implementation of MarkovChain algorithm in PHP
https://github.com/fieg/markov
algorithm machine-learning markov markov-chain php
Last synced: 3 months ago
JSON representation
Implementation of MarkovChain algorithm in PHP
- Host: GitHub
- URL: https://github.com/fieg/markov
- Owner: fieg
- Created: 2015-05-14T11:35:15.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-14T11:56:32.000Z (almost 10 years ago)
- Last Synced: 2024-11-17T01:36:16.988Z (3 months ago)
- Topics: algorithm, machine-learning, markov, markov-chain, php
- Language: PHP
- Homepage:
- Size: 125 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Markov Chain
============Implementation of MarkovChain algorithm in PHP.
[![Build Status](https://travis-ci.org/fieg/markov.png?branch=master)](https://travis-ci.org/fieg/markov)
Getting started
---------------```php
use Fieg\Markov\MarkovChain;$sentences = [
'my blue car',
'red and blue flowers',
'his blue car',
];$chain = new MarkovChain();
foreach ($sentences as $sentence) {
$tokens = explode(" ", $sentence);$chain->train($tokens);
}$result = $chain->query("blue");
```Which would result in:
```
array(2) {
'car' =>
double(0.66666666666667)
'flowers' =>
double(0.33333333333333)
}
```