ensign.cp_decomp.get_fit_per_entry¶
-
get_fit_per_entry
(decomp, tensor, top_k=None)[source]¶ Calculates fit for each entry of a reconstructed tensor present in the original tensor.
This function evaluates how well each entry of the tensor reconstructed from
decomp
matches the entry at the same index intensor
This evaluation is calculated as fit, a floating point number on the interval (-infinity, 1.0]. A fit of 1.0 is an exact match between the reconstructed and original entry. Output is sorted fy fit (ascending).Lower fit values indicate a reconstructed entry is different than the original entry. Low fit values may be indicative of anomalous data.
- Parameters
- decompCPDecomp
Decompostion used to calculate per-element fit. A sparse tensor is reconstructed from
decomp
using sum-of-outer-products and the results are compared totensor
.- tensorSPTensor
The sparse tensor that is the basis for comparison.
- top_kint, optional
The number of elements to return. If
top_k
isNone
(default), fit values for all entries are returned. Iftop_k
is positive, thetop_k
lowest fit elements are returned. Iftop_k
is negative theabs(top_k)
highest fit elements are returned. Iftop_k
is zero an emptyndarray
is returned.
- Returns
- fit_valsnumpy.ndarray
A
numpy.ndarray
of the same shape and format astensor.entries
. The firsttensor.order
columns offit_vals
are indices into into each mode oftensor
. The final column offit_vals
contains the entry’s fit value.