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

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.title("Original dataset")

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

model = SpectralCoclustering(n_clusters=5, random_state=0)
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.title("After biclustering; rearranged to show biclusters")
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
0 votes
1 answer

Clustering algorithms

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

answered May 10, 2019 in Machine Learning by Nisha
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,300 points
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 2,413 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
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,620 points