ArticleslgStudy

mathematics

Feature scaling

Feature scaling is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Feature scaling rather than just read about it. In short: Feature scaling is a method used to normalize the range of independent variables or features of data. In data processing, it is also known as data normalization and is generally performed during the data preprocessing step.

Feature scaling — main illustration
Feature scaling — illustration

Key takeaways

  • Feature scaling belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Feature scaling to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Feature scaling from memory before moving on to harder problems.

Reference excerpt

Feature scaling is a method used to normalize the range of independent variables or features of data. In data processing, it is also known as data normalization and is generally performed during the data preprocessing step.

Motivation Since the range of values of raw data varies widely, in some machine learning algorithms, objective functions will not work properly without normalization. For example, many classifiers calculate the distance between two points by the Euclidean distance. If one of the features has a broad range of values, the distance will be governed by this particular feature. Therefore, the range of all features should be normalized so that each feature contributes approximately proportionately to the final distance. Another reason why feature scaling is applied is that gradient descent converges much faster with feature scaling than without it. It's also important to apply feature scaling if regularization is used as part of the loss function (so that coefficients are penalized appropriately). Empirically, feature scaling can improve the convergence speed of stochastic gradient descent. In support vector machines, it can reduce the time to find support vectors. Feature scaling is also often used in applications involving distances and similarities between data points, such as clustering and similarity search. As an example, the K-means clustering algorithm is sensitive to feature scales.

Methods

Rescaling (min-max normalization) Also known as min-max scaling or min-max normalization, rescaling is the simplest method and consists in rescaling the range of features to scale the range in [0, 1] or [−1, 1]. Selecting the target range depends on the nature of the data. The general formula for a min-max of [0, 1] is given as:

x′=x−min(x)max(x)−min(x) where x is an original value, x′ is the normalized value. For example, suppose that we have the students' weight data, and the students' weights span [160 pounds, 200 pounds]. To rescale this data, we first subtract 160 from each student's weight and divide the result by 40 (the difference between the maximum and minimum weights). To rescale a range between an arbitrary set of values [a, b], the formula becomes:

x′=a+(x−min(x))(b−a)max(x)−min(x) where a,b are the min-max values.

Mean normalization x′=x−x¯max(x)−min(x) where x is an original value, x′ is the normalized value, x¯=average(x) is the mean of that feature vector. There is another form of the means normalization which divides by the standard deviation which is also called standardization.

Standardization (Z-score Normalization)

In machine learning, we can handle various types of data, e.g. audio signals and pixel values for image data, and this data can include multiple dimensions. Feature standardization makes the values of each feature in the data have zero-mean (when subtracting the mean in the numerator) and unit-variance. This method is widely used for normalization in many machine learning algorithms (e.g., support vector machines, logistic regression, and artificial neural networks). The general method of calculation is to determine the distribution mean and standard deviation for each feature. Next we subtract the mean from each feature. Then we divide the values (mean is already subtracted) of each feature by its standard deviation.

x′=x−x¯σ Where x is the original feature vector, x¯=average(x) is the mean of that feature vector, and σ is its standard deviation.

Robust Scaling Robust scaling, also known as standardization using median and interquartile range (IQR), is designed to be robust to outliers. It scales features using the median and IQR as reference points instead of the mean and standard deviation:x′=x−Q2(x)Q3(x)−Q1(x)where Q1(x),Q2(x),Q3(x) are the three quartiles (25th, 50th, 75th percentile) of the feature.

Unit vector normalization Unit vector normalization regards each individual data point as a vector, and divide each by its vector norm, to obtain x′=x/‖x‖. Any vector norm can be used, but the most common ones are the L1 norm and the L2 norm. For example, if x=(v1,v2,v3), then its Lp-normalized version is:(v1(|v1|p+|v2|p+|v3|p)1/p,v2(|v1|p+|v2|p+|v3|p)1/p,v3(|v1|p+|v2|p+|v3|p)1/p)

See also Normalization (machine learning) Normalization (statistics) Standard score fMLLR, Feature space Maximum Likelihood Linear Regression

References

Further reading Han, Jiawei; Kamber, Micheline; Pei, Jian (2011). "Data Transformation and Data Discretization". Data Mining: Concepts and Techniques. Elsevier. pp. 111–118. ISBN 9780123814807.

External links Lecture by Andrew Ng on feature scaling Archived 2017-03-14 at the Wayback Machine

Worked examples

Example 1 — a first encounter with Feature scaling

Start with the simplest possible case. Write down what Feature scaling claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Feature scaling before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Feature scaling ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Feature scaling

In research
Feature scaling appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Feature scaling in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Feature scaling is common in secondary-school and first-year university syllabi. It links to neighbouring topics Machine learning, Statistical data transformation, so understanding it makes those chapters shorter.
In everyday life
Look for Feature scaling outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Feature scaling” →

How to study Feature scaling in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Feature scaling means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Feature scaling out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Feature scaling in simple terms?

Feature scaling is a method used to normalize the range of independent variables or features of data. In data processing, it is also known as data normalization and is generally performed during the data preprocessing step.

Why does Feature scaling matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Feature scaling?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Feature scaling.

Tags

  • Machine learning
  • Statistical data transformation

Keep exploring