The Pandas Function API (applyInPandas) is used for which ML use case?
Select an answer to reveal the explanation.
Short Explanation
applyInPandas is the pattern for 'many models' — group by store, ship each group's data to a worker as a pandas DataFrame, train a model on it, and return predictions. Thousands of micro-models trained in parallel.
Full Explanation
applyInPandas (grouped DataFrame operation) enables the 'many models' pattern: df.groupBy('store_id').applyInPandas(train_and_predict, schema=output_schema). For each group (store), Spark sends the group's data as a pandas DataFrame to a worker. The user-defined function receives a pandas DataFrame, can train any sklearn/statsmodels/custom model on it, and returns a pandas DataFrame with predictions. Use cases: per-store demand forecasting, per-user recommendation models, per-device anomaly detection. This pattern scales to thousands of micro-models. For applying a pre-trained global model, Pandas UDFs (@pandas_udf with function API) are more appropriate. For PyTorch integration, use frameworks like Petastorm or PyTorch DataLoader with Spark. VectorAssembler is not replaceable by applyInPandas.
Prefer to study offline? Printable PDF study book + test engine ($7.50, unofficial). These questions stay free here.