Machine learning¶
These examples live in the companion repository ubunye-ai-ecosystems/ubunye-examples. Run the commands from a clone of it (setup per place).
Training models and using them. Two examples: the full lifecycle done properly, and the same model built in three frameworks to prove the engine does not care which one you pick.
04 · The full lifecycle¶
Build features with a deterministic split, train, judge the model on rows it never saw, pass a quality gate, register, promote to production, then score new data with whatever model is in production. A model that fails the gate is never registered at all.
Open the notebooks under examples/04_ml_taxi_fare/notebooks/ in order,
or run the whole chain:
Seed once (see Start here), then run the three tasks in order:
10 · One model, three frameworks¶
The same model trained in scikit-learn, PyTorch and TensorFlow, behind three config files that are byte for byte identical. A build check keeps them identical. It ends in a leaderboard honest enough to say "too close to call" instead of crowning a half-percent lead.
The three trainers run in parallel, then the judge waits for all three.
TensorFlow needs numpy<2, so install the pinned trio first:
The ml image already carries all three frameworks, pinned correctly:
docker run --rm --entrypoint bash \
-e BENCH_MODEL_STORE=/data/model_store ubunye-ml:ci -c \
'. platforms/spark_env.sh && python platforms/seed.py && \
platforms/run_task.sh examples/04_ml_taxi_fare taxi_fare ml feature_engineering && \
platforms/run_task.sh examples/10_ml_frameworks fare_bench ml \
train_sklearn train_torch train_keras select_champion'
The examples repo has no ready manifest for this one, so here is the
Docker command wrapped in a Job. It follows platforms/k8s/job-template.yaml,
with the ubunye-ml:ci image and at least 5Gi of memory: three frameworks
is a real appetite. Save it as job-ml-frameworks.yaml, then
kubectl apply -f job-ml-frameworks.yaml:
apiVersion: batch/v1
kind: Job
metadata:
name: ubunye-ml-frameworks
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: ubunye
image: ubunye-ml:ci
imagePullPolicy: Never # side-loaded into kind
command: ["bash", "-c"]
args:
- >-
. platforms/spark_env.sh && python platforms/seed.py &&
platforms/run_task.sh examples/04_ml_taxi_fare taxi_fare ml feature_engineering &&
platforms/run_task.sh examples/10_ml_frameworks fare_bench ml
train_sklearn train_torch train_keras select_champion
env:
- name: BENCH_MODEL_STORE
value: /data/model_store
- name: DATA_DIR
value: /data
volumeMounts:
- name: data
mountPath: /data
resources:
requests: { memory: "5Gi", cpu: "2" }
limits: { memory: "7Gi" }
volumes:
- name: data
emptyDir: {}
Follow it with kubectl logs -f job/ubunye-ml-frameworks.