intersecter

intersecter

Implementation of local homology as a detector for intersection points.

Classes

Name Description
Intersecter Low dimensional homology calculator for computing intersection points.

Intersecter

intersecter.Intersecter(
    radii=None,
    neighbors=None,
    max_dim=1,
    n_jobs=1,
    collapse_edges=None,
    threshold=None,
    outlier_label=-1.0,
    tree_type=None,
)

Low dimensional homology calculator for computing intersection points.

This class implements a low-dimensional ‘oracle’ to determine points whose local topology looks like that of intersecting planes. The algorithm depends fundamentally on two radii or neighbor parameters and an optional threshold parameter for determining when persistent features are relevant. Working from homological degree zero to a user-specified maximum homological dimension, local neighborhoods around each point are constructed and their topology checked to be trivial using persistent homology.

The reduced local homology of any point on a topological manifold should be concentrated in a single degree, and that degree is one less than the dimension of the manifold. This class checks this criterion through a range of degrees.

Parameters

Name Type Description Default
radii tuple[float, float] | None The radii of the annular neighborhood at every point. Only one of radii or neighbors should be specified. None
neighbors tuple[int, int] | None The number of neighbors of the annular neighborhood at every point. Only one of radii or neighbors should be specified. None
max_dim int The maximal dimension to run Intersecter. 1
n_jobs int The number of processors to use. 1
threshold float | None An optional float determining when a persistent feature is relevant. The default value uses the thickness of the annular regions. None
collapse_edges bool | None The flag determining whether to collapse edges (see giotto-tda’s documentation on VietorisRipsPersistence). The default behavior is False if max_dim < 4; otherwise it is True. None
outlier_label float The dimension to assign to any outliers. -1.0
tree_type str | None The style of tree to use for nearest neighbors computation. Can be either ‘KD’ for KD Tree or ‘Ball’ for Ball Tree. Default is KD Tree. None

Note

It seems like collapse_edges should be True if the homological dimension is “large”, but what this means in practice is still not clear. This could also cause slow down if a space has strata of many different dimensions.

This class is written in the style of a scikit-learn transformer.

Methods

Name Description
fit Fit the model to X.
fit_predict Use low dimensional homology to determine intersection points.
predict Use low dimensional homology to determine intersection points.
fit
intersecter.Intersecter.fit(X, y=None, subset=None)

Fit the model to X.

Compute the annular neighborhood around each point of X.

Parameters
Name Type Description Default
X np.ndarray[tuple[int, int], np.dtype[np.float64]] Array containing n_samples points in n_features dimensional space. required
y np.ndarray[tuple[int], np.dtype[np.float64]] | None Ignored. (Default value = None) None
subset np.ndarray[tuple[int], np.dtype[np.int_]] | None Those indices of X to used to compute the algorithm. If None, then set to range(len(X)). None
Returns
Name Type Description
self Intersecter Returns the instance itself.
fit_predict
intersecter.Intersecter.fit_predict(X, y=None, subset=None)

Use low dimensional homology to determine intersection points.

This method is equivalent to calling fit and then predict. Points on an n-manifold must have (n-1)-connected local neighborhoods (if n>1). This method checks the spherical shell constructed in fit and returns 0 if it is connected or 1 if it is not. Outliers are assigned the value in self.outlier_label.

Parameters
Name Type Description Default
X np.ndarray[tuple[int, int], np.dtype[np.float64]] Array containing n_samples points in n_features dimensional space. required
y np.ndarray[tuple[int], np.dtype[np.float64]] | None Ignored. None
subset np.ndarray[tuple[int], np.dtype[np.int_]] | None Those indices of X to used to compute the algorithm. If None, then set to range(len(X)). None
Returns
Name Type Description
np.ndarray[tuple[int], np.dtype[np.float64]] Array of local dimensions.
predict
intersecter.Intersecter.predict(X, y=None, subset=None)

Use low dimensional homology to determine intersection points.

Points on an n-manifold must have (n-1)-connected local neighborhoods (if n>0).

This method checks the spherical shell constructed in fit and returns 0 if it is connected or 1 if it is not. Outliers are assigned the value in self.outlier_label.

Parameters
Name Type Description Default
X np.ndarray[tuple[int, int], np.dtype[np.float64]] Array containing n_samples points in n_features dimensional space. required
y np.ndarray[tuple[int], np.dtype[np.float64]] | None Ignored. None
subset np.ndarray[tuple[int], np.dtype[np.int_]] | None Those indices of X to used to compute the algorithm. If None, then set to range(len(X)). None
Returns
Name Type Description
return_ld np.ndarray[tuple[int], np.dtype[np.float64]] Array with 0 for manifold points and 1 else.