def next_batch(df, i=None):
"""
:param df: pandas dataframe
:param i: batch index
:return: (numpy array x, numpy array y)
"""
if i is None:
start = 0
end = df.shape[0]
else:
start = BATCH_SIZE * i
end = BATCH_SIZE * (i + 1)
result = df[start:end]
if "Survived" in result:
batch_ys = pd.get_dummies(result.pop('Survived').values).as_matrix()
batch_xs = result.as_matrix()
return batch_xs, batch_ys
else:
return result.as_matrix()
评论列表
文章目录