zoukankan      html  css  js  c++  java
  • 【Weka】Weka简介

    Weka简介 (http://www.china-pub.com/computers/common/info.asp?id=29304)

          WEKA的全名是怀卡托智能分析环境(Walkato Environment for Knowledge Analysis),WEKA的开发者来自新西兰,而新西兰有一种鸟名字叫做weka,便是weka图标上的那只。

          WEKA是一个公开的数据挖掘工作平台,集合了大量能承担数据挖掘任务的机器学习算法,包括预处理、分类、回归、聚类、关联规则以及在新的交互式界面上的可视化。

          2005年8月,在第十一届ACM SIGKDD的会议上,怀卡托大学的Weka小组获得了数据挖掘和知识探索领域的最高服务奖,Weka系统得到了广泛的认可,被誉为数据挖掘和机器学习历史上的里程碑,是现金最完备的数据挖掘工具之一。Weka每月的下载次数都已破万。

        --摘自(http://www.china-pub.com/computers/common/info.asp?id=29304)

    数据格式

          WEKA的数据是.arff(Attribute-Relation File Format)格式的,是ASCII文本文件。相当于一张二维的表格,@attribute中第二列是表中各项的属性,第二列指定了表格该项的类型,一般有五种类型:{NORMINAL, NUMBERIC, STRING, DATE, RELATION}。下面是一个例子:

    @RELATION iris

    @ATTRIBUTE sepallength REAL
    @ATTRIBUTE sepalwidth REAL
    @ATTRIBUTE petallength REAL
    @ATTRIBUTE petalwidth REAL
    @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}

    @DATA
    5.1,3.5,1.4,0.2,Iris-setosa
    4.9,3.0,1.4,0.2,Iris-setosa
    4.7,3.2,1.3,0.2,Iris-versicolor
    4.6,3.1,1.5,0.2,Iris-setosa
    5.0,3.6,1.4,0.2,Iris-virginica
    5.4,3.9,1.7,0.4,Iris-setosa

    其中:

    1. @RELATION 我自己的理解是相当于给个名字,这二个字符串包含空格,必须加上引号,英文符号中的单引和双引都可;

    2. @ATTRIBUTE 中第二列是表中各项的属性,第二列指定了表格该项的类型,一般有五种类型:{NORMINAL, NUMBERIC, STRING, DATE, RELATION};
    3. @DATA标记后面写的都是数据,每一行都是一组数据。

          在WEKA中给用户提供了从数据库和Excel导出CSV文件转换成ARFF文件的方法,如果不嫌麻烦写个写文件的函数也一样。

    稀疏数据格式

          稀疏数据格式Sparse ARFF和ARFF文件很像,是WEKA中提供的为了有大量零值数据格式。稀疏数据格式一般是<index><space><value>

    如上面例子中的

    5.1,3.5,1.4,0.2,Iris-setosa
    可以写成:
    1 5.1,2 3.5,3 1.4,4 0.2,5 Iris-setosa

    文本数据格式

          文本数据格式在数据格式中并没有,但是在WEKA的数据样例中有这样的例子。当你把文本用TextDirectoryLoader将文本集合转化成数据的时候就会形成这样的格式。下面是一个例子:

    @relation D__temp_weka_TextDirectoryLoader

    @attribute text string
    @attribute @@class@@ {Libya,'Wall Street'}

    @data
    'Libyan fighters have raised the new government',Libya
    'A special briefing by senior U.S. State Department Officials on Secretary Hillary Rodham Clinton\'s visit to Libya:',Libya
    'Occupy Wall Street plans to demand probe into incident involving cop; Group also wants charges against protesters dropped','Wall Street'
    'As Occupy Wall Street enters its fourth week, TIME takes a look at other sociopolitical movements in U.S. history','Wall Street'
    'As Occupy Wall Street enters its fourth week, TIME takes a look at other sociopolitical movements in U.S. history','Wall Street'
    'As Occupy Wall Street enters its fourth week, TIME takes a look at other sociopolitical movements in U.S. history','Wall Street'

        使用TextDirectoryLoader转化文本,使用命令行:

        

    java weka.core.converters.TextDirectoryLoader -dir D:/temp/weka/TextDirectoryLoader/ > D:/temp/weka/data.arff

          路径自己定义,记住不要漏掉符号>在文本文件夹路径和输出文件路径之间。

          其中文件夹路径下面有两个文件夹:Libya和Wall Street。这两个文件夹下面分别有属于各自类别的文本。

  • 相关阅读:
    mac os programming
    Rejecting Good Engineers?
    Do Undergrads in MIT Struggle to Obtain Good Grades?
    Go to industry?
    LaTex Tricks
    Convert jupyter notebooks to python files
    How to get gradients with respect to the inputs in pytorch
    Uninstall cuda 9.1 and install cuda 8.0
    How to edit codes on the server which runs jupyter notebook using your pc's bwroser
    Leetcode No.94 Binary Tree Inorder Traversal二叉树中序遍历(c++实现)
  • 原文地址:https://www.cnblogs.com/xiaoka/p/2412421.html
Copyright © 2011-2022 走看看