Skip to content

Main content

Similarity: Cosine Zero Norm Policy Tool

Compute cosine similarity with an explicit reject/zero undefined-norm policy and a retained defined flag; zero is not silently treated as a measured cosine.

Loading tool…

Description

Compute cosine similarity with an explicit reject/zero undefined-norm policy and a retained defined flag; zero is not silently treated as a measured cosine.

A similarity term depends on the comparison universe, missing-value policy, treatment of repeated features, and normalization. A score can also have a caller-selected value when its mathematical denominator vanishes. Those conventions matter before interpreting a threshold or comparing methods.

Compute cosine similarity with an explicit reject/zero undefined-norm policy and a retained defined flag; zero is not silently treated as a measured cosine.

When to use this tool

Use Similarity: Cosine Zero Norm Policy when you need this particular comparison term, normalization, domain condition, or empty-result policy in a larger matching workflow.

How to use the tool and how it works

  1. Enter left, right, zeroNormPolicy. Keep parallel arrays aligned. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read result. Expand result to inspect the returned fields.

Calculate finite Euclidean norms for aligned nonempty vectors and their normalized dot product. Under zero policy return similarity zero when either norm vanishes; under reject require the norm product nonzero. Return defined and similarity inside result.1

Input fieldMeaning and unitsAccepted input
leftLeftRequired. Array of finite number..
rightRightRequired. Array of finite number..
zeroNormPolicyzero gives a fallback; reject also requires a nonzero computed norm product.Required. Text; one of "zero", "reject".
Output fieldInterpretationReturned shape
resultResultRequired. Object.
json
{
  "input": {
    "left": [
      0,
      0
    ],
    "right": [
      1,
      0
    ],
    "zeroNormPolicy": "zero"
  },
  "output": {
    "result": {
      "defined": false,
      "similarity": 0
    }
  }
}

Limitations and assumptions

  • Very small nonzero norms can have an underflowed product rejected by reject policy. No score clamping, statistical interpretation, or semantic meaning is added.
  • Outputs are nested inside result. The field tables state structural bounds; the mechanics also specify cross-field constraints. Malformed inputs and unsupported domains cause errors. A successful false flag, empty branch value, or zero placeholder has the meaning stated above and is distinct from an input error.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Signed zero is exported as zero.

Alternative or Complementary methods

Compare methods only after aligning feature definitions, missingness, empty policies, multiplicities, and normalizers. Use a complete comparison when the tool returns only one contribution or count check.

References

  1. Calculation and input contract: similarity/cosine-zero-norm-policy — tool.io

Similar or alternative tools