相关疑难解决方法(0)

Algorithm to generate all unique permutations of fixed-length integer partitions?

I'm searching for an algorithm that generates all permutations of fixed-length partitions of an integer. Order does not matter.

For example, for n=4 and length L=3:

[(0, 2, 2), (2, 0, 2), (2, 2, 0),
 (2, 1, 1), (1, 2, 1), (1, 1, 2),
 (0, 1, 3), (0, 3, 1), (3, 0, 1), (3, 1, 0), (1, 3, 0), (1, 0, 3),
 (0, 0, 4), (4, 0, 0), (0, 4, 0)]
Run Code Online (Sandbox Code Playgroud)

I bumbled about with integer partitions + permutations for …

algorithm integer data-partitioning

6
推荐指数
1
解决办法
3451
查看次数

如何根据百分比将列表分成 3 部分?

我有一个文件列表,我想把它分成 3 部分:训练、验证和测试。我试过这段代码,我不知道它是否正确。

files = glob.glob("/dataset/%s/*" % emotion)
training = files[:int(len(files)*0.8)] #get first 80% of file list
validation = files[-int(len(files)*0.1):] #get middle 10% of file list
testing = files[-int(len(files)*0.1):] #get last 10% of file list
Run Code Online (Sandbox Code Playgroud)

我不确定测试列表是重复的还是文件列表的最后 10% 是正确的。

python

2
推荐指数
3
解决办法
4871
查看次数

标签 统计

algorithm ×1

data-partitioning ×1

integer ×1

python ×1