Checking spectral co-clustering also accuracy

0 votes
I want python code for the following requirements:

A dataset is generated using make_biclusters function. The rows and columns are then shuffled and It's then sent to spectral co-clustering also. I would like to rearrange the shuffled matrix and show how accurately the algorithm found the biclusters.

Thank you
Jun 3, 2019 in Machine Learning by Anmol
761 views

1 answer to this question.

0 votes

Hi Vishal, you could try something like this:

import numpy as np
from matplotlib import pyplot as plt

from sklearn.datasets import make_biclusters
from sklearn.datasets import samples_generator as sg
from sklearn.cluster.bicluster import SpectralCoclustering
from sklearn.metrics import consensus_score

data, rows, columns = make_biclusters(
    shape=(300, 300), n_clusters=5, noise=5,
    shuffle=False, random_state=0)

plt.matshow(data, cmap=plt.cm.Blues)
plt.title("Original dataset")

data, row_idx, col_idx = sg._shuffle(data, random_state=0)
plt.matshow(data, cmap=plt.cm.Blues)
plt.title("Shuffled dataset")

model = SpectralCoclustering(n_clusters=5, random_state=0)
model.fit(data)
score = consensus_score(model.biclusters_,
                        (rows[:, row_idx], columns[:, col_idx]))

print("consensus score: {:.3f}".format(score))

fit_data = data[np.argsort(model.row_labels_)]
fit_data = fit_data[:, np.argsort(model.column_labels_)]

plt.matshow(fit_data, cmap=plt.cm.Blues)
plt.title("After biclustering; rearranged to show biclusters")

plt.show()
answered Jun 3, 2019 by Yamini

Related Questions In Machine Learning

0 votes
1 answer

What are different clustering methods?

Different clustering methods include: 1. Density-Based Methods: These methods ...READ MORE

answered May 10, 2019 in Machine Learning by Vishal
996 views
0 votes
1 answer

Clustering algorithms

These are the clustering algorithms that are ...READ MORE

answered May 10, 2019 in Machine Learning by Nisha
864 views
0 votes
1 answer

How can I train a model and calculate the accuracy of CBR algorithm?

Hi@Abubakar, You can find lots of documents on ...READ MORE

answered Oct 17, 2020 in Machine Learning by MD
• 95,440 points
548 views
0 votes
1 answer

Hierarchical Clustering

K-means and Hierarchical clustering are both Clustering ...READ MORE

answered Feb 2, 2022 in Machine Learning by Nandini
• 5,480 points
495 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,056 views
0 votes
1 answer

What is clustering in Machine Learning?

Clustering is a type of unsupervised learning ...READ MORE

answered May 10, 2019 in Machine Learning by Shridhar
959 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP