Selected topic
Data Scaling
Prefer practical output? Use related tools below while reading.
Data scaling, also known as normalization, is a technique used in data preprocessing to scale the values of numerical features so that they fall within a common range. This helps to prevent features with large ranges from dominating the model and improves the stability of algorithms.
python
import pandas as pd# Create a sample dataframe
data = {
'Exam1': [90, 80, 70],
'Exam2': [40, 50, 60]
}
df = pd.DataFrame(data)
print(df)
Exam1 Exam2
0 90 40
1 80 50
2 70 60python
from sklearn.preprocessing import MinMaxScalerscaler = MinMaxScaler(feature_range=(0, 100))
df_scaled = scaler.fit_transform(df)
print(df_scaled)
Exam1 Exam2
0 90.0 40.0
1 80.0 50.0
2 70.0 60.0MinMaxScaler maps the exam scores to a common range [0, 100], making it easier to compare and analyze the data.python
import pandas as pd
from sklearn.preprocessing import MinMaxScaler# Create a sample dataframe
data = {
'Exam1': [90, 80, 70],
'Exam2': [40, 50, 60]
}
df = pd.DataFrame(data)
scaler = MinMaxScaler(feature_range=(0, 100))
df_scaled = scaler.fit_transform(df)
print(df_scaled)
MinMaxScaler.