ENSIGN Python API

ensign.csv2tensor

Converts tabular data into a sparse tensor.

ensign.csv2tensor.csv2tensor(filepaths[, …])

Creates a sparse tensor from one or more CSV files or Bro/Zeek logs.

ensign.csv2tensor.df2tensor(dfs[, …])

Variant of csv2tensor where in-memory DataFrames are passed instead of paths to files on disk.

ensign.cp_decomp

CANDECOMP-PARAFAC (CP) sparse tensor decomposition tools.

This module contains functions for reading, writing, and performing CP decompositions along with a class for representing decomposition results.

ensign.cp_decomp.CPDecomp()

Represents the results of a CP decomposition.

ensign.cp_decomp.CPDecomp.compute_cpd_backtrack(self)

Computes CP Decomposition backtracking information.

ensign.cp_decomp.read_cp_decomp_dir(decomp_dir)

Reads a CP decomposition from the filesystem.

ensign.cp_decomp.write_cp_decomp_dir(…[, …])

Writes a CP decomposition to the filesystem.

ensign.cp_decomp.reconstruct_into(decomp, tensor)

Reconstructs a CP decomposition ‘into’ a sparse tensor.

ensign.cp_decomp.get_fit_per_entry(decomp, …)

Calculates fit for each entry of a reconstructed tensor present in the original tensor.

ensign.cp_decomp.are_close(decomp0, decomp1)

Checks if weights and factor matrices are close according to tolerance.

ensign.cp_decomp.cp_als(sptensor, rank[, …])

Performs a CP decomposition using the alternating least squares (ALS) method.

ensign.cp_decomp.cp_als_nn(sptensor, rank[, …])

Performs a nonnegative CP decomposition using the alternating least squares (ALS) method.

ensign.cp_decomp.cp_apr(sptensor, rank[, …])

Performs a CP decomposition using the alternating Poisson regression (APR) method.

ensign.cp_decomp.cp_apr_pdnr(sptensor, rank)

Performs a CP decomposition using alternating Poisson regression (APR) with projected damped Newton row (PDNR) subproblem.

ensign.cp_decomp.cp_apr_pqnr(sptensor, rank)

Performs a CP decomposition using alternating Poisson regression (APR) with projected quasi-Newton row (PQNR) subproblem.

ensign.sptensor

Sparse tensor tools.

This module contains functions for reading, writing, and representing sparse tensors.

ensign.sptensor.SPTensor([order, nnz, …])

Represents a sparse tensor.

ensign.sptensor.SPTensor.write(self, outdir)

Writes a text representation of the sparse tensor to the given directory.

ensign.sptensor.read_sptensor(directory[, …])

Reads a sparse tensor file from the filesystem.

ensign.sptensor.write_sptensor(directory, …)

Writes a sparse tensor to the filesystem.

ensign.visualize

Visualize a tensor decomposition by plotting scores for selected components in each mode.

ensign.visualize.plot_component(decomp, comp_id)

Visualizes a specific component of a decomposition using blue-line charts.

ensign.comp_top_k

Module for investigating the contents of a tensor decomposition by listing the highest scoring labels in a component.

ensign.comp_top_k.get_top_k(factors, labels, …)

Computes the top k labels and corresponding scores for each mode for each component in the list.

ensign.query_decomp

Return all components containing the query label in the given mode. Up to k components are printed where <query label> has a non-zero score.

ensign.query_decomp.query_decomp(factors, …)

Compute all components containing the query label in the given mode.

ensign.synchronize_labels

Adjusts labels of multiple tensors and/or CP decompositions such that identical labels (e.g., “1/1/1970”, “10.1.1.1”) map to unique indices (e.g., 5, 437).

ensign.synchronize_labels.synchronize_labels(…)

Synchronizes labels between tensors.

ensign.synchronize_labels.synchronize_labels_stream(…)

Synchronizes specified modes between a base decomposition and an update tensor.

ensign.decomp_diff

ensign.decomp_diff.decomp_diff(decomps[, …])

Determine differences(similarities) between decompositions.