src.mining.naive_change_miner

Classes

NaiveChangeMiner(**kwargs)

class src.mining.naive_change_miner.NaiveChangeMiner(**kwargs)
Author:

Alberto M. Esmoris Pena

Naive change miner. See Miner.

The naive change miner considers a point cloud from the past and computes the differences between the points in the present and the past. More formally, let \(\pmb{P} \in \mathbb{R}^{m \times n_x}\) and \(\pmb{Q} \in \mathbb{R}^{\tilde{m} \times n_x}\) be the present and past point clouds, respectively. The point-wise quantification of change can be done in terms of Euclidean distance:

\[d_{i} = \min_{1 \leq j \leq \tilde{m}} \quad \lVert \pmb{q}_{j*} - \pmb{p}_{i*}\rVert\]

Let \(d_* \in \mathbb{R}_{\geq 0}\) be the min distance threshold. Any point that satisfies d_i > d_* is considered as a point-wise change.

It is also possible to define a max distance value \(d^* \in \mathbb{R}\) to truncate all the point-wise distances such that if \(d_{i} > d^*\) then it will be truncated to \(d_{i} = d^*\) .

The change quantification features can be given in different scales. They can be specified through the feature names (fnames) argument:

"euclidean"

\[d_i = \lVert \pmb{q}_{j*} - \pmb{p}_{i*} \rVert\]

"squared"

\[d_i = \lVert \pmb{q}_{j*} - \pmb{p}_{i*} \rVert^2\]

"logarithmic"

\[d_i = \ln\left(\lVert \pmb{q}_{j*} - \pmb{p}_{i*} \rVert\right)\]

"normalized"

(if the \(d^*\) argument is given as zero, then the max distance is used instead).

\[d_i = \dfrac{ \lVert \pmb{q}_{j*} - \pmb{p}_{i*} \rVert - d_* }{ d^*-d_* }\]

"standardized"

(if \(\mu\) and \(\sigma\) are not given, then they are computed as the mean and standard deviation of the distances)

\[d_i = \dfrac{ \lVert \pmb{q}_{j*} - \pmb{p}_{i*} \rVert - \mu }{ \sigma }\]
Variables:
  • fnames (list of str) – The names of the change-based features that must be computed.

  • frenames (None or list of str) – The names of the computed features in the output point cloud. When not given (i.e., None), they will be automatically determined from the feature names (fnames).

  • pcloud_past (str) – The path to the point cloud representing the past.

  • min_distance (float) – The min distance argument \(d_*\).

  • max_distance (float) – The max distance argument \(d^*\).

  • mu (float) – The mu (mean) argument \(\mu\). If not given, it will be automatically computed as the mean distance.

  • sigma (float) – The sigma (standard deviation) argument \(\sigma\). If not given , it will be automatically computed as the standard deviation of the distances.

  • nthreads (int) – The number of threads for the parallel closest neighbors query. Using -1 implies considering as many threads as available cores.

static extract_miner_args(spec)

Extract the arguments to initialize/instantiate a NaiveChangeMiner from a key-word specification.

Parameters:

spec – The key-word specification containing the arguments.

Returns:

The arguments to initialize/instantiate a NaiveChangeMiner.

__init__(**kwargs)

Initialize an instance of NaiveChangeMiner.

Parameters:

kwargs (dict) – The attributes for the NaiveChangeMiner that will also be passed to the parent.

mine(pcloud)

Mine changes considering closest neighbors in the past.

Parameters:

pcloud – The point cloud to be mined.

Returns:

The point cloud extended with change features.

Return type:

PointCloud

load_pcloud_past()

Load the point cloud representing the past.

\[\pmb{Q} \in \mathbb{R}^{\tilde{m} \times n_x}\]
Returns:

The point-wise coordinates (structure space matrix) representing the past.

Return type:

np.ndarray

compute_pwise_distances(P, Q)

Compute the Euclidean point-wise distances between each point in \(\pmb{P}\) and its closest neighbor in \(\pmb{Q}\).

Parameters:
  • P (np.ndarray) – The structure space matrix representing the present.

  • Q (np.ndarray) – The structure space matrix representing the past.

Returns:

A vector with \(m\) point-wise distances, one for each point (row) in \(\pmb{P}\).

Return type:

np.ndarray

feature_from_change_distance(d, fname)

Compute the requested feature from the given point-wise change distances.

Parameters:
  • d – The vector of point-wise change distances, one for each input point (\(\pmb{d} \in \mathbb{R}^{m}\)).

  • fname – The name of the feature to be computed.

Returns:

The computed feature for each point.

Return type:

np.ndarray

compute_hull_mask(P, Q)

Compute the point-wise mask with True for each point of P that lies inside the 2D concave hull of Q and False for each one that lies outside.

Parameters:
  • P – The structure space matrix representing the present.

  • Q (np.ndarray) – The structure space matrix representing the past.

Returns:

Point-wise boolean mask with True for points of P inside the concave hull of Q and False otherwise.

Return type:

np.ndarray