1

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

任何帮助将不胜感激。

4

1 回答 1

3

我相信您的属性名称由于 PCA 过滤器中的一个选项而被截断。

  -一个
  要包含的最大属性数
  转换后的属性名称。
  (-1 = 包括所有,默认值: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.185stalksurfacebelowring=s+0.185伤痕+0.18 stalkbelowroot=b-0.176stalkcolor =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.125 种群=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.05栖息地=u-0.048stalkcolorabovering=o-0.048stalkcolorbelowring=o+0.047veilcolor=w-0.046population=c+0.046capshape=k+0.046ringtype=e-0.046gillaattachment-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.003 stalkcolorabovering=y-0.003veilcolor=y+0.001stalksurfaceabovering=y+0.001capcolor=u+0.001capcolor=r-0.001capcolor=c+0 stalkcolorabovering=c+0 气味=m+0 ringtype=n+0 stalkcolorbelowring=c+0环号=n+0 环型=f
于 2013-10-27T15:29:25.277 回答