在集群(Dask)上应用 Scikit-learn 时对数据位置的混淆

Confusion about the data location when applying Scikit-learn on cluster (Dask)

我目前正致力于通过 dask 将机器学习 (Scikit-Learn) 从单台机器实现到 Slurm 集群。根据一些教程(例如 https://examples.dask.org/machine-learning/scale-scikit-learn.html),使用 job_lib.parallel_backend('dask') 非常简单。但是,读入数据的位置让我感到困惑,none 教程中提到了它。我应该使用 dask.dataframe 读入数据以确保它被传递到集群,还是只使用 pd.dataframe 读入它并不重要(然后数据存储在其中的 RAM 中机器我 运行 Jupiter notebook)?

非常感谢。

如果您的数据足够小(在教程中),并且预处理步骤相当简单,那么可以使用 pandas 读入。这会将数据读入您的本地会话,而不是任何 dask workers。一旦您调用 with joblib.parallel_backend('dask'),数据将被复制到每个工作进程,scikit 工作将在那里完成。

如果你的数据很大或者你有密集的预处理步骤最好用dask“加载”数据,然后使用dask的内置preprocessing and grid search where possible. In this case the data will actually be loaded directly from the workers, because of dask's lazy execution paradigm. Dask's grid search will also cache repeated steps of the cross validation and can speed up computation immensely. More can be found here: https://ml.dask.org/hyper-parameter-search.html