mlpack
Public Member Functions | Static Public Member Functions | List of all members
mlpack::kernel::CosineDistance Class Reference

The cosine distance (or cosine similarity). More...

#include <cosine_distance.hpp>

Public Member Functions

template<typename Archive >
void serialize (Archive &, const uint32_t)
 Serialize the class (there's nothing to save).
 

Static Public Member Functions

template<typename VecTypeA , typename VecTypeB >
static double Evaluate (const VecTypeA &a, const VecTypeB &b)
 Computes the cosine distance between two points. More...
 

Detailed Description

The cosine distance (or cosine similarity).

It is defined by

\[ d(a, b) = \frac{a^T b}{|| a || || b ||} \]

and this class assumes the standard L2 inner product.

Member Function Documentation

◆ Evaluate()

template<typename VecTypeA , typename VecTypeB >
double mlpack::kernel::CosineDistance::Evaluate ( const VecTypeA &  a,
const VecTypeB &  b 
)
static

Computes the cosine distance between two points.

Parameters
aFirst vector.
bSecond vector.
Returns
d(a, b).

The documentation for this class was generated from the following files: