CertLumen

Databricks Machine Learning Associate · Section 3 · 31% of the exam

Identify methods to mitigate data imbalance in training data

One of the objectives of the Databricks Certified Machine Learning Associate exam, in the section “Model Development”. Here is what it covers, the points to remember and a question to try.

What it covers

Pick an algorithm by framing the problem first (label type, data size, interpretability, non-linearity), then check the class balance. When one class is rare, mitigate it in the training data with class weights, resampling or threshold tuning, and judge the result with metrics that notice the minority class.

Points to remember

  • Frame first: continuous label means regression, categorical label means classification, no label means clustering or anomaly detection, interactions mean recommendation (ALS).
  • Linear and logistic models are interpretable baselines; tree ensembles capture non-linearity; random forests reduce variance, boosting reduces bias.
  • Spark ML GBTClassifier supports binary labels only; use random forest, decision tree, multinomial logistic regression or Naive Bayes for multiclass.
  • Trees need no scaling or one-hot encoding; linear models and k-means are sensitive to feature scale.
  • Use single-node libraries when data fits on one machine; use pyspark.ml for distributed training (serverless limit: 100 MB per model).

Try a question

A churn dataset has 300,000 rows and 40 columns and fits easily in the driver's memory. The data scientist wants an XGBoost model and to try about 100 hyperparameter configurations quickly on a multi-node cluster. Which approach is most appropriate?

  1. AUse Spark ML only, because single-node libraries such as XGBoost can't read data that is stored in Unity Catalog tables
  2. BRepartition the pandas DataFrame across the workers, so that one XGBoost model trains faster on each partition
  3. CTrain every configuration one after another on the driver, because tuning trials can't run in parallel
  4. DTrain single-node XGBoost on pandas data and spread the independent tuning trials across the cluster's workers
Show the answer

D. Data size decides the library. When the training data fits on one machine, single-node libraries such as scikit-learn, XGBoost and LightGBM are simple and fast, and the cluster is used to run many tuning trials at once (for example with Optuna, Joblib Spark or, on older runtimes, Hyperopt SparkTrials). Spark ML (pyspark.ml) is for data too large for one machine.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Choosing an Algorithm and Handling Imbalanced Classes teaches this objective (about 40 minutes), and 16 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 48 objectives · Next objective →