morphoclass.unsupervised package¶
Submodules¶
Module contents¶
Utilities for unsupervised methods for neuron m-type classification.
-
morphoclass.unsupervised.make_silhouette_plot(embeddings, n_clusters, random_state=0)¶ Create a silhouette plot given an embedding.
This code up to small amendments is copied from https://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_silhouette_analysis.html
- Parameters
embeddings (np.ndarray) – The embedding to be plotted. The shape should be (n_samples, d_embedding).
n_clusters (int) – The number of clusters to create.
random_state (int) – The random state to use for KMeans (first plot) and PCA (second plot).
-
morphoclass.unsupervised.plot_embedding_pca(embeddings, ax=None, pca=None, labels=None, title=None, annotate_indices=False, annotation_fontsize=7)¶ Plot two principal components of given embedding.
This is an altered version which shows annotations.
- Parameters
embeddings (np.ndarray) – The embedding to be plotted. The shape should be (n_samples, d_embedding).
ax (matplotlib.axes.Axes, optional) – A matplotlib axis object.
pca (sklearn.decomposition.PCA, optional) – An fitted instance of the PCA class from scikit-learn. If not provided then a new instance will be created and fitted.
labels (list_like, optional) – Labels for all samples. Should be of length n_samples.
title (str) – Title for the plot.
annotate_indices (bool) – If true then each point in the plot will be annotated with its index in the provided embeddings.
annotation_fontsize (int) – The font size for the annotation. Has no effect if annotate_indices is False.
- Returns
pca – The PCA of the given embeddings.
- Return type
sklearn.decomposition.PCA