Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Instacart Tech 13 min read Deep dive hardMaster

Leveraging PyFixest for High-Cardinality Marketplace Modeling at Instacart

Controlling for high-cardinality fixed effects (e.g. thousands of regions, shoppers or customers) makes standard OLS intractable, because each dummy variable expands the Gram matrix and matrix inversion scales as O(k³). The Frisch-Waugh-Lovell theorem removes the dummy variables by demeaning, and the method of alternating projections handles multiple fixed effects by iteratively demeaning until the residual falls below a tolerance. A worked example shows convergence at a geometric rate. The post covers Instacart Marketplace's geo:time switchback and static-geo experiment designs. Benchmarks up to 20k categories show pyfixest consistently fastest with trivial memory use, compared with statsmodels (pinv dummies and mixedlm) and scikit-learn's sparse LSQR solver.

Assumes: linear regression / OLSfixed effects modelslinear algebra basicsA/B experiment design

Related posts

  • Variance Reduction Below the Randomization Grain

    Instacart Tech hardMaster

    Instacart improves CUPED variance reduction for region-day switchback experiments by training an order-level model (gradient boosted trees) on pre-treatment features and aggregating its predictions to the region-day grain as the CUPED covariate. Across 10 lateness experiments, order-level CUPED cut variance by 18-40% versus 5-10% for region-day CUPED, shortening experiment runtimes by about a third on average. Features must be unaffected by treatment, and a placebo mean-difference test on the aggregated prediction catches contamination, as with ETA model experiments that shift which orders get placed. The approach applies wherever interference forces coarse cluster randomization but outcomes are observed at a finer unit.

  • TimesFM-3: A zero-shot foundation model for multivariate forecasting

    Google Research hardMaster

    TimesFM-3 is a 330M-parameter decoder-only transformer pre-trained on over 1 trillion real and synthetic time points that does zero-shot multivariate forecasting, supporting multiple targets, past-only covariates and known-future covariates. Series are split into 32-step patches with per-series normalization. Future-known covariates use lookahead tokens that concatenate the current patch with future patches. Layers alternate causal temporal attention within each series with full cross-variate attention at each time step. Contiguous Patch Masking replaces autoregressive patch-by-patch decoding, producing the whole horizon and 9 quantiles in one forward pass. It ranks first among pre-trained foundation models on Gift-Eval, FEV-Bench and Time against Chronos-2, Toto 2.0 and TimesFM-2.5, even in univariate mode, and is available on GitHub, Hugging Face and BigQuery's AI.FORECAST.

  • Introducing TabFM: A zero-shot foundation model for tabular data

    Google Research easyNovice

    TabFM is a foundation model that treats tabular classification and regression as in-context learning, so it predicts on an unseen table in a single forward pass with no training, hyperparameter tuning or feature engineering. Its hybrid architecture combines TabPFN-style alternating row and column attention, compression of each row into a dense vector, and a TabICL-style Transformer over the compressed rows to keep compute low on larger tables. It is pretrained entirely on hundreds of millions of synthetic datasets generated from structural causal models. On TabArena (38 classification and 13 regression datasets, 700 to 150K rows), it is reported to beat tuned tree-based baselines in Elo, and an ensemble variant adds cross and SVD features, NNLS weighting and Platt scaling. It is available on Hugging Face and GitHub and through BigQuery's AI.PREDICT.

  • Building a dynamic inventory optimisation system: A deep dive

    Zalando Engineering mediumAdept

    Zalando's ZEOS builds replenishment recommendations by minimising a cost function that combines storage, lost sales, overstock, operations and inbound costs. Probabilistic demand forecasts feed a Monte Carlo simulation engine with gradient-free black-box optimisers. The weekly forecasting pipeline runs LightGBM through Nixtla's MLForecast with conformal inference, does pre-processing in PySpark on Databricks and feature transforms on SageMaker, and covers 5 million SKUs over about 3 years of history in under 2 hours. The optimisation service shares features via SageMaker Feature Store (online lookups at 10–20ms per SKU, S3-backed offline store). It serves daily batch transform jobs plus an interactive SQS/Lambda path for partner setting changes, keeping both paths consistent.

  • Forecasting Using ClickHouse Machine Learning Functions

    ClickHouse mediumAdept

    ClickHouse's built-in stochasticLinearRegression and evalMLMethod functions can fit and apply time-series forecasting models entirely in SQL, with no Python or R. Using monthly flight passenger data, a log-transformed target is regressed on a linear trend plus 12 month dummy variables, with no intercept to avoid the dummy variable trap. One model per airline-airport pair is trained in a single GROUP BY query, giving 35 models. Test-set MAE and RMSE are computed in SQL, and a future-dates view extends the forecasts three years out. Wrapping training in a materialized view would let the models retrain continuously as new data arrives.

The quest for software engineering knowledge.

Look:
Layout: