January 2018
Beginner to intermediate
316 pages
7h 14m
English
Before we move on with our hotel data, let's do a quick experiment with our iris data to see whether our SVD and PCA really give us the same components:
# import the Iris dataset from scikit-learnfrom sklearn.datasets import load_iris# load the Iris datasetiris = load_iris()# seperate the features and response variableiris_X, iris_y = iris.data, iris.targetX_centered = StandardScaler(with_std=False).fit_transform(iris_X)X_scaled = StandardScaler().fit_transform(iris_X)
# test if we get the same components by using PCA and SVDsvd = TruncatedSVD(n_components=2)pca = PCA(n_components=2) ...
Read now
Unlock full access