PHP code example of medansoftware / c45-algorithm-php
1. Go to this page and download the library: Download medansoftware/c45-algorithm-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
medansoftware / c45-algorithm-php example snippets
$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 "<pre>";
print_r ($arrayTree);
echo "</pre>";
echo $stringTree;
$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 "<pre>";
print_r ($arrayTree);
echo "</pre>";
echo $stringTree;
$c45 = new Algorithm\C45();
$c45->loadFile('example.xlsx')->setTargetAttribute('PLAY')->initialize();
echo "<pre>";
print_r ($c45->buildTree()->toString()); // print as string
echo "</pre>";
echo "<pre>";
print_r ($c45->buildTree()->toJson()); // print as JSON
echo "</pre>";
echo "<pre>";
print_r ($c45->buildTree()->toArray()); // print as array
echo "</pre>";