how to remove a number from 1 to 7 if I don't want this??

I have the code as :
rng(1,'twister');
index = randsample(N_of_data,prcnt_train);
train_labels(index) = rem(train_labels(index)+1,7)+1;
Actually, I have satellite image data set that actually have 7 classes labelled as:
1 2 3 4 5 7.... it has the class 6 but it is not mandatory.....
so I have the labels 1 2 3 4 5 7....
I have to introduce class label noise in satellite image dataset i.e. change their actual labels from the range 1 to 7 (excluding 6).....
Through 'rem' function I am changing their labels... This function also generate the label 6. But in actual, there is no need of that label as I don't have any class with this name in the dataset.....
So, what should I do to get only these labels 1 2 3 4 5 7...... and no label 6 should come i.e. number 6 should not be generated...
The problem is I can't replace the label 7 with 6 in the dataset as this is publicly available dataset from UCI repository.....
So how to write the code for it OR what changes should be made in 'rem' function??....

Answers (2)

I am not 100% sure I understand your question, but you can generate random samples from the vector 1:7 (except 6) like this:
>> randsample([1:5 7],100,'true')
Or generate from 1 to 6 and replace the 6's with 7's.

This question is closed.

Asked:

on 10 Jun 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!