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

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

herilesmana/c45
===============

0.3.2(4y ago)116MITPHPPHP &gt;=5.5

Since May 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/herilesmana/c45)[ Packagist](https://packagist.org/packages/herilesmana/c45)[ RSS](/packages/herilesmana-c45/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (1)Versions (6)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 herilesmana/c45 "*"

```

or add

```
"herilesmana/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 use CSV file as input for training data.** .
2. **The first line of the CSV file MUST be the attribute name and MUST be quoted in double quotes**
3. **Your can use array data**

Usage
-----

[](#usage)

### Using csv file

[](#using-csv-file)

Assuming that you have the following directory structure :

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

```

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

```

Create new file ( with notepad or etc), and save as data.csv

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

```
