PHP code example of thominj / data-miner

1. Go to this page and download the library: Download thominj/data-miner 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/ */

    

thominj / data-miner example snippets




$bins = [ 0, 1, 2, 3];
$data = [ -1, 0, 0.5, 1, 3, 4 ];

$histogram = new thominj\DataMiner\Histogram($bins, $data);
$result = $histogram->getResult();

print_r($result);

// Set bins and add data in the constructor
$histogram = new thominj\DataMiner\Histogram($bins, $data);

// Set bins in the constructor, add data later
$histogram = new thominj\DataMiner\Histogram($bins);
$histogram->addData($data);

// Set bins and add data after instancing the histogram
$histogram = new thominj\DataMiner\Histogram();
$histogram->setBins($bins);
$histogram->addData($data);

// Online mode
$histogram = new thominj\DataMiner\Histogram($bins);

// Add some data
$histogram->addData($data);

// Get the result
print_r($histogram->getResult());

// Add some more data
$histogram->addData($data);

// Get the new result
print_r($histogram->getResult());

$old_result = array(
  'less' => 2,
  0 => 4,
  1 => 2, 
  2 => 0,
  3 => 4
);

$histogram = new thominj\DataMiner\Histogram();
$histogram->preload($old_result);
$histogram->addData($data);

print_r($histogram->getResult());