April 2019
Intermediate to advanced
426 pages
11h 13m
English
By default, the KernelPCA is instantiated with the n_components=None parameter, which constructs a kernel PCA with non-zero components. We can also create a PCA index with five components:
In [ ]: import numpy as np kernel_pca = KernelPCA(n_components=5).fit(df_z_components) pca_5 = kernel_pca.transform(-daily_df_components) weights = fn_weighted_avg(kernel_pca.lambdas_) reconstructed_values = np.dot(pca_5, weights) # Combine DJIA and PCA index for comparison df_combined = djia_2017.copy() df_combined['pca_5'] = reconstructed_values df_combined = df_combined.apply(fn_z_score) df_combined.plot(figsize=(12, 8));
With the fit() method, we fitted the normalized dataset using the linear kernel PCA function ...
Read now
Unlock full access