Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to fixed specific results for times of implementation

1 回表示 (過去 30 日間)
muhammad ismat
muhammad ismat 2016 年 3 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Accuracy=off(data,z)
for i=1:100
n = size(data,1);
data_rand = data(randperm(n),:);
m = ceil(n/20);
k = 1:m:n-m;
test = data_rand(k:k+m-1,:);
train = [data_rand(1:k-1,:); data_rand(k+m:end,:)];
here code for calculate auc
end
accuracy=mean(auc)
the previous code every time change the values of test and train variables, so the value of auc is changed every time.
say the final result is
accuracy=0.7654 and in another time
accuracy=0.6543 and
accuracy=0.4657
but i want to fixed the specific result say 0.6543 i.e if i run previous code more times will give the same results (0.6543)

回答 (1 件)

MHN
MHN 2016 年 3 月 4 日
編集済み: MHN 2016 年 3 月 4 日
Use
rng(1,'twister')
at top of your code. It controls random number generation functions and you will always see the same result as long as you do not change the seed (e.g. 1) and generator method (e.g. twister).

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by