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

Зміст курсу

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.

Завдання

  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.

Завдання

  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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 4. Розділ 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.

Завдання

  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.

Завдання

  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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 4. Розділ 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.

Завдання

  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.

Завдання

  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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

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.

Завдання

  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.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 4. Розділ 3
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt