Thank you all for your input, Yes random is what I need!!
I checked the docs, and follow your comments, I will use both
random.sample and random.shuffle,and random.choice etc. !!

For this particular problem I think ramdom.shuffle() is what I need.

I was not very clear or complete in my explanation, and  I didn't
expect such a
discussion on my needs, now I'm embarrassed :) .

The list is a data set for training a machine learning algorithm. I
want to
use 70% of the records (random) for training, but then the remaining
30% are used for
validation. This is repeated a few times choose again 70% at random
for training and
the rest for validation.

With random.shuffle() I just iterate for the first 70% of the records
for training and
I just continue with the remaining 30%. This last 30% we dont care if
its random anymore,
so shuffle is doing some extra work as it was pointed out.
Conceptually something like this:

population = range(100)
training = random.sample(population,70)
validation = set(population).difference(set(training))

But I think this is more costly

Thanks Again
Mario
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to