Feature scaling is the process of normalizing or standardizing the numerical features in a dataset. It ensures that all features have a similar scale and range, preventing some features from dominating others due to their larger values. Feature scaling is important for algorithms that rely on distance-based calculations, such as K-nearest neighbors (KNN) and gradient descent-based optimization algorithms.
Example code:
# Example code illustrating feature scaling using standardization
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)