本文整理汇总了Python中Dataset.Dataset.getRandomPercent方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.getRandomPercent方法的具体用法?Python Dataset.getRandomPercent怎么用?Python Dataset.getRandomPercent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.getRandomPercent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from Dataset import Dataset [as 别名]
# 或者: from Dataset.Dataset import getRandomPercent [as 别名]
folds=['2-fold', '5-fold', 'N-fold']
for ds in alcohol_datasets:
train_data_all = ds[0].data
test_data = ds[1].data
# Accuracy for get 20%, 50%, 80% and 100% of the data.
# Each subset will have
train_accuracy = [[np.zeros(num_k_values), np.zeros(num_k_values), np.zeros(num_k_values)],
[np.zeros(num_k_values), np.zeros(num_k_values), np.zeros(num_k_values)],
[np.zeros(num_k_values), np.zeros(num_k_values), np.zeros(num_k_values)],
[np.zeros(num_k_values), np.zeros(num_k_values), np.zeros(num_k_values)]]
best_k_and_ds = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
for it in range(5):
train_data_20, t = Dataset.getRandomPercent(train_data_all, 0.2)
train_data_50, t = Dataset.getRandomPercent(train_data_all, 0.5)
train_data_80, t = Dataset.getRandomPercent(train_data_all, 0.8)
all_training_data = [train_data_20,
train_data_50,
train_data_80,
train_data_all]
# Only run on train_data_all once.
if it > 0:
all_training_data = all_training_data[:-1]
for val in range(len(all_training_data)):
for k in k_values:
print str(it) + ": Training on: " + labels[val] + "for k value: " + str(k) + " for " + ds[0].name
# Do 2-5-N Fold Cross Validation.
cv_2 = Dataset.getkPartitions(all_training_data[val], 2)
cv_5 = Dataset.getkPartitions(all_training_data[val], 5)