PropertyDamage.FailureIntelligence.Similarity (PropertyDamage v0.2.0)

View Source

Computes similarity scores between failure fingerprints.

Uses multiple metrics to determine how similar two failures are, enabling pattern detection and clustering.

Summary

Functions

Performs a detailed comparison between two fingerprints.

Finds the most similar fingerprint from a list.

Finds all fingerprints similar to the target.

Computes the similarity score between two fingerprints.

Checks if two fingerprints are similar based on the threshold.

Checks if two fingerprints are similar using a custom threshold.

Computes a similarity matrix for a list of fingerprints.

Types

comparison()

@type comparison() :: %{
  score: score(),
  breakdown: %{
    failure_type: score(),
    check_name: score(),
    command_type: score(),
    command_shape: score(),
    event_types: score(),
    sequence_shape: score(),
    error_category: score(),
    error_pattern: score()
  },
  is_similar: boolean()
}

score()

@type score() :: float()

Functions

compare(fp1, fp2)

Performs a detailed comparison between two fingerprints.

Returns the overall score, per-component breakdown, and similarity determination.

find_most_similar(target, fingerprints)

Finds the most similar fingerprint from a list.

Returns {fingerprint, score} or nil if no fingerprints are provided.

find_similar(target, fingerprints, opts \\ [])

Finds all fingerprints similar to the target.

Returns a list of {fingerprint, score} pairs, sorted by score descending.

score(fp1, fp2)

Computes the similarity score between two fingerprints.

Returns a score between 0.0 (completely different) and 1.0 (identical).

similar?(fp1, fp2)

Checks if two fingerprints are similar based on the threshold.

similar?(fp1, fp2, threshold)

Checks if two fingerprints are similar using a custom threshold.

similarity_matrix(fingerprints)

@spec similarity_matrix([PropertyDamage.FailureIntelligence.Fingerprint.t()]) :: %{
  required({non_neg_integer(), non_neg_integer()}) => score()
}

Computes a similarity matrix for a list of fingerprints.

Returns a map where keys are {index1, index2} and values are scores. Only computes upper triangle (i < j) since similarity is symmetric.