全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
5499 4
2007-10-31

我是个程序新手,所以对指令都一窍不通,有人能分享用R执行ChiMerge的完整教学吗~@@?拜托了!

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2007-10-31 16:12:00

1.Package dprep 要自己安装,安装步骤如下:

  开启R,Package\Install package(s)\dprep

2.我提供两个文件iris.txt & chimerge_demo.R

  没安装dprep,亦可在命令窗口运行,

  chimerge_demo.R 已包含细部分解.

3.a)iris.txt 放在c碟.

  b)运行chimerge_demo.R

     File\Open script\chimerge_demo.R

     Edit\Run all

    
169098.rar
大小:(1.68 KB)

 马上下载


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-10-31 20:07:00

我测试了!! 可以运行呢!

不过我有几个问题想要问一下~@@”

1.一开始的程序代码如下,是在算threshold=qchisq(1-alpha,class-1)  #5.991465 ?

. "tchisq" <-

function(obs)

{

 esp=matrix(0,2,dim(obs)[2])

 for (i in 1:2)

    {

      for (j in 1:dim(obs)[2])

         {

           esp[i,j]=(sum(obs[i,])*sum(obs[,j]))/sum(obs)

           if (esp[i,j]==0)

             {

               esp[i,j]=0.1

             }

         }

    }

 test=sum(((obs-esp)^2)/esp)

 print(test)

}

2.他最后discredata后跑出了150笔的数据是代表slswplpw各自为目标时的离散化后范围吗??

3.离散化一开始不是要定义class,class=dim(table(data[,p])) 这段码定义的吗?不过我看不出来他分为多少~@@

4. for (s in 1:(length(z)+5))  这段码中的S代表??

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2007-11-1 16:00:00

程序中比较重要的function是:

  qchisq(), tchisq(), cut(), table()

alpha,degrees of freedom, qchisq()算出threshold,

  threshold=qchisq(1-alpha,class-1)

tchisq()算出 chi-square,

  test[k]=tchisq(d)

由于你没安装dprep package,所以程序一开始先给出"tchisq".

a=cut(data[,j],breaks=midpoint,include.lowest=TRUE)

b=table(a,data[,p])

j=1   #(sepal length)

b=

     a        1 2 3

  [4.3,4.35]  1 0 0

  (4.35,4.45] 3 0 0

  (4.45,4.55] 1 0 0

  (4.55,4.65] 4 0 0

  (4.65,4.75] 2 0 0

  (4.75,4.85] 5 0 0

  (4.85,4.95] 4 1 1

  (4.95,5.05] 8 2 0

  (5.05,5.15] 8 1 0

  (5.15,5.25] 3 1 0

  (5.25,5.35] 1 0 0

  (5.35,5.45] 5 1 0

  (5.45,5.55] 2 5 0

  (5.55,5.65] 0 5 1

  (5.65,5.75] 2 5 1

  (5.75,5.85] 1 3 3

  (5.85,5.95] 0 2 1

  (5.95,6.05] 0 4 2

  (6.05,6.15] 0 4 2

  (6.15,6.25] 0 2 2

  (6.25,6.35] 0 3 6

  (6.35,6.45] 0 2 5

  (6.45,6.55] 0 1 4

  (6.55,6.65] 0 2 0

  (6.65,6.75] 0 3 5

  (6.75,6.85] 0 1 2

  (6.85,6.95] 0 1 3

  (6.95,7.05] 0 1 0

  (7.05,7.15] 0 0 1

  (7.15,7.25] 0 0 3

  (7.25,7.35] 0 0 1

  (7.35,7.5]  0 0 1

  (7.5,7.65]  0 0 1

  (7.65,7.8]  0 0 4

  (7.8,7.9]   0 0 1

对哪个function有疑问,请在command line键入,

?qchisq

寻求on-line help.

靠你自己慢慢学习细细体会了.

 

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2008-3-29 12:35:00

求救~><”

在这个程序中~我想把class3改为5

但是class=dim(table(data[,p]))

我不知从哪改~请大大交我一下吧……

[此贴子已经被作者于2008-3-29 12:38:09编辑过]

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群