Get startedGet started for free

Removing sparse terms

Running classification models on sparse matrices can be a computational nightmare. Without access to GPUs or cloud compute resources, you might run into time and memory issues on your local computer. You have been given a document-term matrix and plan on running several different algorithms to find the best classification model. In this exercise, you will remove some of the sparse terms from the provided matrix, matrix, at different sparsity levels.

For each level of sparsity, note the number of remaining terms in the matrix.

This exercise is part of the course

Introduction to Natural Language Processing in R

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

less_sparse_matrix <-
  ___(___, sparse = ___)

# Print results
matrix
less_sparse_matrix
Edit and Run Code