How to shuffle data at the same way EVERYTIME random.seed(42)
45 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi guys,
I am looking for a way to shuffle and split my data to test 2 methods. I use 'shuffle' before using 'spliteachlabel'.
The reason I use shuffle is that I want to test many time, but shuffle will random shuffle my data without uncontronable which make the result unfair since the data is run for each method are not the same. So I wonder that there is a way to make the shuffle function run at exactly way.
I got the similar idea in Python, but dont know how to make it in Matlab
random.seed(42)
random.shuffle(imagePaths)
0 Kommentare
Antworten (1)
David Goodmanson
am 27 Sep. 2020
Bearbeitet: David Goodmanson
am 27 Sep. 2020
Hi RG
rng(12345) % for example
rand
rand
rng(12345)
rand % same values as before
rand
see help rand for more examples
2 Kommentare
Steven Lord
am 1 Okt. 2020
cards = ["A", 2:10, "J", "Q", "K"] + [" spade"; " club"; " diamond"; " heart"];
rng(12345)
order = randperm(numel(cards));
shuffledDeck1 = cards(order);
rng(12345)
order2 = randperm(numel(cards));
shuffledDeck2 = cards(order2);
isequal(shuffledDeck1, shuffledDeck2) % true
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!