PHP code example of torian257x / ai-php-rubix-wrap

1. Go to this page and download the library: Download torian257x/ai-php-rubix-wrap 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/ */

    

torian257x / ai-php-rubix-wrap example snippets


    $report = RubixService::train($data, 'column_with_label');

$apartment_data = [
        ['space_m2' =>  10, 'price' => 100],
        ['space_m2' =>  20, 'price' => 200],
        ['space_m2' =>  30, 'price' => 300],
        ['space_m2' =>  40, 'price' => 400],
        //...
        ['space_m2' => 280, 'price' => 2800],
        ['space_m2' => 290, 'price' => 2900],
        ['space_m2' => 300, 'price' => 3000],
];

$report = RubixService::train($apartment_data, 'price');

var_export($report);

/* 
  array (
    'mean absolute error' => 68.88888888888889,
    ...
    'r squared' => 0.9796739130434783,
    ...
  )
*/ 

$prediction = RubixService::predict(['space_m2' => 250]);
//$prediciton ~2440