从Weka PCA中提取完整的属性名称

时间:2013-10-27 06:46:08

标签: weka pca

我目前正在编写一些代码来使用Weka分析mushrooms data off UCI。我试图获取属性的值(即系数),但属性名称被截断(由“...”表示),并且无法从属性中获取完整的系数集。 例如      @attribute -0.251a = e + 0.242m = k + 0.241n = k-0.224t = p + 0.213f = f ... numeric

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

我认为您的属性名称因PCA过滤器中的选项而被截断。

  -A 
  Maximum number of attributes to include in 
  transformed attribute names.
  (-1 = include all, default: 5)

使用以下代码,我将此选项的值更改为-1,并从转换后的数据中打印属性名称。

 Instances originalTrain=...//load the training data

 PrincipalComponents pca = new PrincipalComponents(); // new PCA filter
 pca.setMaximumAttributeNames(-1); //set the value to -1
 pca.setInputFormat(originalTrain);// inform filter about dataset 
 Instances newData = Filter.useFilter(originalTrain, pca);   // apply filter

 System.out.println(newData.attribute(0).name()); //look at new name  

明显未截断的属性名称的示例是(滚动到视图):

0.257stalksurfacebelowring=k+0.256stalksurfaceabovering=k+0.234ringtype=l+0.231odor=f-0.215ringtype=p-0.212stalksurfaceabovering=s+0.206sporeprintcolor=h-0.195stalksurfacebelowring=s+0.185bruises+0.18 stalkroot=b-0.176stalkcolorbelowring=w-0.175stalkcolorabovering=w-0.173odor=n-0.139sporeprintcolor=n-0.134sporeprintcolor=k+0.133habitat=p+0.133gillcolor=b+0.13 stalkcolorbelowring=b+0.13 stalkcolorabovering=b+0.129population=v+0.128stalkcolorabovering=n-0.125population=s-0.124stalkroot=e+0.121stalkcolorbelowring=n-0.119capcolor=w+0.119stalkcolorbelowring=p+0.119stalkcolorabovering=p-0.11gillspacing-0.105stalkroot=c-0.101gillcolor=n+0.094sporeprintcolor=w-0.087capshape=b-0.085gillcolor=k-0.082odor=l-0.082odor=a-0.082habitat=m+0.08 capcolor=y-0.08gillcolor=w+0.078gillcolor=h-0.076population=n-0.073habitat=g-0.072gillsize+0.068odor=y+0.068odor=s-0.067population=a-0.065capsurface=s-0.064odor=p+0.063gillcolor=g-0.059stalksurfaceabovering=f+0.057capsurface=y-0.057ringnumber=t-0.057stalksurfacebelowring=f+0.055ringnumber=o+0.051population=y-0.05habitat=u-0.048stalkcolorabovering=o-0.048stalkcolorbelowring=o+0.047veilcolor=w-0.046population=c+0.046capshape=k+0.046ringtype=e-0.046gillattachment-0.045stalkcolorabovering=g-0.045stalkcolorbelowring=g+0.043capcolor=e-0.041stalkroot=r-0.039gillcolor=u+0.039capcolor=g+0.034habitat=l-0.034veilcolor=n-0.034veilcolor=o-0.033habitat=w-0.031capcolor=p-0.031odor=c-0.031stalksurfacebelowring=y-0.031sporeprintcolor=r+0.03 capshape=f-0.029capcolor=n-0.028gillcolor=o-0.024stalkshape-0.024sporeprintcolor=o-0.024sporeprintcolor=y-0.024sporeprintcolor=b-0.024gillcolor=y-0.023gillcolor=e-0.023capcolor=b-0.023stalkcolorabovering=e-0.023stalkcolorbelowring=e-0.019gillcolor=r-0.018capshape=s-0.018sporeprintcolor=u-0.015capshape=x+0.012habitat=d+0.009gillcolor=p-0.006capsurface=g+0.005capsurface=f-0.004capshape=c+0.003stalkcolorbelowring=y-0.003stalkcolorabovering=y-0.003veilcolor=y+0.001stalksurfaceabovering=y+0.001capcolor=u+0.001capcolor=r-0.001capcolor=c+0    stalkcolorabovering=c+0    odor=m+0    ringtype=n+0    stalkcolorbelowring=c+0    ringnumber=n+0    ringtype=f