1. Go to this page and download the library: Download rubix/housing 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/ */
use Rubix\ML\Transformers\NumericStringConverter;
use Rubix\ML\Transformers\MissingDataImputer;
$dataset->apply(new NumericStringConverter())
->apply(new MissingDataImputer())
->transformLabels('intval');
use Rubix\ML\PersistentModel;
use Rubix\ML\Regressors\GradientBoost;
use Rubix\ML\Regressors\RegressionTree;
use Rubix\ML\Persisters\Filesystem;
$estimator = new PersistentModel(
new GradientBoost(new RegressionTree(4), 0.1),
new Filesystem('housing.rbx', true)
);
use Rubix\ML\Other\Loggers\Screen;
$estimator->setLogger(new Screen());
$estimator->train($dataset);
use Rubix\ML\Extractors\CSV;
$extractor = new CSV('progress.csv', true);
$extractor->export($estimator->steps());
$estimator->save();
use Rubix\ML\Datasets\Unlabeled;
use Rubix\ML\Extractors\CSV;
use Rubix\ML\Transformers\NumericStringConverter;
$dataset = Unlabeled::fromIterator(new CSV('unknown.csv', true))
->apply(new NumericStringConverter());
use Rubix\ML\PersistentModel;
use Rubix\ML\Persisters\Filesystem;
$estimator = PersistentModel::load(new Filesystem('housing.model'));
$predictions = $estimator->predict($dataset);
use Rubix\ML\Extractors\ColumnPicker;
use Rubix\ML\Extractors\CSV;
$extractor = new ColumnPicker(new CSV('dataset.csv', true), ['Id']);
$ids = array_column(iterator_to_array($extractor), 'Id');
array_unshift($ids, 'Id');
array_unshift($predictions, 'SalePrice');
$extractor = new CSV('predictions.csv');
$extractor->export(array_transpose([$ids, $predictions]));
sh
$ php train.php
sh
$ php predict.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.