Skip to content

Commit

Permalink
Merge branch 'sparse-kde' of https://github.com/GardevoirX/scikit-matter
Browse files Browse the repository at this point in the history
 into sparse-kde
  • Loading branch information
GardevoirX committed Aug 12, 2024
2 parents 21ff481 + 9d8ad9b commit 62b1e0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions docs/src/references/neighbors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ Sparse Kernel Density Estimation
--------------------------------

.. autoclass:: skmatter.neighbors.SparseKDE
:show-inheritance:

.. automethod:: fit
.. automethod:: score_samples
.. automethod:: score
8 changes: 4 additions & 4 deletions examples/neighbors/pamm.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def cluster_distribution_3D(

# %%
# We need to estimate the probability at each grid point to do quick shift, which can
# further partition the set of grid points in to several clusters. The resulting
# further partition the set of grid points into several clusters. The resulting
# clusters can be interpreted as (meta-)stable states of the system.
#
#
Expand All @@ -368,7 +368,7 @@ def cluster_distribution_3D(
)

# %%
# Based on the results, the gaussian mixture model of the system can be generated:
# Based on the results, the Gaussian mixture model of the system can be generated:
#
#

Expand All @@ -386,7 +386,7 @@ def cluster_distribution_3D(

# %%
# The final result shows seven (meta-)stable states of hydrogen bond. Here we also show
# the reference hydrogen bond descriptor. The gaussian with the largest weight locates
# the reference hydrogen bond descriptor. The Gaussian with the largest weight locates
# closest to the reference point. This result shows that, with the help of the
# `SparseKDE` and `QuickShift` algorithm, we can easily identify the (meta-)stable
# states of the system objectively and without any prior knowledge about the system.
Expand All @@ -402,4 +402,4 @@ def cluster_distribution_3D(
ax.scatter(REF_HB[0], REF_HB[1], REF_HB[2], marker="+", color="red", s=1000)

# %%
f"The gaussian with the highest probability is {np.argmax(cluster_weights) + 1}"
f"The Gaussian with the highest probability is {np.argmax(cluster_weights) + 1}"
4 changes: 2 additions & 2 deletions examples/neighbors/sparse-kde.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Example for the usage of the :class:`skmatter.neighbors.SparseKDE` class. This class is
specifically designed for conducting pobabilistic analysis of molecular motifs
(`PAMM <https://doi.org/10.1063/1.4900655>`_),
which is quiet useful for analyzing motifs like H-bonds, coordination polyhedra, and
which is quite useful for analyzing motifs like H-bonds, coordination polyhedra, and
protein secondary structure.
Here we show how to use the sparse KDE model to fit the probability distribution based
Expand Down Expand Up @@ -60,7 +60,7 @@
plt.show()

# %%
# The perquisite of conducting sparse KDE is to partition the sample set. Here, we use
# Sparse KDE requires a discretization of the sample space. Here, we use
# the FPS method to generate grid points in the sample space:
#
#
Expand Down
4 changes: 2 additions & 2 deletions src/skmatter/neighbors/_sparsekde.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SparseKDE(BaseEstimator):
The fractional number of points in the voronoi cell of each grid points. Use
this when each cell has a similar number of points.
kernel : str, default=gaussian
The kernel used here. Now only the gaussian kernel is available.
The kernel used here. Now only the Gaussian kernel is available.
verbose : bool, default=False
Whether to print progress.
Expand All @@ -79,7 +79,7 @@ class SparseKDE(BaseEstimator):
>>> np.random.seed(0)
>>> n_samples = 10_000
To create two gaussians with different means and covariance and sample from them
To create two Gaussians with different means and covariance and sample from them
>>> cov1 = [[1, 0.5], [0.5, 1]]
>>> cov2 = [[1, 0.5], [0.5, 0.5]]
Expand Down

0 comments on commit 62b1e0b

Please sign in to comment.