I have 5 vertical strings which were generated in order of probability by my classifier. If the classifiers confidence was very high I want to keep that classification but for the low ones I would like to vary between all possible orders of combinations creating a list of all possible vertical strings.
so my data looks like this:
aa aa aa aa aa
ab ac aa ad ae
aa ab af ae ag
and I would like to get all of the possible ordered combinations
aa aa aa aa aa aa aa aa aa aa ...
ab ac aa ad ae ae ab ac aa ad ...
aa ab af ae ag aa ab af ae ag...
I tried itertools but I can't seem to find the right tool to do this. Does anyone know how to do this?
This is what I have tried so far:
import sys
import os
import itertools
from itertools import permutations
in_file = sys.argv[1]
f1 = open(in_file, 'r')
new_lines = []
for line in f1.readlines():
line = line.strip()
do stuff to replace my higher confidence matches...
new_lines.append(line)
for x in new_lines:
for a,b,c,d,e,f,g,h,i,j in permutations(x.split(), 10):
print '{} {} {} {} {} {} {} {} {} {}'.format(a.rstrip('\n'), b.rstrip('\n'), c.rstrip('\n'), d.rstrip('\n'), e.rstrip('\n'), f.rstrip('\n'), g.rstrip('\n'), h.rstrip('\n'), i.rstrip('\n'), j.rstrip('\n'))
I tested this with 10 to make make sure it didn't explode but this does not seem to work the way I thought it would. If I put 5 it just gives me the same list I had before. Is there a way I can do this?