Databricks Certified Machine Learning Professional Practice Questions

Databricks Certified Machine Learning Professional exam preparation

Databricks Certified Machine Learning Professional practice questions in English: 180 questions with explanations. The mock exam has 59 questions and 120 minutes.

Databricks Certified Machine Learning Professional free question 2 / 10 · Domain 1: Model Development

A StringIndexer with default settings is fit on a plan column that contains "basic" 700 times, "premium" 250 times and "enterprise" 50 times. Which indices does it assign?

  1. basic = 0, premium = 1, enterprise = 2
  2. basic = 0, enterprise = 1, premium = 2
  3. premium = 0, enterprise = 1, basic = 2
  4. enterprise = 0, premium = 1, basic = 2
Show the answer and explanation

Answer: A

Why this is correct
StringIndexer encodes a string column of labels to indices in [0, numLabels) and supports four ordering options: frequencyDesc, frequencyAsc, alphabetDesc and alphabetAsc. The default is frequencyDesc, which orders by descending label frequency so that the most frequent label gets 0. Here basic (700) gets 0, premium (250) gets 1 and enterprise (50) gets 2. Ties under a frequency ordering are further sorted by alphabet.

Why the other options are wrong
"basic = 0, enterprise = 1, premium = 2" … This is alphabetical order, ascending (alphabetAsc). It is one of the four supported ordering options, not the default.
"enterprise = 0, premium = 1, basic = 2" … This is ascending order by label frequency (frequencyAsc), where the least frequent label gets 0. It is not the default.
"premium = 0, enterprise = 1, basic = 2" … This is descending alphabetical order (alphabetDesc). It is not the default.

Default ordering is by frequency
Choose another of the four ordering options when the indices must follow alphabetical order instead.

Go to the Databricks Certified Machine Learning Professional practice app (10 free questions; purchase unlocks all questions)

See the full practice set