Created
March 14, 2022 17:23
-
-
Save peeush-agarwal/067fa7895587064b3ed7a4693e62c727 to your computer and use it in GitHub Desktop.
PCA: standardize the wine dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.model_selection import train_test_split | |
from sklearn.preprocessing import StandardScaler | |
# split into training and testing sets | |
X, y = df_wine.iloc[:, 1:].values, df_wine.iloc[:, 0].values | |
X_train, X_test, y_train, y_test = train_test_split( | |
X, y, test_size=0.3, | |
stratify=y, random_state=0 | |
) | |
# standardize the features | |
sc = StandardScaler() | |
X_train_std = sc.fit_transform(X_train) | |
X_test_std = sc.transform(X_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment