0% found this document useful (0 votes)
18 views2 pages

Data Preprocessing Techniques in ML

The document discusses techniques for preprocessing data including mean subtraction, normalization, PCA, and whitening. It also discusses preprocessing techniques specifically for deep learning with images such as centering data to zero by subtracting the mean image from all samples.

Uploaded by

mavoho1719
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Data Preprocessing Techniques in ML

The document discusses techniques for preprocessing data including mean subtraction, normalization, PCA, and whitening. It also discusses preprocessing techniques specifically for deep learning with images such as centering data to zero by subtracting the mean image from all samples.

Uploaded by

mavoho1719
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 1

Data Preprocessing

There are different techniques used in learning in order to improve the accuracy of the model
by preprocessing the data:

There are three common forms of data preprocessing a data matrix X, where we will assume
that X is of size [N × D] (N is the number of data, D is their dimensionality).

Figure 1.1: Preprocessing example 1

Figure 1.2: Preprocessing example 2

Mean subtraction Most common form of preprocessing. It involves subtracting the mean
across every individual feature in the data, and has the geometric interpretation of centring
the cloud of data around the origin along every dimension. In NumPy, this operation would
be implemented as: X -= [Link](X, axis = 0). With images specifically, for convenience it

1
2 Chapter 1 Data Preprocessing

can be common to subtract a single value from all pixels (e.g. X -= [Link](X)), or to do so
separately across the three color channels.

Normalization Refers to normalizing the data dimensions so that they are of approximately
the same scale. There are two common ways of achieving this normalization. One is to divide
each dimension by its standard deviation, once it has been zero-centered: (X /= [Link](X,
axis = 0)). Another form of this preprocessing normalizes each dimension so that the min and
max along the dimension is -1 and 1 respectively. It only makes sense to apply this preprocessing
if you have a reason to believe that different input features have different scales (or units), but
they should be of approximately equal importance to the learning algorithm. In case of images,
the relative scales of pixels are already approximately equal (and in range from 0 to 255), so it
is not strictly necessary to perform this additional preprocessing step.

PCA The reason why one would want to use PCA is if one expects that many of the features
are in fact dependent. This would be particularly handy for Naive Bayes where independence
is assumed. Most datasets are far too large to use PCA. Attention: PCA complexity is O(n3 ),
so more sophisticated methods are required. But if your dataset is small, and you don’t have
the time to investigate more sophisticated methods, then by all means go ahead and apply an
out-of-box PCA for feature selection.

Whitening Takes the data in the eigenbasis and divides every dimension by the eigenvalue
to normalize the scale. The geometric interpretation of this transformation is that if the input
data is a multi-variable Gaussian, then the whitened data will be a Gaussian with zero mean
and identity covariance matrix.

Deep Learning with images

For Deep Learning for images we will only use: center our data to zero. To do so, for each
pixel, compute its mean across all the dataset and subtract the resulting mean image to all the
training samples. If you have more than one channel (e.g. RGB) do it for each of the channels
separately.

Common questions

Powered by AI

Additional normalization on image data may be unnecessary when pixel values already share a relative scale, typically ranging from 0 to 255, which means their impact as input features is inherently equalized. This is particularly applicable to scenarios in deep learning models where centering data to zero sufficiently standardizes the input .

PCA is employed to reduce dimensionality when many features are inter-dependent, which violates the independence assumption central to algorithms like Naive Bayes. It helps in identifying the principal components and facilitates feature selection, making it useful in smaller datasets where computational complexity is not a limiting factor .

In deep learning for images, preprocessing primarily involves centering data to zero by computing and subtracting the mean per pixel across the dataset, potentially across each color channel separately, to maintain integrity of RGB values. This is distinct from standard techniques that might involve multiple normalization steps due to differing scales of non-image data .

The primary goal of mean subtraction in data preprocessing is to center the data cloud around the origin along every dimension, which facilitates easier analysis and interpretation of data patterns. It is implemented in NumPy by subtracting the mean across every individual feature, i.e., X -= np.mean(X, axis=0).

To ensure efficacy of data preprocessing in model accuracy, one should rigorously assess data dimensionality, scale, dependency, and normalization needs. Incorporating essential preprocessing steps like mean subtraction and feature scaling tailored to dataset characteristics, and selectively applying techniques such as PCA or whitening based on dataset size and dependencies, can substantially enhance accuracy outcomes .

The two common approaches for normalizing data dimensions are scaling each dimension by its standard deviation after zero-centering (X /= np.std(X, axis=0)) and rescaling each dimension so that the min and max are -1 and 1. The first approach is suitable when features have different units yet should hold equal importance, while the second approach is apt if the data's range needs uniformity across all features. For image data, the first method isn't necessary since pixel scales are already similar .

Whitening transforms the distribution of a multivariate Gaussian dataset into a Gaussian with zero mean and identity covariance. Geometrically, it normalizes the data's scale in the eigenbasis, effectively transforming it into a sphere in multi-dimensional space .

Feature scaling impacts learning algorithms by ensuring that all feature dimensions contribute equally to the model. It is critical for non-image data where features may vary vastly in their scales or units, otherwise this asymmetry would bias the algorithm towards features with larger scales, potentially leading to suboptimal models .

Despite PCA's computational intensity, it may be used out-of-box for feature selection when datasets are small and quick, straightforward feature extraction is needed without delving into more sophisticated techniques. It offers a balance of implementation simplicity and performance improvement in these contexts .

The computational challenge with PCA is its complexity, which is O(n³). This makes it inefficient for large datasets, as processing becomes computationally intensive. Therefore, simpler data reduction methods or inherently less complex algorithms might be preferred for practical feasibility unless advanced implementations or optimizations of PCA are utilized .

You might also like