1. Go to this page and download the library: Download cocur/arff 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/ */
cocur / arff example snippets
use Cocur\Arff\Document;
use Cocur\Arff\Column\NumericColumn;
use Cocur\Arff\Column\NominalColumn;
$document = new Document('iris');
$document->addColumn(new NumericColumn('sepallength'));
$document->addColumn(new NumericColumn('sepalwidth'));
$document->addColumn(new NumericColumn('petallength'));
$document->addColumn(new NumericColumn('petalwidth'));
$document->addColumn(new NominalColumn('class', ['Iris-setosa','Iris-versicolor','Iris-virginica']));
$document->addData(['sepallength' => 5.1, 'sepalwidth' => 3.5, 'petallength' => 1.4, 'petalwidth' => 0.2, 'class' => 'Iris-setosa']);
$writer = new Writer();
$writer->render($document); // returns rendered .arff file
$writer->write($document, 'iris.arff'); // writes .arff file to disk
use Cocur\Arff\Reader;
$reader = new Reader();
$document = $reader->readFile('irif.arff'); // returns Cocur\Arff\Document
$column = new DateColumn('created', 'yyyy-MM-dd HH:mm:ss');
use Cocur\Arff\Bridge\Plum\ArffWriter;
$writer = new ArffWriter('filename.arff', 'name', [
new NumericColumn('sepallength'),
new NumericColumn('sepalwidth'),
new NumericColumn('petallength'),
new NumericColumn('petalwidth'),
new NominalColumn('class', ['Iris-setosa','Iris-versicolor','Iris-virginica']),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.