Feature Scaling & Encoding
[markdown] content available only on the platform
[markdown] content available only on the platform
Flashcards · Feature Scaling & Encoding
Scale dominance — A feature with large raw values outweighing others in distance or gradient calculations just because of its scale.
Area 30-200 m² swamping bedrooms 1-5.
Min-Max normalization — Rescales a column into [0, 1] using its minimum and maximum; very sensitive to outliers.
MinMaxScaler().fit_transform(X_train)
z-score standardization — Rescales a column to mean 0 and standard deviation 1; output is unbounded and less outlier-sensitive.
StandardScaler().fit_transform(X_train)
scaler.fit_transform() — Learns the scaling statistics from the data and transforms it in one step; use it on the training set.
x_train = scaler.fit_transform(x_train)
scaler.transform() — Applies statistics already learned from train to new data, such as the test set.
x_test = scaler.transform(x_test)
pd.get_dummies() — pandas function that one-hot encodes chosen columns into 0/1 columns per category.
pd.get_dummies(data, columns=["city"], dtype=int)
Series.map() — Replaces each value using a dictionary; a simple way to ordinal-encode ordered categories.
data["size"].map({"S": 0, "M": 1, "L": 2})
Distance-based algorithm — An algorithm that compares examples by distance, so it is strongly affected by feature scale.
KNN, SVM
