R maxent

只是简单走一遍

> library(maxent)
> data<-read.csv(system.file("data/NYTimes.csv.gz",package="maxent"))

data 大体是这样的

 

Article_ID

Date

Title

Subject

Topic.Code

1

41246

1-Jan-96

Nation's Smaller Jails Struggle To Cope With Surge in Inmates

Jails overwhelmed with hardened criminals

12

2

41257

2-Jan-96

FEDERAL IMPASSE SADDLING STATES WITH INDECISION

Federal budget impasse affect on states

20

3

41268

3-Jan-96

Long, Costly Prelude Does Little To Alter Plot of Presidential Race

Contenders for 1996 Presedential elections

20

4

41279

4-Jan-96

Top Leader of the Bosnian Serbs Now Under Attack From Within

Bosnian Serb leader criticized from within

19

5

41290

5-Jan-96

BATTLE OVER THE BUDGET: THE OVERVIEW; LEADERS IN HOUSE DROP G.O.P. PLAN ON U.S. WORKERS

Battle over budget: Republican leaders abandon strategy of using closed Government offices

1

6

41302

7-Jan-96

South African Democracy Stumbles on Old Rivalry

political violence in south africa

19

7

41314

8-Jan-96

Among Economists, Little Fear on Deficit

economists not afraid of a deficit

1


> corpus<-Corpus(VectorSource(data$Title[1:150]))

> matrix<-DocumentTermMatrix(corpus)

>sparse<-as.compressed.matrix(matrix)

> model<-maxent(sparse[1:100],data$Topic.Code[1:100])

> results<-predict(model,sparse[101:150])
results如下

 

labels

19

16

24

20

1

12

5

2

6

15

3

10

30

7

17

26

4

28

13

1

19

0.457087826659217

0.0213082778550618

0.0213082778550618

0.031094676823177

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0876652559145207

0.104528072777158

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

0.0213082778550618

2

17

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.117486554487558

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.248875785414505

0.0372728035351727

0.0372728035351727

0.0372728035351727

0.0372728035351727



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值