geosnap.analyze.analytics.spectral

geosnap.analyze.analytics.spectral(X, n_clusters, eigen_solver=None, random_state=None, n_init=10, gamma=1.0, affinity='rbf', n_neighbors=10, eigen_tol=0.0, assign_labels='kmeans', degree=3, coef0=1, kernel_params=None, n_jobs=-1, **kwargs)[source]

Spectral Clustering.

Parameters
Xarray_like

n x k attribute data

n_clustersint

The number of clusters to form as well as the number of centroids to generate.

eigen_solver{None, ‘arpack’, ‘lobpcg’, or ‘amg’}

The eigenvalue decomposition strategy to use. AMG requires pyamg to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities.

n_componentsinteger, optional, default=n_clusters

Number of eigen vectors to use for the spectral embedding

random_stateint, RandomState instance or None (default)

A pseudo random number generator used for the initialization of the lobpcg eigen vectors decomposition when eigen_solver=’amg’ and by the K-Means initialization. Use an int to make the randomness deterministic. See Glossary.

n_initint, optional, default: 10

Number of time the k-means algorithm will be run with different centroid seeds. The final results will be the best output of n_init consecutive runs in terms of inertia.

gammafloat, default=1.0

Kernel coefficient for rbf, poly, sigmoid, laplacian and chi2 kernels. Ignored for affinity=’nearest_neighbors’.

affinitystr or callable(), default ‘rbf’

How to construct the affinity matrix.

n_neighborsinteger

Number of neighbors to use when constructing the affinity matrix using the nearest neighbors method. Ignored for affinity=’rbf’.

eigen_tolfloat, optional, default: 0.0

Stopping criterion for eigendecomposition of the Laplacian matrix when eigen_solver=’arpack’.

degreefloat, default=3

Degree of the polynomial kernel. Ignored by other kernels.

coef0float, default=1

Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.

n_jobsint or None, optional (default=None)

The number of parallel jobs to run. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.

**kwargsdict

additional wkargs.

Returns
fitted cluster instancesklearn.cluster.SpectralClustering