zoukankan      html  css  js  c++  java
  • lsa cosine R

    cosine {lsa}R Documentation

    Cosine Measure (Matrices)

    Description

    Calculates the cosine measure between two vectors or between all column vectors of a matrix.

    Usage

    cosine(x, y = NULL)
    

    Arguments

    xA vector or a matrix (e.g., a document-term matrix).
    yOptional: a vector with compatible dimensions to x. If `NULL', all column vectors of x are correlated.

    Details

    cosine() calculates a similarity matrix between all column vectors of a matrix x. This matrix might be a document-term matrix, so columns would be expected to be documents and rows to be terms.

    When executed on two vectors x and ycosine() calculates the cosine similarity between them.

    Value

    Returns a n*n similarity matrix of cosine values, comparing all n column vectors against each other. Executed on two vectors, their cosine similarity value is returned.

    Note

    The cosine measure is nearly identical with the pearson correlation coefficient (besides a constant factor)cor(method="pearson"). For an investigation on the differences in the context of textmining see (Leydesdorff, 2005).

    Author(s)

    Fridolin Wild fridolin.wild@wu-wien.ac.at

    References

    Leydesdorff, L. (2005) Similarity Measures, Author Cocitation Analysis,and Information Theory. In: JASIST 56(7), pp.769-772.

    See Also

    cor

    Examples

    ## the cosinus measure between two vectors
    
    vec1 = c( 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
    vec2 = c( 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 )
    cosine(vec1,vec2) 
    
    ## the cosine measure for all document vectors of a matrix
    
    vec3 = c( 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0 )
    matrix = cbind(vec1,vec2, vec3)
    cosine(matrix)
  • 相关阅读:
    详解并发和并行意义
    MoleHill Getting Started AGAL(转)
    解决setInterval计时器不准的问题
    Flash视频播放器开发经验总结
    利用pushState开发无刷页面切换
    用小乐图客抓取人人网照片
    如何在Flash中新窗口打开页面而不被拦截
    响应式开发总结
    用Asroute解决复杂状态切换问题
    对iframe跨域通信的封装
  • 原文地址:https://www.cnblogs.com/lexus/p/2270661.html
Copyright © 2011-2022 走看看