首页 > 解决方案 > 从 Dask DataFrame (tensorflow_decision_forests) 创建 Keras 数据集

问题描述

我正在使用 Dask 加载一个非常大的数据集(比我拥有的可用 RAM 大得多),存储在 SQLite 数据库中,如下所示:

df = dd.read_sql_table("22", "sqlite:///db.sqlite", index_col="id")

然后,我想用tensorflow_decision_forests一些模型来尝试拟合数据。根据 的文档tensorflow_decision_forests,以下内容适用于 Pandas DataFrames:

import tensorflow_decision_forests as tfdf
train_ds = tfdf.keras.pd_dataframe_to_tf_dataset(df, label="species")
model = tfdf.keras.RandomForestModel()
model.fit(train_ds)

但是,当我tfdf.keras.pd_dataframe_to_tf_dataset在 Dask DataFrame 中使用时,很长一段时间都没有发生任何事情,然后 python 突然被一个SIGTERM信号终止了。我猜这不是将 Dask DataFrame 转换为 Keras 数据集的正确方法,尽管没有引发错误/异常。使用 Keras 存储在 Dask DataFrames 中的数据的正确方法是什么?具体来说,将 Dask DataFrame 转换为 Keras 数据集的正确方法是什么?

标签: pythondataframetensorflowkerasdask

解决方案


推荐阅读