1、首先下载安装weka

http://www.cs.waikato.ac.nz/ml/weka/downloading.html

2、打开weka,选择第一项Explorer

3、准备数据集文件,在weka中,一般数据文件为:xxx.arff,比如我编辑一个文件叫做tumor.arff,文件的内容为:

@RELATION tumor

@ATTRIBUTE size NUMERIC
@ATTRIBUTE 'Class' {'1','0'}

@DATA
0.0,'0'
0.1,'0'
0.7,'1'
1.0,'0'
1.1,'0'
1.3,'0'
1.4,'1'
1.7,'1'
2.1,'1'
2.2,'1'

稍微解释一下数据,size属性表示tumor的大小,被单引号括起来的Class应该是weka中的保留字,专门表示类别。

4、加载数据。在主界面的Preprocess选项卡下,点Open file,然后选择第三步中准备好的数据文件:tumor.arff

在这个界面下,可以看到关于数据的一些统计信息,以及一些图形化的显示,同学们可以自己探索。

6、切换到主界面的Classify选项卡,点击Choose,在functions分支下面选择Logistic。

Test options选择Use training set,然后点击Start即可

7、再给出一组测试数据:

@RELATION tumor
@ATTRIBUTE x1 NUMERIC
@ATTRIBUTE x2 NUMERIC
@ATTRIBUTE 'Class' {'1','0'}

@DATA
0.0 2.9 '0'
1 1.9 '0'
2.0 0.9 '0'
3.0 -0.1 '0'
4.0 -1.1 '0'
0.0 2.5 '0'
1 1.5 '0'
2.0 0.5 '0'
3.0 -0.5 '0'
4.0 -1.5 '0'
0.0 2.0 '0'
1 1 '0'
2.0 0.0 '0'
3.0 -1 '0'
4.0 -2.0 '0'
0.0 1 '0'
1 0.0 '0'
2.0 -1 '0'
3.0 -2.0 '0'
4.0 -3.0 '0'
0.2 2.9 '1'
1.2 1.9 '1'
2.2 0.9 '1'
3.2 -0.1 '1'
4.2 -1.1 '1'
1.2 2.9 '1'
2.2 1.9 '1'
3.2 0.9 '1'
4.2 -0.1 '1'
5.2 -1.1 '1'
2.2 2.9 '1'
3.2 1.9 '1'
4.2 0.9 '1'
5.2 -0.1 '1'
6.2 -1.1 '1'
3.0 0.2 '0'
1 2.3 '0'
1 1.8 '1'
2.0 0.8 '1'

weka训练结果:

训练出来的模型是:h(x)=1/(1+exp(-(-13.9827+4.6001*x1+4.6302*x2)))

用weka来做Logistic Regression的更多相关文章

  1. 逻辑回归 Logistic Regression

    逻辑回归(Logistic Regression)是广义线性回归的一种.逻辑回归是用来做分类任务的常用算法.分类任务的目标是找一个函数,把观测值匹配到相关的类和标签上.比如一个人有没有病,又因为噪声的 ...

  2. Logistic Regression - Formula Deduction

    Sigmoid Function \[ \sigma(z)=\frac{1}{1+e^{(-z)}} \] feature: axial symmetry: \[ \sigma(z)+ \sigma( ...

  3. Stanford机器学习笔记-2.Logistic Regression

    Content: 2 Logistic Regression. 2.1 Classification. 2.2 Hypothesis representation. 2.2.1 Interpretin ...

  4. Logistic Regression vs Decision Trees vs SVM: Part II

    This is the 2nd part of the series. Read the first part here: Logistic Regression Vs Decision Trees ...

  5. Logistic Regression Vs Decision Trees Vs SVM: Part I

    Classification is one of the major problems that we solve while working on standard business problem ...

  6. Logistic Regression逻辑回归

    参考自: http://blog.sina.com.cn/s/blog_74cf26810100ypzf.html http://blog.sina.com.cn/s/blog_64ecfc2f010 ...

  7. 在opencv3中实现机器学习之:利用逻辑斯谛回归(logistic regression)分类

    logistic regression,注意这个单词logistic ,并不是逻辑(logic)的意思,音译过来应该是逻辑斯谛回归,或者直接叫logistic回归,并不是什么逻辑回归.大部分人都叫成逻 ...

  8. Stanford机器学习---第三讲. 逻辑回归和过拟合问题的解决 logistic Regression & Regularization

    原文:http://blog.csdn.net/abcjennifer/article/details/7716281 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...

  9. Coursera台大机器学习课程笔记9 -- Logistic Regression

    如果只想得到某种概率,而不是简单的分类,那么该如何做呢?在误差衡量问题上,如何选取误差函数这段很有意思. 接下来是如何最小化Ein,由于Ein是可凸优化的,所以采用的是梯度下降法:只要达到谷底,就找到 ...

随机推荐

  1. Monad / Functor / Applicative 浅析

    前言 Swift 其实比 Objective-C 复杂很多,相对于出生于上世纪 80 年代的 Objective-C 来说,Swift 融入了大量新特性.这也使得我们学习掌握这门语言变得相对来说更加困 ...

  2. CentOS minimal 版安装图形界面及中文语言

    1.连接网络: CentOS minimal.iso安装好后, 进入终端,默认是不开网络的, 首先启用网卡, 自动获取ip. ifconfig eth0 up dhclient eth0 再 ifco ...

  3. POJ 2186 Popular Cows tarjan缩点算法

    题意:给出一个有向图代表牛和牛喜欢的关系,且喜欢关系具有传递性,求出能被所有牛喜欢的牛的总数(除了它自己以外的牛,或者它很自恋). 思路:这个的难处在于这是一个有环的图,对此我们可以使用tarjan算 ...

  4. Git学习 -- 搭建Git服务器

    搭建环境 服务器端:CentOS 6.5   IP:192.168.101.129 客户端:CentOS 6.5 . Windows 服务器端: 创建repository版本库,例如/srv/test ...

  5. PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)

    简单dfs #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  6. STL笔记之【map之添加元素】

    //---------------------------------------------------------// 向map中插入元素的方法比较//---------------------- ...

  7. Sichuan State Programming Contest 2012 C。Counting Pair

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=118254#problem/C 其实这道题目不难...就是没有仔细分析... 我们可以发现 ...

  8. 使用Word API打开Word文档 ASP.NET编程中常用到的27个函数集

    使用Word API(非Openxml)打开Word文档简单示例(必须安装Word) 首先需要引入参照Microsoft.Office.Interop.Word 代码示例如下: public void ...

  9. Connecting Universities

    Connecting Universities Treeland is a country in which there are n towns connected by n - 1 two-way ...

  10. hrbustoj 1125 循环小数 II(小数变分数+极限思想)

    #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #i ...