zoukankan      html  css  js  c++  java
  • Weka的基本概念和操作介绍

    最近在学习Weka发现是一个很不错的数据挖掘工具,在这里介绍下。

    什么是数据挖掘?什么是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

    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 的功能非常强大,你可以利用分类器和过滤器做各种各样的事情。



    本次内容引用自:https://www.jianshu.com/p/4e77cf818618


  • 相关阅读:
    手机管理中的应用【6】——电源管理篇
    NYOJ 14 场地安排(它可以被视为一个经典问题)
    YUV格式转换RGB(基于opencv)
    互联网金融进入洗礼阶段,控制风险是制胜之道
    Uva 409-Excuses, Excuses!(串)
    MATLAB新手教程
    IE无法打开internet网站已终止操作的解决的方法
    关于SetCapture() 和 ReleaseCapture()的使用方法
    wxWidgets刚開始学习的人导引(2)——下载、安装wxWidgets
    MyReport报表引擎2.7.6.7新功能
  • 原文地址:https://www.cnblogs.com/zhuozige/p/13111664.html
Copyright © 2011-2022 走看看