plt.xlabel('Index') plt.ylabel('Latent Variable 1') plt.title('Metric MDS 1-Dimension Plot with Observation Class') plt.scatter(mds_dim[:, 0], list(alldata.index), c=y) plt.colorbar() plt.show() ''' ------------------------------------------------------------------------------- -----------------------------------Isomap-------------------------------------- ------------------------------------------------------------------------------- ''' #Apply isomap embedding, keeping n components < the number of original features iso_model = Isomap(n_neighbors=5, n_components=2) iso_model.fit_transform(x_std) print(iso_model.get_params()) iso_dim = iso_model.embedding_ print(iso_dim.shape) #There should be 2 latent variables represented #Plot first 2 extracted features and the observation class plt.figure(figsize=(10, 5)) plt.xlabel('Latent Variable 1 (explains most variance)') plt.ylabel('Latent Variable 2 (explains second most variance)') plt.title('Isomap 2-Dimension Plot with Observation Class') plt.scatter(iso_dim[:, 0], iso_dim[:, 1], c=y) plt.colorbar() plt.show() #Apply isomap for many different choices of dimensions #Limitation is that nbr dimensions must be < the number of original features nbr_dim = range(3)