Learn R Programming

text2vec (version 0.6.4)

BNS: BNS

Description

Creates BNS (bi-normal separation) model. Defined as: Q(true positive rate) - Q(false positive rate), where Q is a quantile function of normal distribution.

Usage

BNS

Format

R6Class object.

Fields

bns_stat

data.table with computed BNS statistic. Useful for feature selection.

Usage

For usage details see Methods, Arguments and Examples sections.


bns = BNS$new(treshold = 0.0005)
bns$fit_transform(x, y)
bns$transform(x)

Methods

$new(treshold = 0.0005)

Creates bns model

$fit_transform(x, y)

fit model to an input sparse matrix (preferably in "dgCMatrix" format) and then transforms it.

$transform(x)

transform new data x using bns from train data

Arguments

bns

A BNS object

x

An input document term matrix. Preferably in dgCMatrix format

y

Binary target variable coercible to logical.

treshold

Clipping treshold to avoid infinities in quantile function.

Details

Bi-Normal Separation

Examples

Run this code
if (FALSE) {
data("movie_review")
N = 1000
it = itoken(head(movie_review$review, N), preprocessor = tolower, tokenizer = word_tokenizer)
vocab = create_vocabulary(it)
dtm = create_dtm(it, vocab_vectorizer(vocab))
model_bns = BNS$new()
dtm_bns = model_bns$fit_transform(dtm, head(movie_review$sentiment, N))
}

Run the code above in your browser using DataLab