PHPackages                             juliardi/c45 - 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. juliardi/c45

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

juliardi/c45
============

0.1.0(8y ago)207.1k↑121.4%8MITPHPPHP &gt;=5.5

Since Jan 27Pushed 7y ago2 watchersCompare

[ Source](https://github.com/juliardi/C45)[ Packagist](https://packagist.org/packages/juliardi/c45)[ RSS](/packages/juliardi-c45/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

PHP-C45
=======

[](#php-c45)

C45 algorithm implementation in pure PHP

**NOTE : this implementation doesn't support numeric value for data training. I don't have any plan to implement it. Feel free to send a pull request.**

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

[](#installation)

The preferred way to install this extension is through composer.

Either run

```
php composer.phar require --prefer-dist juliardi/c45 "*"

```

or add

```
"juliardi/c45": "*"

```

to the require section of your composer.json file.

Requirement
-----------

[](#requirement)

This library doesn't need any special configuration. You can use it as is. However, there are a few requirement that must be met in order to make this library run as intended.

1. **You can only use CSV file as input for training data.** It is a bad decision and I admit it. However as of now i don't have time to implements a more generic way to read training data.
2. **The first line of the CSV file MUST be the attribute name and MUST be quoted in double quotes**

Here is an example of a valid CSV for training :

```
"outlook", "windy", "humidity", "play"
sunny, false, high, no
sunny, true, high, no
sunny, false, high, no
sunny, false, medium, yes
sunny, true, medium, yes
overcast, false, medium, yes
overcast, true, medium, yes
overcast, true, high, yes
overcast, false, medium, yes
rain, false, high, yes
rain, false, medium, yes
rain, true, medium, no
rain, false, medium, yes
rain, true, medium, no

```

Usage
-----

[](#usage)

Assuming that you have the following directory structure :

```
.
├── src
|   ├── index.php
|   └── data.csv
├── vendor
├── composer.json

```

You can use PHP-C45 in your `index.php` like this :

```
