July 2019
Beginner to intermediate
740 pages
16h 52m
English
When we plotted out the period versus semi-major axis for all the planets using a log scale for the period, we saw a nice separation of the planets along an arc. We are going to use k-means to find groups of planets with similar orbits along that arc.
As we discussed in the Preprocessing data section, we can build a pipeline to isolate the scaling of our data, culminating with the KMeans object to make eight clusters (for the number of planets in our solar system):
>>> from sklearn.cluster import KMeans>>> from sklearn.pipeline import Pipeline>>> from sklearn.preprocessing import StandardScaler>>> kmeans_pipeline = Pipeline([... ('scale', StandardScaler()), ... ('kmeans', KMeans(8, random_state=0)) ...Read now
Unlock full access