How to Use PyTorch with Apple MPS Backend

Apple Silicon (M1, M2, M3, M4) brings a capable GPU integrated into the same die as the CPU, with shared memory that eliminates the PCIe data transfer bottleneck of discrete GPUs. PyTorch supports it via the Metal Performance Shaders (MPS) backend, available since PyTorch 1.12. For ML workloads that fit in the Mac’s unified memory, … Read more

Getting Started with JAX for Machine Learning

JAX is NumPy with automatic differentiation, JIT compilation, and hardware acceleration baked in. It is not a deep learning framework in the way PyTorch is — there are no built-in layers or optimisers. Instead, JAX gives you the primitives for building them: pure functional transformations (jit, grad, vmap, pmap) that compose cleanly and run efficiently … Read more

PyTorch 2.0 Compile Mode: A Practical Guide

PyTorch 2.0 introduced torch.compile(), a one-line speedup for PyTorch models. It compiles your model’s computation graph using TorchDynamo and TorchInductor, fusing operations and generating optimised kernels for your hardware. On NVIDIA GPUs, compile mode typically delivers 10–50% speedup with no changes to model architecture or training loop. This guide covers how to use it, what … Read more

PyTorch vs JAX: Which Should You Learn in 2026?

PyTorch and JAX both dominate modern deep learning research, but they make fundamentally different design choices. PyTorch is object-oriented, eager by default, and built around mutable tensors and a familiar Python programming model. JAX is functional, pure, and built around function transformations — you write plain Python functions and apply jit, grad, vmap, and pmap … Read more

TabNet vs XGBoost: Which Should You Use?

TabNet is a deep learning architecture designed specifically for tabular data. It uses sequential attention to select which features to focus on at each decision step — essentially learning feature selection and transformation jointly rather than relying on hand-crafted engineering. XGBoost is gradient boosted trees, the dominant tabular baseline for the past decade. The comparison … Read more

How to Save and Load an XGBoost Model

Saving and loading XGBoost models sounds trivial — and mostly it is — but there are enough format options, version compatibility nuances, and post-load gotchas (particularly around early stopping) to make it worth covering carefully. This guide covers every serialisation format XGBoost supports, when to use each, and what to watch out for. Format Overview … Read more

How to Use XGBoost with scikit-learn Pipelines

Wrapping XGBoost in a scikit-learn pipeline solves a problem that bites almost every ML project eventually: training-serving skew. When preprocessing steps live outside the model, it is easy for inference code to apply them slightly differently — wrong scaler, missing imputer, column order mismatch — producing silent errors that corrupt predictions without raising exceptions. A … Read more

XGBoost Cross-Validation Best Practices

Cross-validation gives you a reliable estimate of how an XGBoost model will perform on unseen data. A single train/test split is noisy — performance varies significantly depending on which samples happen to end up in the test set. Cross-validation reduces that variance by averaging over multiple splits. This guide covers how to do it correctly … Read more

XGBoost Multiclass Classification Guide

XGBoost handles multiclass classification with the same API as binary classification — just change the objective and let XGBoost figure out the rest. The model trains one set of trees per class (one-vs-all internally), outputs a probability for each class, and predicts the class with the highest probability. This guide covers the full workflow: training, … Read more

LightGBM for Imbalanced Classification

Imbalanced classification — fraud detection, medical diagnosis, churn prediction, rare event detection — is where default model settings fail most predictably. A model that predicts the majority class for every sample achieves 99% accuracy on a 1:99 dataset while being completely useless. LightGBM has several built-in mechanisms for imbalanced data, and combining them with the … Read more