Hi!
I'm looking for an alternative to the datasample function. It's a part of the Statistics & Machine Learning toolbox. Any ideas? I want to be able to sample rows of data from tables and matrices and would like to have the choice of sampling with/without replacement.
Thanks for your ideas!

5 件のコメント

Adam Danz
Adam Danz 2020 年 8 月 22 日
Are you sampling with replacement or without replacement?
Veena Chatti
Veena Chatti 2020 年 8 月 22 日
Hi Adam,
I am sampling with replacement. My dataset (of personally curated "ground truths") contains hundreds of samples, and I am using it to train a pattern recognition perceptron that needs 200,000 epochs at a reasonable learning rate.
Thanks,
Veena
Veena Chatti
Veena Chatti 2020 年 8 月 22 日
編集済み: Veena Chatti 2020 年 8 月 22 日
I think I've found a way to do it by converting the dataset to an array, combining a loop with randperm, and choosing one row at a time, but ideally, if someone knows about a function that does it in a more straightforward way that I just haven't come across yet, that would be fabulous. I eventually want to share my perceptron with others who may not have the toolbox, and it would be nice not to require that they have to buy it just for this one function!
Adam Danz
Adam Danz 2020 年 8 月 22 日
randperm samples without replacement.
To sample with replacement, use randi.
Veena Chatti
Veena Chatti 2020 年 8 月 26 日
Thanks. I think I have it now.

サインインしてコメントする。

 採用された回答

Kiran Felix Robert
Kiran Felix Robert 2020 年 8 月 26 日

0 投票

Hi Veena,
Yes, randomperm (without replacement) and randi (with replacement) can be used as an alternative.
Furthermore, if the dataset has been converted to either a matrix or an array format, the rows can be sampled without using a loop as shown in the example as follows,
X = rand(50,10); % Assume X is the dataset
SampledRows = X(randi(50,[200,1]),:); % 200 Sample rows (with replacement)
Kiran Felix Robert

1 件のコメント

Veena Chatti
Veena Chatti 2020 年 9 月 3 日
Thank you Kiran Felix Robert!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by