Case 2: Four Distinct Clusters
Well, I think that the model did good work. But what if we try to divide the points into 4 groups?
Oppgave
Swipe to start coding
- Import necessary libraries with their standard aliases. These are
pandas
(pd
),matplotlib.pyplot
(plt
),seaborn
(sns
), andKMeans
fromsklearn.cluster
. - Create a
KMeans
model object with 4 clusters. - Fit the
data
to themodel
. - Predict the labels for
data
. Save the result within the'prediction'
column ofdata
. - Build scatter plot for
'x'
and'y'
columns ofdata
with each point being painted with respect to the'prediction'
column.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 5
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 3.57
Case 2: Four Distinct Clusters
Sveip for å vise menyen
Well, I think that the model did good work. But what if we try to divide the points into 4 groups?
Oppgave
Swipe to start coding
- Import necessary libraries with their standard aliases. These are
pandas
(pd
),matplotlib.pyplot
(plt
),seaborn
(sns
), andKMeans
fromsklearn.cluster
. - Create a
KMeans
model object with 4 clusters. - Fit the
data
to themodel
. - Predict the labels for
data
. Save the result within the'prediction'
column ofdata
. - Build scatter plot for
'x'
and'y'
columns ofdata
with each point being painted with respect to the'prediction'
column.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 3.57Seksjon 1. Kapittel 5
single