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

Contenido del 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.

Tarea

  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.

Tarea

  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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 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.

Tarea

  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.

Tarea

  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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 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.

Tarea

  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.

Tarea

  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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo 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.

Tarea

  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.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 4. Capítulo 3
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt