I am using Iris dataset and trying to scale the feature to the range [0,1]
. After normalization, I want to binarize the feature. The iris database contains n = 150 examples, each of length d = 4 features. One method is to normalize using the standard deviation applying the formula :
scaled_data = data - mean of data /standard deviation of data
Implementing it gives,
iris_data = load('iris.mtx');
y = load('iris.truth');
y = y + 1;
[n,d] = size(iris_data);
for d = 1:d
scaled_data(:,d) = (iris_data(:,d)- mean(iris_data(:,d))/std(iris_data(:,d))
end
As an example, I generated random numbers from the Uniform distribution in the range [0.1,9] as
a = 0.1;
b = 8;
r = (b-a).*rand(1000,1) + a;
scaled_data = (r - mean(r))/std(r);
But, this does not scale the values to [0,1]
!! The output of scaled_data is in [-1.75,1.7]
But, I am unsure if this is the correct way to do so - should I scale across the rows or across the columns and how?
Problem 1: Please help in how to properly scale the feature to the [0,1] range . How to normalize data to 0-1 range?
explains the procedure
data = (data - min(data))/(max(data)-min(data));
but what is the name for this procedure and for a feature database, should I be scaling using each example or each feature variable?
Problem 2: then to convert to 0/1.
Few samples from the iris dataset are:
iris_data =
5.10000000000000 3.50000000000000 1.40000000000000 0.200000000000000
4.90000000000000 3 1.40000000000000 0.200000000000000
4.70000000000000 3.20000000000000 1.30000000000000 0.200000000000000
4.60000000000000 3.10000000000000 1.50000000000000 0.200000000000000
5 3.60000000000000 1.40000000000000 0.200000000000000