Skip to content

Commit 8d9cd37

Browse files
committed
updated docs and minor fixes to density_advanced
1 parent 7b256a2 commit 8d9cd37

5 files changed

+30
-16
lines changed

dadapy/density_advanced.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def compute_grads(self, comp_covmat=False):
182182

183183
# ----------------------------------------------------------------------------------------------
184184

185-
def compute_pearson(self, comp_p_mat=False, method="jaccard"):
185+
def compute_pearson(self, comp_p_mat=False, similarity_method="jaccard"):
186186
"""
187187
Compute, for any couple (i,j) of points connected on the directed neighbourhood graph, an estimate of the
188188
Pearson correlation coefficient between the directed deltaFij computed with the gradients in i and in j, namely
@@ -193,13 +193,13 @@ def compute_pearson(self, comp_p_mat=False, method="jaccard"):
193193
194194
Args:
195195
comp_p_mat (bool): if True, also computes the pearson_mat attribute.
196-
method (str): method to compute the neighbourhood similarity index (see documentation for
197-
compute_neigh_similarity_index).
196+
similarity_method (str): similarity_method to compute the neighbourhood similarity index (see documentation
197+
for compute_neigh_similarity_index).
198198
"""
199199

200200
# check or compute neigh_similarity_index
201201
if self.neigh_similarity_index is None:
202-
self.compute_neigh_similarity_index(method=method)
202+
self.compute_neigh_similarity_index(method=similarity_method)
203203
# check or compute grads
204204
if self.grads is None:
205205
self.compute_grads()
@@ -234,7 +234,7 @@ def compute_pearson(self, comp_p_mat=False, method="jaccard"):
234234
self.pearson_mat = p_mat.todense()
235235
np.fill_diagonal(self.pearson_mat, 1.0)
236236

237-
def compute_deltaFs(self, pearson_method="jaccard", comp_p_mat=False):
237+
def compute_deltaFs(self, similarity_method="jaccard", comp_p_mat=False):
238238
"""Compute deviations deltaFij to standard kNN log-densities at point j as seen from point i using
239239
a linear expansion with as slope the semisum of the average gradient of the log-density over
240240
the neighbourhood of points i and j.
@@ -246,7 +246,7 @@ def compute_deltaFs(self, pearson_method="jaccard", comp_p_mat=False):
246246
The log-density differences are stored Fij_array, their variances in Fij_array_var.
247247
248248
Args:
249-
pearson_method: see docs for compute_pearson function
249+
similarity_method: see docs for neigh_graph.compute_neigh_similarity_index function
250250
comp_p_mat: see docs for compute_pearson function
251251
252252
"""
@@ -270,7 +270,9 @@ def compute_deltaFs(self, pearson_method="jaccard", comp_p_mat=False):
270270

271271
# check or compute common_neighs
272272
if self.pearson_mat is None:
273-
self.compute_pearson(method=pearson_method, comp_p_mat=comp_p_mat)
273+
self.compute_pearson(
274+
similarity_method=similarity_method, comp_p_mat=comp_p_mat
275+
)
274276

275277
Fij_array = 0.5 * np.einsum("ij, ij -> i", g1 + g2, self.neigh_vector_diffs)
276278
vari = np.einsum(
@@ -296,18 +298,17 @@ def compute_deltaFs(self, pearson_method="jaccard", comp_p_mat=False):
296298

297299
# ----------------------------------------------------------------------------------------------
298300

299-
def compute_deltaFs_inv_cross_covariance(self, pearson_method="jaccard"):
301+
def compute_deltaFs_inv_cross_covariance(self, similarity_method="jaccard"):
300302
"""Compute the appoximate inverse cross-covariance of the deltaFs cov[deltaFij,deltaFlm] using the LSDI
301-
approximation (see compute_density_BMTI_reg docs)
303+
approximation (see compute_density_BMTI docs)
302304
303305
Args:
304-
pearson_method: see docs for compute_pearson function
305-
306+
similarity_method: see docs for neigh_graph.compute_neigh_similarity_index function
306307
"""
307308

308309
# check for deltaFs
309310
if self.pearson_mat is None:
310-
self.compute_pearson(method=pearson_method, comp_p_mat=True)
311+
self.compute_pearson(similarity_method=similarity_method, comp_p_mat=True)
311312

312313
# check or compute deltaFs_grads_semisum
313314
if self.Fij_var_array is None:

docs/source/density_advanced.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The density_advanced module
2+
================================
3+
4+
.. automodule:: density_advanced
5+
:members:

docs/source/implemented_algorithms.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ The algorithms currently implemented are:
2424
* k-NN ("k-nearest neighbours estimator")
2525
* PAk ("Point adaptive k-NN estomator")
2626
* k*-NN ("k-star nearest neighbours estimator")
27+
* point-adaptive mean-shift gradient estimator
28+
* BMTI ("Binless Multidimensional Thermodynamic Integration")
2729

2830
Density based clustering
2931
--------------------------
@@ -52,4 +54,4 @@ These algorithms estimate the information content of each feature in the dataset
5254
and assign a weight to each feature. The weights can take one the value zero, leading to feature selection.
5355
The algorithm currently implemented is:
5456

55-
* DII ("Differentiable Information Imbalance")
57+
* DII ("Differentiable Information Imbalance")

docs/source/modules.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
Modules (API reference)
22
=======================
33

4-
The package contains the following modules: id_estimation, density_estimation, clustering, metric_comparisons,
5-
feature_weighting,data, data_sets.
4+
The package contains the following modules:
65

76

87
.. toctree::
98
:maxdepth: 2
109

1110
base
1211
id_estimation
12+
neigh_graph
1313
density_estimation
14+
density_advanced
1415
clustering
1516
id_discrete
1617
metric_comparisons
1718
feature_weighting
1819
data
19-
utils
20+
utils

docs/source/neigh_graph.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The neigh_graph module
2+
================================
3+
4+
.. automodule:: neigh_graph
5+
:members:

0 commit comments

Comments
 (0)