Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Setting Parameters: Affinity | Spectral Clustering
Cluster Analysis in Python
course content

Conteúdo do Curso

Cluster Analysis in Python

Cluster Analysis in Python

1. K-Means Algorithm
2. K-Medoids Algorithm
3. Hierarchical Clustering
4. Spectral Clustering

Setting Parameters: Affinity

Well, that was not the result we were looking for. Can we improve it? Can we make the clustering algorithm learn to differ such structures?

The answer is yes - we need to set some parameters within the SpectralClustering function. The parameter we should change is affinity. This parameter defines how should affinity matrix be built (the math explanation of this is outside the scope of this course). By default, the parameter's value is 'rbf'. If we want to differ the clusters with such a structure as in the previous chapter, we should consider the 'nearest_neighbors' value of the parameter.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 4. Capítulo 3
toggle bottom row

Setting Parameters: Affinity

Well, that was not the result we were looking for. Can we improve it? Can we make the clustering algorithm learn to differ such structures?

The answer is yes - we need to set some parameters within the SpectralClustering function. The parameter we should change is affinity. This parameter defines how should affinity matrix be built (the math explanation of this is outside the scope of this course). By default, the parameter's value is 'rbf'. If we want to differ the clusters with such a structure as in the previous chapter, we should consider the 'nearest_neighbors' value of the parameter.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 4. Capítulo 3
toggle bottom row

Setting Parameters: Affinity

Well, that was not the result we were looking for. Can we improve it? Can we make the clustering algorithm learn to differ such structures?

The answer is yes - we need to set some parameters within the SpectralClustering function. The parameter we should change is affinity. This parameter defines how should affinity matrix be built (the math explanation of this is outside the scope of this course). By default, the parameter's value is 'rbf'. If we want to differ the clusters with such a structure as in the previous chapter, we should consider the 'nearest_neighbors' value of the parameter.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Well, that was not the result we were looking for. Can we improve it? Can we make the clustering algorithm learn to differ such structures?

The answer is yes - we need to set some parameters within the SpectralClustering function. The parameter we should change is affinity. This parameter defines how should affinity matrix be built (the math explanation of this is outside the scope of this course). By default, the parameter's value is 'rbf'. If we want to differ the clusters with such a structure as in the previous chapter, we should consider the 'nearest_neighbors' value of the parameter.

Tarefa

  1. Import SpectralClustering function from sklearn.cluster.
  2. Create a SpectralClustering model object with 4 clusters and set the affinity parameter to 'nearest_neighbors'.
  3. Fit the data to the model and predict the labels. Save predicted labels as the 'prediction' column of data.
  4. Build the seaborn scatter plot with 'x' column of data on the x-axis, 'y' column of data on the y-axis for each value of 'prediction'. Then, display the plot.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 4. Capítulo 3
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt