Calculator Inputs
Example Data Table
| Use Case | Vector A | Vector B | Weights | Expected Pattern |
|---|---|---|---|---|
| Semantic search | 0.20, 0.40, 0.10, 0.90, 0.60 | 0.10, 0.35, 0.25, 0.80, 0.55 | 1, 1, 1, 1, 1 | Strong similarity |
| Recommendation engine | 4, 5, 1, 0, 3 | 5, 4, 0, 1, 3 | 1.2, 1.2, 0.8, 0.8, 1 | Moderate similarity |
| Image feature matching | 0.90, 0.10, 0.70, 0.20 | 0.88, 0.11, 0.69, 0.18 | 1, 1, 1, 1 | Very high alignment |
Formula Used
Cosine similarity measures the angle between two vectors instead of their raw size. It is commonly used in embeddings, text analysis, recommendation systems, clustering, and nearest-neighbor comparison.
Cosine Similarity = (A · B) / (||A|| × ||B||)
Here, A · B is the dot product of the weighted vectors. ||A|| and ||B|| are their magnitudes. A result near 1 means very similar direction, 0 means orthogonal behavior, and negative values mean opposing direction.
If weights are supplied, each dimension is multiplied before the dot product and magnitude steps. This lets you emphasize more important features in the final similarity score.
How to Use This Calculator
- Enter comma-separated values for Vector A and Vector B.
- Add optional dimension weights if some features matter more.
- Choose the number of decimal places for output.
- Enable zero padding if vectors may have different lengths.
- Enable normalization if you want each vector scaled first.
- Click Calculate Similarity to view the result above the form.
- Export the output using CSV or PDF buttons when needed.
Frequently Asked Questions
1. What does cosine similarity measure?
It measures how closely two vectors point in the same direction. It focuses on orientation rather than absolute size.
2. When is cosine similarity useful?
It is useful for embeddings, search ranking, recommendations, clustering, document comparison, and feature matching where direction matters more than magnitude.
3. What does a score near 1 mean?
A value near 1 means the vectors are strongly aligned. Their patterns are very similar, even if absolute values differ.
4. Can vectors have different lengths?
Yes, if you enable zero padding. Otherwise, both vectors must contain the same number of dimensions.
5. Why would I use weights?
Weights let you emphasize important dimensions and reduce less relevant ones. This is helpful when some features carry more predictive value.
6. What happens if a vector magnitude is zero?
Cosine similarity becomes undefined because the formula divides by vector magnitude. Add nonzero values before calculating.
7. What is the difference between cosine similarity and distance?
Similarity shows directional closeness. Cosine distance is usually calculated as 1 minus cosine similarity, making larger values indicate greater separation.