PHP code example of devfym / intelliphp

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

    

devfym / intelliphp example snippets


// Call autoload to import Composer packages
me;

// Create new instance
$df = new DataFrame();

// Create sample array-formatted data
$data = [
    'name' => ['aaron','bambi','celine','dennise'],
    'age'  => [12, 14, 16, 18]
];

// set data into DataFrame
$df->readArray($data);

// Get Columns
$df->getColumns();

// Get Index
$df->getIndex();

// Get array of Name
$df->name->all();

// Get array of Age
$df->age->all();

// Get Mean of Age
$df->age->mean();


// Call autoload to import Composer packages
ssion\LinearRegression;

// Create new instance 
$linear = new LinearRegression();

// Create Train Data
$x_train = [2, 4, 6, 8, 10];
$y_train = [1, 3, 5, 7, 9];

// Set Train Data into instance via setTrain(@array predictors, @array outcomes) method. 
$linear->setTrain($x_train, $y_train);

// Generate LinearRegression Model.
$linear->model();

// Predict Value by passing Predictor via predict(@float predictor) method.
$linear->predict(7);

// it will return a value of 6.