# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np

con_mat=np.load('/media/maria/DATA1/Documents/NeuralData/conn_undir_drosophila.npy')[:10000,:10000]



from sklearn.cluster import SpectralClustering
import numpy as np
clustering = SpectralClustering(n_clusters=100,assign_labels="discretize",random_state=0,affinity='precomputed').fit(con_mat)
clustering.labels_

# +
import matplotlib.pyplot as plt

plt.hist(clustering.labels_,bins=100)
# -

import seaborn as sns
print(clustering.labels_==0)
ind=np.where(clustering.labels_==0)[0]
subs=con_mat[ind[:, None], ind]
subs[subs>0]=1
sns.heatmap(subs)
print(subs.shape)
print(subs)

print(np.nonzero(subs)[0].shape)



StarcoderdataJupyterScriptsDedupFiltered