devfym / intelliphp
Machine Learning for PHP.
0.0.2
2020-01-06 23:47 UTC
Requires
- php: ^7.1.3
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-05-20 10:17:38 UTC
README
Composer Library for Machine Learning.
Requirements
Currently it requires PHP Version >= 7.2
How to install package
composer require devfym/intelliphp
Features
- Data
- Math (method in DataFrame / Series)
- Min, Max, Mean, Median
- Standard Deviation
- Variance
- Quartile
- Statistic
- Correlation
- Pearson Correlation
- Spearman Rank Correlation
- Kendall Rank Correlation
- Differences
- F Test
- Activation Function
- ReLU
- Sigmoid
- Softmax
- Validation
- Mean Squared Error (MSE)
- Root Mean Squared Error (RMSE)
- Correlation
- Regression
Examples
DataFrame
// Call autoload to import Composer packages require_once __DIR__ . '/vendor/autoload.php'; // Import DataFrame use devfym\Data\DataFrame; // 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();
Linear Regression
// Call autoload to import Composer packages require_once __DIR__ . '/vendor/autoload.php'; // Import LinearRegression use devfym\Regression\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.