PHP Machine Learning Library

A lightweight machine learning library for data analysis in PHP

Version 1.0.0

Installation

Install via Composer:

composer require phpml/php-machine-learning

Or add to your composer.json:

"phpml/php-machine-learning": "^1.0"

Basic Usage

Here's a simple example of using the library:

<?php
require 'vendor/autoload.php';

use PHPML\Models\LinearRegression;
use PHPML\Preprocessing\DataPreprocessor;

// Sample data
$data = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]];
$labels = [3, 5, 7, 9, 11];

// Preprocess data
$preprocessor = new DataPreprocessor($data);
$normalizedData = $preprocessor->normalize();

// Train model
$model = new LinearRegression();
$model->fit($normalizedData, $labels);

// Make predictions
$predictions = $model->predict($normalizedData);
print_r($predictions);

Available Models

Data Preprocessing

The DataPreprocessor class provides various data preprocessing methods:

Data Analysis

The DataAnalyzer class provides statistical analysis:

Model Evaluation

The ModelEvaluator class provides evaluation metrics: