Files
labs/Module-3/2.Standardizing.ipynb

3.7 KiB

To standardize a feature means to shift all of its values so that their mean = 0 and to scale them so that their variance = 1

Load data

In [ ]:
import pandas as pd
data = pd.read_csv("file_pe_headers.csv", sep =",")
X = data.drop(["Name", "Malware"], axis=1).to_numpy()
In [ ]:
print(X.shape)
print(X)

standarize data

In [ ]:
# Next standarize x using StandardScaler instance
from sklearn.preprocessing import StandardScaler
In [ ]:
### standarize 1-dimension data
In [ ]:
# get e_lfanew
data1st = X[:,16].reshape(-1, 1)
print(data1st.shape)
print(data1st)
In [ ]:
data1st_standardized = StandardScaler().fit_transform(data1st)

print(data1st_standardized.shape)
In [ ]:
print(data1st_standardized)

standarize multi-dimension data

In [ ]:
X_standardized = StandardScaler().fit_transform(X)

print(X_standardized.shape)
In [ ]:
print(X_standardized)

It is important to standardize features because performance is highly sensitive to the relative scale of features.

In [ ]:
In [ ]:
In [ ]: