Getting Started With ML Prediction Engine
Requirements
Docker users need only Docker, the compose file builds both containers. Running without Docker needs PHP 8.1 or newer with the pdo_sqlite extension, and Python 3.9 or newer with scikit-learn, one pip install scikit-learn. There is no database server to install, the SQLite file and the data folder create themselves.
Step 1: Install and Run the Engine
Both install paths start the same way: copy config.sample.php to config.php and set apiKey and adminPassword to long random strings.
Docker is the fastest path. Set mlServiceUrl to http://ml:8750 in the config, then:
cp config.sample.php config.php
# edit config.php: set apiKey, adminPassword, and mlServiceUrl
docker compose up --build
That starts the PHP app and the Python worker together, and the admin is at http://localhost:8080/admin.php.
Local without Docker starts the worker yourself, then PHP:
cp config.sample.php config.php
# edit config.php: set apiKey and adminPassword
python3 python/worker.py serve &
php -S localhost:8080 -t public
Step 2: Choose How PHP Reaches Python
One config line, mlDriver, decides how the PHP front talks to the scikit-learn worker. service runs the worker as a tiny HTTP service on localhost, the recommended setup and what Docker wires automatically. cli has PHP run python3 worker.py per request, no daemon to manage, a good fit for light traffic on any box with Python. The main settings:
| Setting | What it does |
|---|---|
apiKey | The key clients must send with every API call |
adminPassword | Password for admin.php |
corsOrigin | Which browser origins may call the API |
dbPath | SQLite file location |
dataPath | Folder for datasets and trained models |
mlDriver | "service" or "cli", how PHP reaches the Python worker |
mlServiceUrl | Worker address, http://127.0.0.1:8750 local, http://ml:8750 in Docker |
pythonPath | Python executable for the cli driver |
retrainEvery | Default live training retrain interval in rows |
chatProvider + keys | Optional, only for the AI summaries endpoint |
Step 3: Create a Pipeline and Add Rows
Log into admin.php and create a pipeline. A pipeline holds one or more model steps, and most jobs want exactly one: pick a class, say a KNN classifier for text, and you have a working setup. Choosing a model walks the whole catalog with plain-language advice, and every class shows inline parameter help in the admin.
Then feed it examples. Add rows in the browser, an input and its label, like "refund my order" labeled billing, or push them in bulk through the API. Twenty or thirty rows per label is a fine starting point for a first classifier, and the dataset and training guide covers formats, bulk loading, and dataset habits that pay off.
Step 4: Train and Test
Click Train. The engine rebuilds the model from the complete dataset, vectorizing text and scaling numbers automatically, and reports how many rows it learned from. Then use the test box on the same page: type an input, see the prediction instantly. This tight loop, add rows, train, test, is how models actually get good, and it all happens on one admin page.
Step 5: Call Predict From Your App
Your application talks to one endpoint:
curl -X POST http://localhost:8080/api.php/predict \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{"pipelineID": 1, "input": "why was i charged twice"}'
The response is small and direct: {"output": "billing", ...}, plus each step's output when a pipeline has several. Send text for text models or a list of numbers for numeric models, and act on the answer in your code. Every endpoint and field is documented in the API reference.
Before You Go Live
Serve over HTTPS, keep the Python worker on localhost or a private network so it only ever hears from your own PHP app, the Docker setup already isolates it that way, and back up the data folder, it holds your datasets and trained models. When a model should keep learning from real traffic, flip on live training and the engine retrains itself as predictions flow.
Setup is one config file and one command: Docker starts the PHP app and Python worker together, or run them yourself with two commands. Create a pipeline, add labeled rows, click train, and your app is one POST away from real machine learning predictions on your own hardware.