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 in Machine Learning by Anmol
81 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 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 9 in Machine Learning by Vishal
44 views
0 votes
1 answer

Clustering algorithms

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

answered May 9 in Machine Learning by Nisha
43 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 409 views
0 votes
1 answer

What is clustering in Machine Learning?

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

answered May 9 in Machine Learning by Shridhar
83 views
0 votes
1 answer

Calculating accuracy of prediction of rpart model

Your first task would be to build ...READ MORE

answered Apr 4, 2018 in Data Analytics by Bharani
• 4,560 points
1,808 views
0 votes
1 answer

Why would you choose Blob Storage over File Storage which also has ability to store file(s) and folder(s)

Azure Files: Azure File storage provides shared ...READ MORE

answered Apr 13, 2018 in Azure by null_void
• 3,220 points

edited Apr 13, 2018 by null_void 71 views
0 votes
1 answer

trigger an event after checking into TFS

You essentially can't do this in TVFC. ...READ MORE

answered Apr 13, 2018 in DevOps & Agile by DareDev
• 6,810 points
84 views