Orange Forum • View topic - How do you set rand seed on MakeRandomIndices2

How do you set rand seed on MakeRandomIndices2

A place to ask questions about methods in Orange and how they are used and other general support.

How do you set rand seed on MakeRandomIndices2

Postby greenturtleshell » Sun Dec 29, 2013 20:44

When I use MakeRandomIndices2, the random seed is always the same. How do you set the seed?This is my program:

def test_rnd_sampling(data, learners, p=0.7, n=10):
acc = [0.0]*len(learners)
for i in range(n):
selection = orange.MakeRandomIndices2(data, p)
train_data = data.select(selection, 0)
test_data = data.select(selection, 1)
classifiers = []
for l in learners:
classifiers.append(l(train_data))
acc1 = accuracy(test_data, classifiers)
print "%d: %s" % (i+1, acc1)
for j in range(len(learners)):
acc[j] += acc1[j]
for j in range(len(learners)):
acc[j] = acc[j]/n
return acc

Re: How do you set rand seed on MakeRandomIndices2

Postby Ales » Thu Jan 02, 2014 19:12

Use the 'randseed' parameter
Code: Select all
selection = orange.MakeRandomIndices2(data, p, randseed=10)

Re: How do you set rand seed on MakeRandomIndices2

Postby greenturtleshell » Mon Jan 13, 2014 2:48

What I mean is how do you make the randseed different every time you run the program?

Re: How do you set rand seed on MakeRandomIndices2

Postby Ales » Tue Jan 14, 2014 20:13

greenturtleshell wrote:What I mean is how do you make the randseed different every time you run the program?
You can initialize it from the current time, read from /dev/urandom, etc.


Return to Questions & Support