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 in tensor 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 to tensor.

tensorSPTensor

The sparse tensor that is the basis for comparison.

top_kint, optional

The number of elements to return. If top_k is None (default), fit values for all entries are returned. If top_k is positive, the top_k lowest fit elements are returned. If top_k is negative the abs(top_k) highest fit elements are returned. If top_k is zero an empty ndarray is returned.

Returns
fit_valsnumpy.ndarray

A numpy.ndarray of the same shape and format as tensor.entries. The first tensor.order columns of fit_vals are indices into into each mode of tensor. The final column of fit_vals contains the entry’s fit value.