Categorical columns

In the next step, we will explore categorical columns. The H2O parser marks a column as a categorical column only if it contains a limited set of string values. This is the main difference from columns that are marked as string columns. They contain more than 90 percent of unique values (see, for example, the url column that we explored in the previous paragraph). Let's collect a list of all the categorical columns in our dataset and also the sparsity of individual features:

val categoricalColumns = loanDataHf.names().indices  .filter(idx => loanDataHf.vec(idx).isCategorical)  .map(idx => (loanDataHf.name(idx), loanDataHf.vec(idx).cardinality()))  .sortBy(-_._2)println(s"Categorical columns:${table(tblize(categoricalColumns, ...

Get Mastering Machine Learning with Spark 2.x now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.