1. Go to this page and download the library: Download rubix/credit 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/ */
rubix / credit example snippets
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Extractors\CSV;
$dataset = Labeled::fromIterator(new CSV('dataset.csv', true));
use Rubix\ML\Transformers\LambdaFunction;
use Rubix\ML\Transformers\MissingDataImputer;
use Rubix\ML\Transformers\FloatTypeConverter;
use Rubix\ML\Transformers\OneHotEncoder;
use Rubix\ML\Transformers\PowerTransformer;
use Rubix\ML\Transformers\ZScaleStandardizer;
$dataset->apply(new LambdaFunction(function (array &$sample) {
if ($sample[2] === '0') {
$sample[2] = '?';
}
}))
->apply(new MissingDataImputer())
->apply(new FloatTypeConverter())
->apply(new OneHotEncoder())
->apply(new PowerTransformer())
->apply(new ZScaleStandardizer());
use Rubix\ML\Classifiers\LogisticRegression;
use Rubix\ML\NeuralNet\Optimizers\Stochastic;
use Rubix\ML\NeuralNet\Optimizers\Schedulers\StepDecay;
$estimator = new LogisticRegression(128, new Stochastic(new StepDecay(0.001, 100)));
use Rubix\ML\Loggers\Screen;
$logger = new Screen();
$estimator->setLogger($logger);
$estimator->setValidationDataset($testing);
$estimator->train($training);
use Rubix\ML\Extractors\CSV;
$extractor = new CSV('progress.csv', true);
$extractor->export($estimator->progress(), overwrite: true);
use Rubix\ML\CrossValidation\Reports\AggregateReport;
use Rubix\ML\CrossValidation\Reports\MulticlassBreakdown;
use Rubix\ML\CrossValidation\Reports\ConfusionMatrix;
$report = new AggregateReport([
new MulticlassBreakdown(),
new ConfusionMatrix(),
]);
$predictions = $estimator->predict($testing);
use Rubix\ML\Persisters\Filesystem;
$results = $report->generate($predictions, $testing->labels());
$results->toJSON()->saveTo(new Filesystem('report.json'));
use Rubix\ML\Datasets\Labeled;
use Rubix\ML\Extractors\CSV;
use Rubix\ML\Transformers\LambdaFunction;
use Rubix\ML\Transformers\MissingDataImputer;
use Rubix\ML\Transformers\FloatTypeConverter;
$dataset = Labeled::fromIterator(new CSV('dataset.csv', true));
$dataset = $dataset->apply(new LambdaFunction(function (array &$sample) {
if ($sample[2] === '0') {
$sample[2] = '?';
}
}))
->apply(new MissingDataImputer())
->apply(new FloatTypeConverter());
$stats = $dataset->describeByClassLabels();
use Rubix\ML\Persisters\Filesystem;
$stats->toJSON()->saveTo(new Filesystem('stats.json'));
use Rubix\ML\Datasets\Labeled;
$dataset = $dataset->randomize()->take(2048);
use Rubix\ML\Transformers\OneHotEncoder;
use Rubix\ML\Transformers\PowerTransformer;
use Rubix\ML\Transformers\ZScaleStandardizer;
$dataset->apply(new OneHotEncoder())
->apply(new PowerTransformer())
->apply(new ZScaleStandardizer());
$dataset->apply($embedder);
use Rubix\ML\Extractors\CSV;
$dataset->exportTo(new CSV('embedding.csv'), overwrite: true);
sh
$ php train.php
sh
$ php explore.php
sh
$ php plot.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.