[WEKA] 1 概览

A LITTLE BIT OF EVERYTHING

什么是数据挖掘?什么是Weka?

数据挖掘是一门成熟的技术,Weka 是数据挖掘的工具包,是 Waikato Environment for Knowledge Analysis 的首字母缩略词,我们称作 Weka。

Exploring the Explorer

更多天气数据运用

instances 实例
attributes 属性
class 类属性
我们已在上节课学习了数据文件,是关于天气的数据,一个非常简单的数据集。它包含了 14 天的天气,或者说实例。 每天是一个实例,由五种属性来描述。四种与天气有关, 最后一个叫类属性。它是我们希望要预测的。
discrete (“nominal”) : “classification” problem
continuous (“numeric”): “regression” problem

更多玻璃数据运用

ARFF 文件格式 ARFF file format:
%打头的行都是说明
@data后面都是instances

@relation Glass
@attribute 'RI' numeric
@attribute 'Na' numeric
@attribute 'Mg' numeric
@attribute 'Al' numeric
@attribute 'Si' numeric
@attribute 'K' numeric
@attribute 'Ca' numeric
@attribute 'Ba' numeric
@attribute 'Fe' numeric
@attribute 'Type' { 'build wind float', 'build wind non-float', 'vehic wind float', 'vehic wind non-float', containers, tableware, headlamps}
@data
1.51793,12.79,3.5,1.12,73.03,0.64,8.77,0,0,'build wind float'

Question 2
Which of these attributes, taken by itself, gives the best indication of the class?
sepallength
sepalwidth
petalwidth
When you look at the class distribution for petalwidth, you can see that it has the least overlap of colors for all the bars.
//直接观察法,观察每一个属性的数据的class分类情况


竟然猜对了( •̀ ω •́ )

Building a classifier 建立分类器

Classify panel分类器面板
J48 一个决策树分类器

  1. J48 的配置面板改变参数,以及“More”按钮
    -Set minNumObj to 15 to avoid small leaves
    -… option: pruned vs unpruned trees
  2. 右击我们之前的运行记录,得到一个小菜单。单击“visualize tree”。
  3. Confusion Matrix
  4. weka的percentage of correctly classified instances保留小数点后四位,实际中我们常保留整数。

Using a filter 使用过滤器

在使用分类器之前,预处理数据很重要。
过滤器分为属性过滤器和实例过滤器。

Use a filter to remove an attribute 使用过滤器删除一个属性

方法一:直接选中属性,左下角remove。
方法二:和选择classify方法一样,点击preprocess标签下的choose,进入filter
Open weather.nominal.arff (again!)
 Check the filters
– supervised vs unsupervised
– attribute vs instance
 Choose the unsupervised attribute filter Remove
 Check the More information; look at the options
 Set attribute Indices to 3 and click OK 删除属性湿度(humidity):湿度的序号是 3
 Apply the filter
 Recall that you can Save the result
 Press Undo


修改attributeIndex & nominalIndex

Allfilter 和 MultiFilter 用于合并使用多种过滤器。
监督过滤器在过滤时会使用类的值,它们不如不使用类值的无监督过滤器更为广泛应用。
在选择过滤器的时候,我们必须考虑是用监督过滤器还是无监督过滤器,用属性过滤器还是实例过滤器。之后,就是用你的常识在过滤器列表中找到你想要的过滤器。

Remove instances where humidity is high 删除湿度值为 high 的实例

 Supervised or unsupervised? 无监督
 Attribute or instance? 实例
 Look at them
 Select RemoveWithValues
 Set attributeIndex
 Set nominalIndices
 Apply
 Undo

Filters can be very powerful
Judiciously removing attributes can
– improve performance
– increase comprehensibility

Question 3
Identify one of the attributes that was removed by clicking Undo and then Apply. Now figure out why it was removed.
A The attribute name was too short
B Only one of the attribute’s values actually appears in the dataset
C The attribute only had two possible values
[B]
An attribute that has the same value for all instances in the dataset doesn’t yield any additional information, and Weka therefore deems it to be useless.

Question 4
Open the glass.arff dataset (which was downloaded when you installed Weka). Apply the unsupervised attribute filter Normalize. What is the new range (i.e. minimum and maximum) of the Na attribute?
The Normalize filter scales attributes into the range [0, 1].

Visualizing your data 可视化数据

Open iris.arff
 Bring up Visualize panel
 Click one of the plots; examine some instances
 Set x axis to petalwidth and y axis to petallength
 Click on Class colour to change the colour
 Bars on the right change correspond to attributes: click for x
axis; right-click for y axis
 Jitter slider
 Show Select Instance: Rectangle option
 Submit, Reset, Clear and Save

  1. 我们可以在下拉菜单中选择不同的 x 轴和 y 轴。更简单的方法是,单击这些代表不同属性的小横条。单击这里,x 轴就会改变为花萼长;单击这里,x 轴就会改变为花萼宽;单击这里,x 轴就会改变为花瓣长;等等。右键单击这里,y 轴就会改变为花萼长。这样,我们就可以快速地浏览这些不同的图。
  2. 抖动(jitter)滑块可以帮助你区分实际位置特别近的点。
  3. 选择数据集的一部分

Visualizing classification errors 可视化分类结果

 Run J48 (trees>J48)
 Visualize classifier errors (from Results list) 日志区右键
 Plot predictedclass against class
 Identify errors shown by confusion matrix

深入了解你的数据,并且建立可视化模型。你可以做各种各样的事情。你可以清理
你的数据,删除异常数据。你可以观察分类误差。
例如,有一种过滤器可以添加类为一个新的属性。让我们去看看。找到这个过滤器,添加一个属性。这是个监督过滤器,因为它用到了类。添加一个属性,用过滤
器 AddClassfication。这里,我们打开配置面板,机器学习方案,选择 J48,将
outputClassification 设置为 True。完成配置。现在应用这个过滤器。它将添加一个新的属性。完成了。这个新增的属性是根据 J48 分类的结果。
Weka 的功能非常强大,你可以利用分类器和过滤器做各种各样的事情。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 200,302评论 5 470
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,232评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 147,337评论 0 332
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,977评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,920评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,194评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,638评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,319评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,455评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,379评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,426评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,106评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,696评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,786评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,996评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,467评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,043评论 2 341

推荐阅读更多精彩内容