admin管理员组

文章数量:815368

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



本文标签: R maxent