PHPackages                             medansoftware/c45-algorithm-php - 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. medansoftware/c45-algorithm-php

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

medansoftware/c45-algorithm-php
===============================

1.0.2(4y ago)122928MITPHPPHP &gt;=5.5

Since Nov 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MedanSoftware/C45-Algorithm-PHP)[ Packagist](https://packagist.org/packages/medansoftware/c45-algorithm-php)[ RSS](/packages/medansoftware-c45-algorithm-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (0)

C45 Algorithm - PHP Language
============================

[](#c45-algorithm---php-language)

> [**Use Example File**](example.xlsx)

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

[](#installation)

The recommended way to install the C45 PHP library is through [Composer](https://getcomposer.org) :

```
composer require medansoftware/c45-algorithm-php
```

Manual Installation
-------------------

[](#manual-installation)

```
composer dump-autoload
```

Setup
-----

[](#setup)

```
$c45 = new Algorithm\C45('example.xlsx', 'PLAY');
$initialize = $c45->initialize(); // initialize
$buildTree = $initialize->buildTree(); // build tree

$arrayTree = $buildTree->toArray(); // set to array
$stringTree = $buildTree->toString(); // set to string

echo "";
print_r ($arrayTree);
echo "";

echo $stringTree;
```

or

```
$c45 = new Algorithm\C45();
$c45->loadFile('example.xlsx'); // load example file
$c45->setTargetAttribute('PLAY'); // set target attribute

$initialize = $c45->initialize(); // initialize
$buildTree = $initialize->buildTree(); // build tree

$arrayTree = $buildTree->toArray(); // set to array
$stringTree = $buildTree->toString(); // set to string

echo "";
print_r ($arrayTree);
echo "";

echo $stringTree;
```

Other Examples
--------------

[](#other-examples)

```
$c45 = new Algorithm\C45();
$c45->loadFile('example.xlsx')->setTargetAttribute('PLAY')->initialize();

echo "";
print_r ($c45->buildTree()->toString()); // print as string
echo "";

echo "";
print_r ($c45->buildTree()->toJson()); // print as JSON
echo "";

echo "";
print_r ($c45->buildTree()->toArray()); // print as array
echo "";
```

Initialize Data from Array
--------------------------

[](#initialize-data-from-array)

```
$c45 = new Algorithm\C45();
$input = new Algorithm\C45\DataInput;
$data = array(
	array(
		"OUTLOOK" => "Sunny",
		"TEMPERATURE" => "Hot",
		"HUMIDITY" => "High",
		"WINDY" => "False",
		"PLAY" => "No"
	),
	array(
		"OUTLOOK" => "Sunny",
		"TEMPERATURE" => "Hot",
		"HUMIDITY" => "High",
		"WINDY" => "True",
		"PLAY" => "No"
	),
	array(
		"OUTLOOK" => "Cloudy",
		"TEMPERATURE" => "Hot",
		"HUMIDITY" => "High",
		"WINDY" => "False",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Rainy",
		"TEMPERATURE" => "Mild",
		"HUMIDITY" => "High",
		"WINDY" => "False",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Rainy",
		"TEMPERATURE" => "Cool",
		"HUMIDITY" => "Normal",
		"WINDY" => "False",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Rainy",
		"TEMPERATURE" => "Cool",
		"HUMIDITY" => "Normal",
		"WINDY" => "True",
		"PLAY" => "No"
	),
	array(
		"OUTLOOK" => "Cloudy",
		"TEMPERATURE" => "Cool",
		"HUMIDITY" => "Normal",
		"WINDY" => "True",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Sunny",
		"TEMPERATURE" => "Mild",
		"HUMIDITY" => "High",
		"WINDY" => "False",
		"PLAY" => "No"
	),
	array(
		"OUTLOOK" => "Sunny",
		"TEMPERATURE" => "Cool",
		"HUMIDITY" => "Normal",
		"WINDY" => "False",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Rainy",
		"TEMPERATURE" => "Mild",
		"HUMIDITY" => "Normal",
		"WINDY" => "False",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Sunny",
		"TEMPERATURE" => "Mild",
		"HUMIDITY" => "Normal",
		"WINDY" => "True",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Cloudy",
		"TEMPERATURE" => "Mild",
		"HUMIDITY" => "High",
		"WINDY" => "True",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Cloudy",
		"TEMPERATURE" => "Hot",
		"HUMIDITY" => "Normal",
		"WINDY" => "False",
		"PLAY" => "Yes"
	),
	array(
		"OUTLOOK" => "Rainy",
		"TEMPERATURE" => "Mild",
		"HUMIDITY" => "High",
		"WINDY" => "True",
		"PLAY" => "No"
	)
);

// Initialize Data
$input->setData($data); // Set data from array
$input->setAttributes(array('OUTLOOK', 'TEMPERATURE', 'HUMIDITY', 'WINDY', 'PLAY')); // Set attributes of data

// Initialize C4.5
$c45->c45 = $input; // Set input data
$c45->setTargetAttribute('PLAY'); // Set target attribute
$initialize = $c45->initialize(); // initialize

// Build Output
$buildTree = $initialize->buildTree(); // Build tree
$arrayTree = $buildTree->toArray(); // Set to array
$stringTree = $buildTree->toString(); // Set to string

echo "";
print_r ($arrayTree);
echo "";

echo $stringTree;
```

```
$new_data = array(
	'OUTLOOK' => 'Sunny',
	'TEMPERATURE' => 'Hot',
	'HUMIDITY' => 'High',
	'WINDY' => FALSE
);

echo $c45->initialize()->buildTree()->classify($new_data); // print "No"
```

[Refrence](https://github.com/juliardi/C45)

**Made with ❤️ + ☕ ~ Agung Dirgantara**

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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 ~443 days

Total

3

Last Release

1531d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11814324?v=4)[Agung Dirgantara](/maintainers/agoenks29D)[@agoenks29D](https://github.com/agoenks29D)

---

Top Contributors

[![agoenks29D](https://avatars.githubusercontent.com/u/11814324?v=4)](https://github.com/agoenks29D "agoenks29D (11 commits)")

---

Tags

c45-treesdataminingdecision-tree

### Embed Badge

![Health badge](/badges/medansoftware-c45-algorithm-php/health.svg)

```
[![Health](https://phpackages.com/badges/medansoftware-c45-algorithm-php/health.svg)](https://phpackages.com/packages/medansoftware-c45-algorithm-php)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k19](/packages/solspace-craft-freeform)[pimcore/data-importer

Adds a comprehensive import functionality to Pimcore Datahub

46855.5k5](/packages/pimcore-data-importer)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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