用R的lsa包运行lsa分析,默认使用dimcalc_share()保留奇异值。根据函数帮助“finds the first position in the descending sequence of singular values where their sum meets or exceeds the specified share”,这个函数要保留前n个最大奇异值,这些值的和占所有奇异值的share百分比。
函数代码:
function(share=0.5)
{
function(x){
if(any(which(cumsum(s/sum(s))<=share))){
d=max(which(cumsum(s/sum(s))<=share))+1
}
else{
d=length(s)
}
return(d)
}
}
根据这个R代码,如果第一个降序排列的奇异值所占比重比share大,那么所有值都将被保留,但这个函数是不是应该只保留此第一个奇异值呢?
另外,我自己写了个函数,保留了比重占0.5和0.8的奇异值,用得到的语义空间进行文档相似度测度,并据此分类,但training error高于直接使用原始term-document-matrix。能帮忙分析一下其中原因么?(term-document-matrix没有进行权重分配,使用的是原始的计数)