Data Preparation Flashcards

1
Q

Normalization formula (scaling)

A

Xnorm = (X - Xmin) / (Xmax-Xmin)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Normalization code (scaling)

A

importing the Normalizer from sklearn

from sklearn.preprocessing import Normalizer
#Creating a sample data array
X = [[4, 1, 2, 2],[1, 3, 9, 3],[5, 7, 5, 1]]
transformer = Normalizer().fit(X) # fit does nothing.
transformer
Normalizer()
transformer.transform(X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Standardization formula (Z-score normalizing)

A

Xstand = (X - mean(X)) / std(X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Standardization code (Z-score normalizing)

A

importing the StandardScaler from sklearn

from sklearn.preprocessing import StandardScaler
#Creating a sample data array
data = [[0, 0], [0, 0], [1, 1], [1, 1]]
scaler = StandardScaler()
print(scaler.fit(data))
print(scaler.mean_)
print(scaler.transform(data))
print(scaler.transform([[2, 2]]))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly