Preprocessing
Standardize, normalize, impute, and discretize your features with robust transformers.
Open source · MIT licensed
A high-level machine learning and deep learning library for the PHP language. Build programs that learn from your data — from ETL to training, cross-validation, and production.
composer require rubix/ml
01 — The toolbox
Supervised and unsupervised estimators for classification, regression, clustering, and anomaly detection — all behind one consistent, delightful API.
Boosting ensemble of weak learners
Bagged ensemble of decision trees
Greedy binary decision tree
Extremely randomized tree
Probabilistic Gaussian model
KNN accelerated by a k-d tree
Distance-based voting classifier
Linear probabilistic classifier
Adaptive logistic boosting
Feed-forward neural network
Conditional probability classifier
Meta-strategy for multiclass
Fixed-radius voting classifier
Multiclass linear model
Support Vector Classifier
Boosted regression trees
L2-regularized linear regression
Binary decision tree regressor
Extremely randomized tree
Support Vector Regression
Adaptive linear neuron
Neural network regressor
Distance-based regression
KNN accelerated by a k-d tree
Fixed-radius regression
Centroid-based partitioning
Medoid-based partitioning
Density-based clustering
Expectation-maximization model
Mode-seeking clustering
Soft membership clustering
Ensemble of isolation trees
Density-based outlier detection
Boundary-based novelty detection
Maximum likelihood estimation
Lightweight online detector
Robust statistical detector
Linear orthogonal projection
t-distributed stochastic neighbor embedding
Truncated singular value decomposition
Gaussian random projection
Sparse random projection
Supervised linear projection
02 — End-to-end
Rubix ML covers the entire machine learning life cycle. Extract data from any source, clean and transform it through composable pipelines, train your estimator, then cross-validate and ship it to production.
Standardize, normalize, impute, and discretize your features with robust transformers.
Vectorize text into numeric feature bags with tokenizers and TF-IDF weighting.
Resize, flip, rotate, and vectorize images for computer vision tasks.
Project high-dimensional data into compact embeddings for speed and clarity.
03 — Deep learning
A full deep learning engine with feed-forward networks, backpropagation, and a rich library of layers, activation functions, cost functions, and optimizers.
Interval, cyclical, and step-decay learning rate schedulers included.
04 — Production
Measure real performance with a complete suite of metrics and reports, save models to disk, and accelerate training with parallel processing backends.
Robust resampling strategies and 25+ metrics — accuracy, F1, MCC, RMSE, R², and more — plus confusion matrices and error analysis reports.
Serialize trained models with the efficient RBX format, native PHP, or Gzip — then reload them anywhere, any time.
Tap into multi-core processing with the Swoole or AMP backend, and compute tensors at native speed with the Tensor extension.
05 — Delightful API
Expressive, object-oriented, and consistent. Here is a full workflow — build a dataset, train a learner, and make predictions.
1use Rubix\ML\Datasets\Labeled;
2use Rubix\ML\Classifiers\KNearestNeighbors;
3use Rubix\ML\CrossValidation\Metrics\Accuracy;
4
5// 1. Load a labeled dataset
6$dataset = new Labeled($samples, $labels);
7$dataset->randomize()->split(0.8);
8
9// 2. Choose and train an estimator
10$estimator = new KNearestNeighbors(3);
11$estimator->train($dataset);
12
13// 3. Make predictions on unknown samples
14$predictions = $estimator->predict($testing);
15
16// 4. Score the model
17$score = (new Accuracy())->score($testing->labels(), $predictions);
06 — Learn by doing
Beginner to advanced projects, many with pre-cleaned datasets and step-by-step instructions.
Handwritten digit classification
VisionImage recognition with a CNN
ClassicThe hello-world of ML
NLPPositive / negative classification
RegressionPredict sale prices
RiskPredict loan defaults
BusinessForecast customer loss
BiologySequence classification
ClusteringGroup colors with K-Means
GamingMatch result prediction
SensorsClassify motion data
ClassicRelationship outcome
07 — FAQ
Yes. The code is licensed under the permissive MIT license and is free to use commercially. The documentation is licensed CC BY-NC 4.0.
PHP 8.3 or above. The Tensor extension is recommended for fast matrix and vector computing, and Swoole is optional for multiprocessing.
No. The library ships with a gentle introduction, a basic tutorial, and complete API docs. Beginners can learn as they build.
Absolutely. Models are persistable, estimators are serializable, and the library supports cross-validation, parallel backends, and inference at scale.
Join the community on Telegram, browse the documentation, or open an issue on GitHub.
Interact with maintainers and other PHP machine learning enthusiasts.
Telegram Channel Star on GitHubCode: MIT · Docs: CC BY-NC 4.0
One command is all it takes to bring machine learning to your PHP project.
composer require rubix/ml