【问题标题】:How to implement train, test, validation split in this code?如何在此代码中实现训练、测试、验证拆分?
【发布时间】:2022-11-27 11:50:45
【问题描述】:

所以我被要求实现拆分函数参数:80% 训练,10% 验证和 10% 测试。而且我不明白如何在这里做。请帮忙。谢谢。

    def plot_example(x_raw, y_raw):
  fig, axes = plt.subplots(3, 3)
  i = 0
  for i in range(3):
    for j in range(3):
      imgplot = axes[i,j].imshow(x_raw[i*3 + j], cmap = 'bone')
      axes[i,j].set_title(y_raw[i*3 + j])
      axes[i,j].get_yaxis().set_visible(False)
      axes[i,j].get_xaxis().set_visible(False)
  fig.set_size_inches(18.5, 10.5, forward=True)

## TODO: Implement the split function parameter: 80% train, 10% validation, and 10% test.
(ds_train, ds_val, ds_test), ds_info = tfds.load("colorectal_histology", 
                                           split=[],
                                           as_supervised=True, with_info=True)
df = tfds.as_dataframe(ds_train.shuffle(1000).take(1000), ds_info)

plot_example(df['image'], df['label'])
print(ds_info)

请解释

【问题讨论】:

    标签: python machine-learning scikit-learn sklearn-pandas


    【解决方案1】:

    【讨论】:

      最近更新 更多