what is the syntax to add noise in data set

I need the syntax to add noise to data set..
I hv write the code as:
rand_class_data = randsample(data(:,:),data*10/100);
y(rand_class_data)= ~y(rand_class_data);
wrong_labels = y;
%testing ensemble on noised data
losswith_noised_data = loss(ens_on_traindata, rand_class_data,wrong_labels)
--------------------------------------------------
the dataset im using is ''ionosphere'
I want to change the labels that i hd done with
y(rand_class_data)= ~y(rand_class_data);
but the problem is with data
i.e. how should i randsample the data??..
mean to say how to write
r = randsample(data(:,:),data*10/100);
the error is as :
"POPULATION must be a vector."
plz suggest me the right syntax to randsample the data

Answers (2)

may be using data(:)?
eg
rand_class_data = randsample(data(:),round(numel(data)*10/100))

1 Comment

yes .... u r right..... Actually my code is as follows:
data_set = load('ionosphere.txt');
data = data_set(:,1:end-1);
y = data_set(:, end);
train_data = data(1:2:end,:);
train_labels = y(1:2:end);
test_data = data(2:2:end,:);
test_labels = y(2:2:end);
then I had construct an ensemble by using training data as follows:
ens_on_traindata = fitensemble(train_data,train_labels,'AdaBoostM1',100,'tree','type','classification');
then determine then loss (misclassification) of the test data by using the ensemble i.e tested the performance of ensemble on test data as follows:
Losswith_test_data = loss(ens_on_traindata, test_data, test_labels);
Now I wants to analyze the sensitivity of AdaboostM1 and evaluate its performance in the presence of noise..... So thats why I have introduced the noise (classification noise) in the dataset by changing the labels of 10 % of the dataset....
In the Help of MATLAB 2011a, they have added the noise in the artificial dataset...... I tried to use the same with ionosphere dataset, but the problem is with the syntax i.e. in what way I should write the data..
and how to write the randsample( , );
plz can u help me in this regard..??

Sign in to comment.

Your question is still active here. Please do not ask duplicate questions.

Asked:

on 30 May 2012

Community Treasure Hunt

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

Start Hunting!