plz tell the syntax to add noise in the dataset

2 views (last 30 days)
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..??
  1 Comment
Walter Roberson
Walter Roberson on 31 May 2012
duplicate is at http://www.mathworks.com/matlabcentral/answers/39830-what-is-the-syntax-to-add-noise-in-data-set

Sign in to comment.

Answers (1)

Ilya
Ilya on 31 May 2012
Use cvpartition to select a known fraction of your data at random. For example, flip class labels in 10% of the data:
>> load ionosphere
>> Y = strcmp('g',Y); % convert Y to a logical array
>> cvpart = cvpartition(size(X,1),'holdout',0.1) % sampling without stratification
cvpart =
Hold-out cross validation partition
N: 351
NumTestSets: 1
TrainSize: 316
TestSize: 35
>> idxToFlip = test(cvpart); % labels to flip
>> Y(idxToFlip) = ~Y(idxToFlip);
Instead of non-stratified sampling, you might want to stratify by class:
>> cvpart = cvpartition(Y,'holdout',0.1) % sampling with stratification

Community Treasure Hunt

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

Start Hunting!