regress.text: Fit regularized regressions to text data given a corpus and...

Description Usage Arguments Value Examples

View source: R/regress.text.R

Description

This function will fit regularized regressions to text data given a corpus and outputs.

Usage

1
2
3
  regress.text(text, y, n.splits = 10, size = 0.8,
  standardizeCase = TRUE, stripSpace = TRUE,
  removeStopwords = TRUE)

Arguments

text

A character vector containing the documents for analysis.

y

A numeric vector of outputs associated with the documents.

n.splits

How many resampling steps should be used to set lambda?

size

How much of the data should be used during resampling for model fitting?

standardizeCase

Should all of the text be standardized on lowercase?

stripSpace

Should all whitespace be stripped from the text?

removeStopwords

Should tm's list of English stopwords be pulled out of the text?

Value

A list containing regression coefficients, the terms used with those coefficients, the value of lambda used for model assessment, and an estimate of the RMSE associated with that model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library('TextRegression')

text <- c('saying text is good',
'saying text once and saying text twice is better',
'saying text text text is best',
'saying text once is still ok',
'not saying it at all is bad',
'because text is a good thing',
'we all like text',
'even though sometimes it is missing')

y <- c(1, 2, 3, 1, 0, 1, 1, 0)

results <- regress.text(text, y)

print(results)

johnmyleswhite/TextRegression documentation built on May 19, 2019, 5:17 p.m.