Scaling fish data for clustering
You are given an array samples giving measurements of fish. Each row represents an individual fish. The measurements, such as weight in grams, length in centimeters, and the percentage ratio of height to length, have very different scales. In order to cluster this data effectively, you'll need to standardize these features first. In this exercise, you'll build a pipeline to standardize and cluster the data.
These fish measurement data were sourced from the Journal of Statistics Education.
Latihan ini adalah bagian dari kursus
Unsupervised Learning in Python
Petunjuk latihan
- Import:
make_pipelinefromsklearn.pipeline.StandardScalerfromsklearn.preprocessing.KMeansfromsklearn.cluster.
- Create an instance of
StandardScalercalledscaler. - Create an instance of
KMeanswith4clusters calledkmeans. - Create a pipeline called
pipelinethat chainsscalerandkmeans. To do this, you just need to pass them in as arguments tomake_pipeline().
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Perform the necessary imports
from ____ import ____
from ____ import ____
from ____ import ____
# Create scaler: scaler
scaler = ____
# Create KMeans instance: kmeans
kmeans = ____
# Create pipeline: pipeline
pipeline = ____