weka中分析对象是以arff格式文件表示的,主要有两部分组成:文件头和数据。文件头包括relation说明和属性说明。@relation weather @attribute temperature real @attribute windy {TRUE, FALSE} 属性部分声明属性名称和类别(如果为枚举型则说明预设数据值),数据部分由@data 引导。主要处理的数据类型有枚举型(nominal)数值型(integer real)、文本型(string)、日期型(date)。从本质上来讲只有nomianl 和numeric 两类,因为string 可看作特殊的nominal ,date则可以作为numeric类型处理。date本身作为String类型,当arff文件读入时自动转换为date,其中每一部分(年月日等)可作为整型处理。
weather表对应的arff文件如下:
@relation weather
@attribute outlook {sunny, overcast, rainy} @attribute temperature real @attribute humidity real @attribute windy {TRUE, FALSE} @attribute play {yes, no}
@data sunny,85,85,FALSE,no sunny,80,90,TRUE,no overcast,83,86,FALSE,yes rainy,70,96,FALSE,yes rainy,68,80,FALSE,yes rainy,65,70,TRUE,no overcast,64,65,TRUE,yes sunny,72,95,FALSE,no sunny,69,70,FALSE,yes rainy,75,80,FALSE,yes sunny,75,70,TRUE,yes overcast,72,90,TRUE,yes overcast,81,75,FALSE,yes rainy,71,91,TRUE,no
arff格式文件的特点:a standard way of representing datasets that consist of independent,unordered instances and do not involve relationships among instances。各个记录相互独立、没有顺序要求,同时各个记录间不存在关系。 called an ARFF file. |