classify: Classify Rows of a Count Matrix

Description Usage Arguments Value See Also Examples

View source: R/classify.R

Description

Use a count matrix to classify the rows, based on the frequencies in the cells.

Usage

1
classify(x, n = 1, ties.method = "probability", seed = NULL, ...)

Arguments

x

A term_count or count matrix/data.frame.

n

The number of classifications per row to return.

ties.method

Either c("probability", "random", "first", "last") for specifying how ties are handled; "probability" by default. This utilizes the probability distributions from all tags (regardless of strength/counts of tags) to randomly sample with probabilties to break ties. Note that this can lead to different results each time classify is run. Use seed to make results reproducible. The other methods use max.col for tie breaking. See max.col for a description of those arguments.

seed

A seed to use in the sample to make the results reproducible.

...

ignored.

Value

Returns a single vector or list of ordered vectors of predicted classifications; order by term frequency. Ties default to random order.

See Also

max.col

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Not run: 
library(dplyr)
data(presidential_debates_2012)

discoure_markers <- list(
    response_cries = c("\\boh", "\\bah", "\\baha", "\\bouch", "yuk"),
    back_channels = c("uh[- ]huh", "uhuh", "yeah"),
    summons = "hey",
    justification = "because"
)

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    classify()

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    classify() %>%
    plot()

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    classify() %>%
    plot(rm.na=FALSE)

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    classify(n = 2)

presidential_debates_2012 %>%
    with(., term_count(dialogue, TRUE, discoure_markers)) %>%
    {.[!uncovered(.), -c(1:2)]} %>%
    classify()

## End(Not run)

trinker/termco documentation built on Jan. 7, 2022, 3:32 a.m.