我有两个叫做数据和标签的python np.arrays。我想随机缩小它们的大小。为此,我正在做以下事情:
var letters = ['link1','link2','link3','link4','link5','link6','link7','link8'];
for ( var k = 0; k < 3; k++){
iimset("POS", letters[parseInt(Math.random() * (letters.length - 1))]);
var congdong;
congdong = "CODE:";
congdong += "VERSION BUILD=8970419 RECORDER=FX" + "\n";
congdong += "SET !ERRORIGNORE YES" + "\n";
congdong += "TAB T=1" + "\n";
congdong += "URL GOTO={{POS}}" + "\n";
iimPlay(congdong)
}
我从标签和数据中随机选取50000。如何存储其余数据,以便能从初始数组中找到其余索引吗?
答案 0 :(得分:1)
如果你想“随机”减小尺寸,我会非常反对使用种子...
除此之外,使用boolean masking:
INPUT:
1
2
3
4
OUTPUT:
3
4
如果您想将数据减少一定数量,我可以考虑以下几点:
mask = np.ones(len(data), dtype=bool)
mask[ind] = False
reduced_data = data[~mask] #completely similar to data[ind]
rest_data = data[mask]