% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/information_gain.R
\name{ndH}
\alias{ndH}
\title{Information gain (uniform distribution)}
\usage{
ndH(dataf, doc_col, term_col, count_col)
}
\arguments{
\item{dataf}{Tidy document-term matrix}

\item{doc_col}{Column of \code{dataf} with document IDs}

\item{term_col}{Column of \code{dataf} with terms}

\item{count_col}{Column of \code{dataf} with document-term counts}
}
\value{
Dataframe with columns

\if{html}{\out{<div class="sourceCode">}}\preformatted{- `\{\{ term col \}\}`, term
- `dH`, information gain relative to uniform distribution over documents
- `n`, total count of term occurrence
- `ndH`, \eqn{\log_2 n \times \delta H}
}\if{html}{\out{</div>}}
}
\description{
Calculates \eqn{\log_2 n \times \delta H}, the log total occurrence times information gain (relative to the uniform distribution) for each term. I prefer this for vocabulary selection over methods such as TF-IDF.
}
\examples{
  library(dplyr)
  library(tidytext)
  library(janeaustenr)
  austen_df = austen_books() |>
      unnest_tokens(term, text, token = 'words') |>
      mutate(author = 'Jane Austen') |>
      count(author, book, term)
  ndH(austen_df, book, term, n)
}
