,可以按照以下步骤进行:
import pandas as pd
import tensorflow as tf
data = {'Feature1': [1, 2, 3, 4, 5],
'Feature2': [6, 7, 8, 9, 10],
'Label': [0, 1, 0, 1, 0]}
df = pd.DataFrame(data)
def pandas_to_tf_dataset(dataframe, batch_size):
features = dataframe.drop('Label', axis=1)
labels = dataframe['Label']
dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels))
dataset = dataset.shuffle(len(dataframe)).batch(batch_size)
return dataset
batch_size = 2
dataset = pandas_to_tf_dataset(df, batch_size)
这个过程中涉及到的名词解释如下:
推荐的腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云