Function | Syntax | Description | Data type of the return value |
cosine_similarity function | cosine_similarity(array(double) vector1, array(double) vector2) cosine_similarity(varchar vector1, varchar vector2)
| Calculates the cosine similarity of two vectors. Valid values of the cosine similarity: [-1, 1]. If the value of the cosine similarity between two vectors is 1, the vectors are in the same direction. If the value of the cosine similarity between two vectors is -1, the vectors are in the opposite directions. If the value of the cosine similarity between two vectors is 0, one vector is vertical to the other vector.
| double |
inner_product or dot_product function | inner_product(array(double) vector1, array(double) vector2) inner_product(varchar vector1, varchar vector2) dot_product(array(double) vector1, array(double) vector2) dot_product(varchar vector1, varchar vector2)
| Calculates the inner product of two vectors. | double |
l2_distance or euclidean_distance function | euclidean_distance(array(double) vector1, array(double) vector2) euclidean_distance(varchar vector1, varchar vector2) l2_distance(array(double) vector1, array(double) vector2) l2_distance(varchar vector1, varchar vector2)
| Calculates the Euclidean distance between two vectors. | double |
vector_norm function | vector_norm(array(double) vector1) vector_norm(array(double) vector1, double p) vector_norm(varchar vector1) vector_norm(varchar vector1, double p)
| Calculates the norm of a vector. The norm of a vector is equivalent to the magnitude of the vector. | double |
vector_sum function | | Calculates the sum of all elements of a vector. | double |
vector_mean function | | Calculates the mean of a vector. | double |
vector_variance function | | Calculates the variance of a vector. Variance measures the dispersion of the elements of a vector. Variance is the average of the squared distances from each element of the vector to the mean. | double |
vector_std_dev function | | Calculates the standard deviation of a vector. The standard deviation of a vector is the positive square root of its variance. Variance measures how far each data point in a dataset is from the mean. A high variance value indicates that the data points are significantly spread out from the mean. A low variance value indicates that the data points are close to the mean. | double |
vector_add function | vector_add(array(double) vector1, array(double) vector2) vector_add(varchar vector1, varchar vector2)
| Calculates the sum of two vectors. You can perform arbitrary linear transformation based on vector addition, vector subtraction, and vector scaling functions. | array(double) |
vector_subtract function | vector_subtract(array(double) vector1, array(double) vector2) vector_subtract(varchar vector1, varchar vector2)
| Calculates the difference between two vectors. You can perform arbitrary linear transformation based on vector addition, vector subtraction, and vector scaling functions. | array(double) |
vector_scale function | vector_scale(array(double) vector1, double alpha) vector_scale(varchar vector1, double alpha)
| Calculates the result of vector scaling. You can perform arbitrary linear transformation based on vector addition, vector subtraction, and vector scaling functions. | array(double) |
vector_multiply function | vector_multiply(array(double) vector1, array(double) vector2) vector_multiply(varchar vector1, varchar vector2)
| Calculates the product of each element at the same position in two vectors and returns the result vector. | array(double) |
vector_divide function | vector_divide(array(double) vector1, array(double) vector2) vector_divide(varchar vector1, varchar vector2)
| Calculates the division of each element at the same position in two vectors and returns the result vector. | array(double) |
vector_add_value function | vector_add_value(array(double) vector1, double value) vector_add_value(varchar vector1, double value)
| Adds a constant to each element in a vector and returns the result vector. | array(double) |
vector_fill_nan function | vector_fill_nan(varchar vector1, varchar fill_option) | Specifies a value for an element that is left empty in a vector. If NaN , null , Inf , or -Inf exists in a vector, the related element is considered empty. You can specify different values for fill_option , such as avg , mean , median , min , max , and value=0 . If you specify value=0, you can replace 0 with other digits. | array(double) |