CertSafari

    Free Scikit-learn Expert Practitioner Certification Sample Questions

    35 free sample questions from our bank of 510+, covering every exam domain, with answers and detailed explanations. Updated August 2026.

    Domain 1: Machine Learning Concepts

    Subdomain 1.2: Loss functions and splitting criteria

    1.You are training a LogisticRegression model on an imbalanced dataset and want to penalize misclassifications of the minority class more. Which parameter should you set?

    1. A.class_weight='balanced'
    2. B.loss='hinge'
    3. C.penalty='l1'
    4. D.C=0.1
    Show answer & explanation

    Correct answer: Aclass_weight='balanced'

    • A. Setting class_weight='balanced' automatically adjusts weights inversely proportional to class frequencies, increasing the penalty for misclassifying minority class samples. This is the standard parameter for handling class imbalance in scikit-learn's LogisticRegression.
    • B. Incorrect. loss='hinge' is not a valid parameter for LogisticRegression; it is associated with SVM-style classifiers such as SGDClassifier or LinearSVC. It does not address class imbalance in logistic regression.
    • C. Incorrect. penalty='l1' controls the type of regularization (L1) applied to the model coefficients, encouraging sparsity. It does not change the relative cost of misclassifying one class versus another.
    • D. Incorrect. C is the inverse of regularization strength; lowering it increases regularization and raising it decreases regularization. It does not specifically penalize minority class errors more.

    Subdomain 1.2: Loss functions and splitting criteria

    2.You are training a HistGradientBoostingClassifier on a multi-class problem and observe overfitting. Which technique is directly available in the estimator to help prevent overfitting?

    1. A.Enable early stopping with a validation set.
    2. B.Increase the max_depth parameter further.
    3. C.Change the loss to 'categorical_crossentropy'.
    4. D.Reduce the learning_rate significantly.
    Show answer & explanation

    Correct answer: AEnable early stopping with a validation set.

    • A. Correct. HistGradientBoostingClassifier supports early stopping via the `early_stopping` parameter set to True and providing a validation set (e.g., using `validation_fraction`). This monitors validation performance and stops training when improvement stalls, directly reducing overfitting.
    • B. Incorrect. Increasing max_depth makes trees more complex, which typically increases overfitting. To prevent overfitting, you would reduce max_depth or use other regularization, not increase it.
    • C. Incorrect. HistGradientBoostingClassifier does not support 'categorical_crossentropy'; it uses 'log_loss' (cross-entropy) for multi-class. Changing to an unsupported loss is not a valid overfitting-control technique.
    • D. Incorrect. Decreasing learning_rate can sometimes improve generalization, but it is not the most direct built-in overfitting control. Early stopping is a more explicit mechanism, as the estimator does not automatically adjust learning_rate for overfitting prevention.

    Subdomain 1.3: Feature selection methods

    3.Which of the following are feature selection methods?(Select 3)

    1. A.('var', VarianceThreshold())
    2. B.('select', SelectKBest(f_classif, k=10))
    3. C.('select', SelectPercentile(f_classif, percentile=10))
    4. D.('rf', RandomForestClassifier())
    5. E.('feature_union', FeatureUnion(...))
    6. F.('pca', PCA())
    Show answer & explanation

    Correct answers: A, B, C('var', VarianceThreshold()); ('select', SelectKBest(f_classif, k=10)); ('select', SelectPercentile(f_classif, percentile=10))

    • A. Correct. VarianceThreshold is a simple unsupervised feature selection method that removes low-variance features.
    • B. Correct. SelectKBest with f_classif is a supervised univariate feature selection method that selects the top k features based on ANOVA F-scores.
    • C. Correct. SelectPercentile with f_classif is a supervised univariate feature selection method that selects a percentile of features based on F-scores.
    • D. Incorrect. RandomForestClassifier is a predictive model, not a feature selection method. It can provide feature importances for use with SelectFromModel.
    • E. Incorrect. FeatureUnion concatenates outputs of multiple transformers; it is not a feature selection method.
    • F. Incorrect. PCA is a dimensionality reduction technique that creates new components, not a feature selection method.

    Subdomain 1.1: Supervised and unsupervised learning, model families

    4.Which of the following metrics is most appropriate for evaluating probabilistic calibration?

    1. A.Accuracy
    2. B.AUC-ROC
    3. C.Average precision
    4. D.F1 score
    5. E.Log loss
    6. F.Brier score
    Show answer & explanation

    Correct answer: FBrier score

    • A. Incorrect. Accuracy does not measure calibration; it simply counts correct predictions and depends on a decision threshold, ignoring the quality of predicted probabilities.
    • B. Incorrect. AUC-ROC evaluates the ranking ability of a classifier across thresholds and is robust to class imbalance, but it does not assess calibration. A model with perfect ranking can still have poorly calibrated probabilities.
    • C. Incorrect. Average precision summarizes the precision-recall curve, focusing on the positive class ranking. It is useful for imbalanced data but does not measure probability calibration.
    • D. Incorrect. F1 score combines precision and recall at a specific threshold, balancing false positives and false negatives. It does not evaluate the quality of predicted probabilities or calibration.
    • E. Incorrect. Log loss (cross-entropy) is a proper scoring rule that penalizes confident wrong predictions, but it conflates calibration and refinement. It is not a pure calibration metric.
    • F. Correct. Brier score measures the mean squared difference between predicted probabilities and actual outcomes, directly assessing probabilistic calibration. It can be decomposed into calibration and refinement components.

    Subdomain 1.4: Calibration vs. ranking power differentiation

    5.After training a model, a data scientist divides predictions into bins and calculates the weighted average absolute difference between the average confidence and accuracy. What metric does this process compute?

    1. A.AUC
    2. B.ECE
    3. C.Brier score
    4. D.Log loss
    Show answer & explanation

    Correct answer: BECE

    • A. Incorrect. AUC (Area Under the ROC Curve) measures the ranking power of a model by evaluating how well it separates positive and negative classes across thresholds. It does not compare predicted confidence to observed accuracy in bins, and thus does not assess calibration directly.
    • B. Correct. Expected Calibration Error (ECE) is computed by partitioning predictions into bins, computing the average predicted confidence and the actual accuracy within each bin, and then taking the weighted average of the absolute differences between them. This directly quantifies calibration quality.
    • C. Incorrect. The Brier score measures the mean squared difference between predicted probabilities and actual binary outcomes. Although it reflects both calibration and refinement, it does not involve binning predictions or computing absolute differences between average confidence and accuracy.
    • D. Incorrect. Log loss (logarithmic loss) calculates the negative log-likelihood of the predicted probabilities for the true labels. It penalizes overconfident incorrect predictions but does not rely on binning or weighted absolute differences between confidence and accuracy.

    Subdomain 1.4: Calibration vs. ranking power differentiation

    6.A developer wants to calibrate a pre-trained classifier using CalibratedClassifierCV with cv='prefit'. What does this setting do?

    1. A.It cross-validates to train the base estimator and calibrator on multiple folds.
    2. B.It assumes the base estimator is already fitted, using the data for calibration.
    3. C.It throws an error because 'prefit' is not a valid cross-validation option.
    4. D.It fits the calibrator on a separate validation set not used for training.
    Show answer & explanation

    Correct answer: BIt assumes the base estimator is already fitted, using the data for calibration.

    • A. Incorrect. This describes the standard cross-validation calibration workflow, where the estimator is trained and calibrated across folds. With cv='prefit', the base estimator is not retrained inside CalibratedClassifierCV; it assumes the base estimator is already fitted.
    • B. Correct. When cv='prefit', CalibratedClassifierCV assumes the base estimator is already fitted and uses the provided data solely for calibration, without refitting the base model. This is useful for calibrating a pre-trained model efficiently.
    • C. Incorrect. 'prefit' is a valid setting for CalibratedClassifierCV. It does not raise an error; it changes the behavior to assume the estimator is already trained, skipping the cross-validation fitting step.
    • D. Incorrect. While calibration ideally requires data separate from training data, cv='prefit' does not itself create or enforce a separate validation split. The user must provide appropriate calibration data, and the calibrator is fitted directly on that input data.

    Domain 2: Model Building and Evaluation

    Subdomain 2.3: Calibration plotting (reliability diagrams)

    7.You plot the reliability diagram of your binary classifier and observe a curve that lies above the diagonal for predicted probabilities less than 0.5 and below the diagonal for probabilities greater than 0.5. What does this indicate about your model?

    1. A.A perfectly calibrated model has its reliability curve exactly on the diagonal line.
    2. B.An underconfident model produces probability estimates that are too close to 0.5.
    3. C.An overconfident model produces probability estimates that are too extreme.
    4. D.A model with poor discrimination but good calibration ranks classes poorly but probabilities are accurate.
    Show answer & explanation

    Correct answer: CAn overconfident model produces probability estimates that are too extreme.

    • A. Incorrect. A perfectly calibrated model would have its reliability curve lie exactly on the diagonal across all probability ranges. The described curve deviates systematically from the diagonal, indicating miscalibration.
    • B. Incorrect. Underconfidence would produce the opposite pattern: the curve would be below the diagonal for low probabilities and above for high probabilities, because estimated probabilities are too close to 0.5. The described pattern is the reverse.
    • C. Correct. Being above the diagonal at low predicted probabilities means the true fraction of positives is higher than predicted, and being below the diagonal at high probabilities means the true fraction is lower. This indicates the model is overconfident, assigning probabilities too extreme (too close to 0 or 1).
    • D. Incorrect. The reliability diagram assesses calibration, not discrimination. The described curve clearly indicates miscalibration, so the model does not have good calibration. Poor discrimination may coexist, but the curve does not speak to discrimination.

    Subdomain 2.3: Calibration plotting (reliability diagrams)

    8.You use histogram binning to calibrate a model. With 5 bins, the calibration curve is smooth but deviates from the diagonal in some regions. You increase to 20 bins and find the curve follows the diagonal more closely but with high variability. What trade-off does this illustrate?

    1. A.The trade-off between precision and recall.
    2. B.The bias-variance trade-off in calibration.
    3. C.The trade-off between training and inference time.
    4. D.The linear vs non-linear calibration trade-off.
    Show answer & explanation

    Correct answer: BThe bias-variance trade-off in calibration.

    • A. Precision and recall measure classification performance at a specific threshold, not the behavior of calibration curves under different bin counts. The trade-off illustrated is about how binning granularity affects the estimated calibration, not about decision-threshold trade-offs.
    • B. Increasing the number of bins reduces bias (the curve fits the diagonal more closely) but increases variance (higher variability in the estimated probabilities). This is the classic bias-variance trade-off applied to calibration estimation: fewer bins yield a smoother but potentially underfit curve, while more bins yield a more accurate but noisy curve.
    • C. Training and inference time are computational performance considerations, not the trade-off observed in calibration curves. While more bins might slightly increase computation, the question focuses on the stability and fidelity of the calibration curve, not runtime.
    • D. Histogram binning does not directly correspond to a choice between linear and non-linear calibration methods. The observed effect of bin count on curve smoothness and variability is better described by the bias-variance trade-off, not the form of the calibration function.

    Subdomain 2.1: Custom estimators following the sklearn API

    9.Which of the following are correct practices when building a custom clustering estimator in scikit-learn?(Select 2)

    1. A.Inherit from `ClusterMixin` for default `fit_predict`.
    2. B.Implement `fit` to return cluster labels for training data.
    3. C.Implement a `predict` method for labeling new data.
    4. D.Store cluster centers in the `cluster_centers_` attribute.
    5. E.Use `check_estimator` to verify API compliance.
    Show answer & explanation

    Correct answers: A, EInherit from `ClusterMixin` for default `fit_predict`.; Use `check_estimator` to verify API compliance.

    • A. Correct. Inheriting from `ClusterMixin` provides a default `fit_predict` implementation and signals to scikit-learn that the estimator is a clusterer, which enables interoperability with utilities like `check_estimator` and meta-estimators.
    • B. Incorrect. In scikit-learn, the `fit` method should return `self` to allow method chaining. Cluster labels are stored as an attribute (e.g., `labels_`) after fitting, not returned directly.
    • C. Incorrect. A `predict` method is optional for clustering estimators; many algorithms (e.g., DBSCAN, AgglomerativeClustering) only support `fit` and `fit_predict`. It is not a requirement of the sklearn API.
    • D. Incorrect. The `cluster_centers_` attribute is only appropriate for algorithms that compute centroids (e.g., KMeans). It is not a general requirement for all clustering estimators.
    • E. Correct. `check_estimator` is the standard tool for validating that a custom estimator complies with scikit-learn's API and conventions, including method signatures, attribute naming, and cloning behavior.

    Subdomain 2.2: Metadata routing

    10.What is the primary purpose of metadata routing in scikit-learn?

    1. A.To optimize hyperparameter tuning by sharing metadata across cross-validation folds.
    2. B.To prevent shape mismatches when concatenating outputs from multiple transformers in a pipeline.
    3. C.To route metadata like `sample_weight` to specific estimators and methods in a composite estimator.
    4. D.To reduce memory consumption by avoiding data duplication across multiple pipeline steps.
    Show answer & explanation

    Correct answer: CTo route metadata like `sample_weight` to specific estimators and methods in a composite estimator.

    • A. Incorrect. Metadata routing is not used for hyperparameter tuning optimization or sharing information across cross-validation folds. Its purpose is to control how extra metadata is passed to the right methods in a composed estimator.
    • B. Incorrect. Preventing shape mismatches when concatenating transformer outputs is handled by feature union or pipeline output management, not metadata routing. Metadata routing concerns auxiliary arguments such as sample weights, groups, or validation data, not feature dimensions.
    • C. Correct. Metadata routing ensures that metadata (e.g., sample_weight, target, or custom metadata) is correctly passed to the appropriate estimators and methods in a composite estimator or pipeline. It allows estimators to explicitly declare which extra inputs they consume.
    • D. Incorrect. Metadata routing does not aim to reduce memory usage by deduplicating data across pipeline steps. It is an API mechanism for requesting, accepting, and forwarding metadata arguments safely through estimator hierarchies, not memory optimization.

    Subdomain 2.2: Metadata routing

    11.Which statement about metadata routing in scikit-learn is correct?

    1. A.Metadata routing must be explicitly enabled via `sklearn.set_config(enable_metadata_routing=True)` before using it.
    2. B.Metadata routing is enabled by default in recent scikit-learn versions, so no global configuration change is needed.
    3. C.Metadata routing only applies to cross-validation routines and is not available for pipelines.
    4. D.When enabled, metadata routing automatically sends parameters like `sample_weight` to every step without user requests.
    Show answer & explanation

    Correct answer: AMetadata routing must be explicitly enabled via `sklearn.set_config(enable_metadata_routing=True)` before using it.

    • A. Correct. Metadata routing is not active by default in scikit-learn, even in recent versions. Users must explicitly enable it using `sklearn.set_config(enable_metadata_routing=True)` before it can be used with estimators and meta-estimators.
    • B. Incorrect. Metadata routing is not enabled by default; users must opt in via the global configuration setting. The statement is false.
    • C. Incorrect. Metadata routing is available for pipelines, transformers, and other meta-estimators, not just cross-validation routines. It is designed for the entire scikit-learn ecosystem.
    • D. Incorrect. Enabling metadata routing does not automatically forward parameters like `sample_weight` to every step. Each estimator must explicitly declare which metadata it requests, and only those are routed.

    Subdomain 2.4: Post-calibration techniques: isotonic, Platt scaling

    12.Which of the following classifiers is most likely to produce poorly calibrated probability estimates without additional calibration?

    1. A.Logistic regression with default L2 regularization.
    2. B.Gaussian Naive Bayes under naive independence assumption
    3. C.Random Forest with 500 estimators on 10,000 samples
    4. D.Linear SVM with Platt scaling enabled via probability=True
    Show answer & explanation

    Correct answer: BGaussian Naive Bayes under naive independence assumption

    • A. Incorrect. Logistic regression directly models class probabilities and typically yields well-calibrated estimates, even with default L2 regularization. It is one of the better-calibrated classifiers.
    • B. Correct. Gaussian Naive Bayes is often poorly calibrated because its strong conditional independence assumption is frequently violated in real data, leading to overconfident (extreme) probability estimates. Post-calibration techniques like isotonic regression or Platt scaling are often beneficial.
    • C. Incorrect. While random forests can be miscalibrated in some settings, with many trees (e.g., 500) and sufficient data (e.g., 10,000 samples), they often provide reasonably stable probability estimates. They are not as consistently poorly calibrated as Gaussian Naive Bayes.
    • D. Incorrect. Setting probability=True for a linear SVM enables Platt scaling, which explicitly calibrates the decision scores into probability estimates. Therefore, the classifier is already calibrated.

    Subdomain 2.4: Post-calibration techniques: isotonic, Platt scaling

    13.Underlying scikit-learn's CalibratedClassifierCV with method='sigmoid', what type of model is actually fitted for calibration?

    1. A.A linear regression model on log-odds of predicted probabilities.
    2. B.A logistic regression model on raw outputs of the base estimator.
    3. C.An isotonic regression model fitted with a sigmoid kernel.
    4. D.A support vector machine with a sigmoid kernel function.
    Show answer & explanation

    Correct answer: BA logistic regression model on raw outputs of the base estimator.

    • A. Incorrect. Platt scaling (sigmoid method) does not fit a linear regression on log-odds. Instead, it learns a logistic regression (sigmoid) mapping from the base estimator's outputs to calibrated probabilities.
    • B. Correct. With method='sigmoid', CalibratedClassifierCV uses Platt scaling, which fits a logistic regression model on the base estimator's raw outputs (decision function or predicted probabilities) to produce calibrated probabilities.
    • C. Incorrect. Isotonic regression is used with method='isotonic', not 'sigmoid'. The sigmoid method employs a parametric logistic regression, not a non-parametric isotonic regression with any kernel.
    • D. Incorrect. A support vector machine with a sigmoid kernel is unrelated to calibration. The calibration step in CalibratedClassifierCV fits a separate sigmoid mapping, not an SVM.

    Domain 3: Interpretation and communication

    Subdomain 3.2: Permutation importance

    14.When `permutation_importance` is called with a single metric, what does the returned `Bunch` object contain?

    1. A.`importances_mean`, `importances_std`, and `importances` (the raw scores for each repeat).
    2. B.`feature_names`, `importance_scores`, and `p_values`.
    3. C.`mean_decrease_accuracy`, `mean_decrease_gini`, and `feature_importances_`.
    4. D.`train_importances`, `test_importances`, and `cv_importances`.
    Show answer & explanation

    Correct answer: A`importances_mean`, `importances_std`, and `importances` (the raw scores for each repeat).

    • A. Correct. According to scikit-learn documentation, the `Bunch` object returned by `permutation_importance` contains `importances_mean` (the mean of the importance scores), `importances_std` (the standard deviation across repeats), and `importances` (the raw scores for each individual shuffle/repeat).
    • B. Incorrect. The standard `Bunch` output for `permutation_importance` does not include `feature_names`, `importance_scores`, or `p_values`. Feature names are typically maintained via the input X (e.g., if it is a pandas DataFrame).
    • C. Incorrect. These terms are more closely associated with impurity-based feature importance found in tree-based estimators (like Random Forests). `feature_importances_` is an attribute of the model, not a return value of this inspection utility.
    • D. Incorrect. The function returns summary statistics and raw importances for the specific dataset (X, y) provided. It does not internally handle or return separate buckets for train, test, or cross-validation importance.

    Subdomain 3.2: Permutation importance

    15.You have a text classification pipeline: `Pipeline([('tfidf', TfidfVectorizer()), ('clf', LogisticRegression())])`. You want to find the permutation importance of the original text column versus a numerical metadata column. Which of the following statements are true regarding this process?(Select 2)

    1. A.Passing the entire pipeline to `permutation_importance` will permute the raw text strings before TF-IDF vectorization.
    2. B.Passing the entire pipeline will permute the individual TF-IDF tokens (words) independently.
    3. C.Permuting the raw text column evaluates the importance of the entire text feature as a whole, rather than individual words.
    4. D.`permutation_importance` cannot handle string data, so you must pass the output of the `TfidfVectorizer` instead.
    5. E.You must use `n_jobs=1` when permuting text data to avoid memory corruption.
    Show answer & explanation

    Correct answers: A, CPassing the entire pipeline to `permutation_importance` will permute the raw text strings before TF-IDF vectorization.; Permuting the raw text column evaluates the importance of the entire text feature as a whole, rather than individual words.

    • A. Correct. `permutation_importance` operates by shuffling the columns of the input data `X` provided to the function. Since the pipeline starts with a `TfidfVectorizer` that accepts raw strings, the permutation happens on these strings before they are transformed into a numerical representation.
    • B. Incorrect. Shuffling occurs on the input features passed to the `permutation_importance` function. Because the tokens (words) are generated internally by the vectorizer within the pipeline, they are not seen as independent features by the permutation function. To permute individual tokens, one would need to pass the pre-transformed sparse matrix to the classifier directly.
    • C. Correct. By shuffling the entire string within the text column, the relationship between that text field and the target is broken. This allows the user to evaluate the cumulative predictive value of the text field as a single feature relative to other columns like metadata.
    • D. Incorrect. `permutation_importance` is agnostic to data types as long as the provided estimator (in this case, the pipeline) can handle them. Since the pipeline includes a `TfidfVectorizer`, it is perfectly capable of processing string data during the importance calculation.
    • E. Incorrect. There is no specific requirement to use `n_jobs=1` for text data. While text processing and large sparse matrices can be memory-intensive, `n_jobs` is a standard parameter for parallelization and does not cause inherent memory corruption.

    Domain 3: Interpretation and Communication

    Subdomain 3.1: Partial dependence plots

    16.When using `PartialDependenceDisplay.from_estimator`, what does the `grid_resolution` parameter control?

    1. A.The count of grid points per feature for evaluating partial dependence.
    2. B.The number of decimal places to round the feature values in the plot.
    3. C.The size of the dataset used for computing partial dependence.
    4. D.The dots per inch (dpi) resolution of the generated plot image.
    Show answer & explanation

    Correct answer: AThe count of grid points per feature for evaluating partial dependence.

    • A. Correct. The `grid_resolution` parameter specifies the number of grid points per feature used to evaluate the partial dependence. A larger value makes the grid finer and the plot smoother, at the cost of more computation.
    • B. Incorrect. `grid_resolution` does not control any rounding of feature values or plotting precision. It only affects the number of evaluation points used for the partial dependence calculation.
    • C. Incorrect. The size of the dataset used for partial dependence is not controlled by `grid_resolution`. The dataset size is determined by the input data, and any sampling is handled by other parameters.
    • D. Incorrect. DPI is a figure rendering property and is unrelated to `grid_resolution`. The parameter concerns the computational grid for feature values, not image output quality.

    Subdomain 3.3: Pipeline diagnosis and feature selection pitfalls

    17.Which feature is most likely to be removed by a variance-based feature selection method?

    1. A.A feature with 1% positives (variance ≈ 0.0099).
    2. B.A feature with 10% positives (variance ≈ 0.09).
    3. C.A feature with 50% positives (variance = 0.25).
    4. D.A feature with a constant value (variance = 0).
    5. E.A feature with 5% positives (variance ≈ 0.0475).
    Show answer & explanation

    Correct answer: DA feature with a constant value (variance = 0).

    • A. Incorrect. Variance ≈ 0.0099 is below the default threshold of 0.01, so it would be dropped, but the constant feature (variance=0) is even more likely to be removed.
    • B. Incorrect. Variance ≈ 0.09 is well above any common threshold (0.01 or 0.05), so it would be kept.
    • C. Incorrect. Variance = 0.25 is the maximum for a Bernoulli variable and far above thresholds, so it would be kept.
    • D. Correct. Variance = 0 is below any positive threshold, so it will always be removed by variance thresholding.
    • E. Incorrect. Variance ≈ 0.0475 is above 0.01 but below 0.05; it may be dropped depending on threshold, but not as certainly as the constant feature.

    Subdomain 3.4: Reading and explaining others’ code

    18.What does TfidfVectorizer(max_features=100) do when applied to a collection of text documents?

    1. A.It reduces the dimensionality from 5000 to 100, serving as sparse PCA.
    2. B.It transforms the text documents into TF-IDF feature vectors.
    3. C.It regularizes the logistic regression by compressing the feature space.
    4. D.It extracts and outputs interpretable topics from the text data.
    Show answer & explanation

    Correct answer: BIt transforms the text documents into TF-IDF feature vectors.

    • A. Incorrect. The code does not perform PCA or dimensionality reduction. TF-IDF produces weighted term features, not latent components like sparse PCA. Reducing from 5000 to 100 dimensions is not what TfidfVectorizer does.
    • B. Correct. TfidfVectorizer converts text documents into numerical TF-IDF feature vectors. With max_features=100, it limits the vocabulary to the top 100 terms. This is a standard preprocessing step for text classification.
    • C. Incorrect. TF-IDF does not regularize logistic regression or compress the feature space directly. Regularization is a property of the logistic regression model itself, not the vectorizer.
    • D. Incorrect. Extracting interpretable topics is done by topic models like LDA or NMF, not TF-IDF. TF-IDF highlights important words but does not generate topic summaries.

    Subdomain 3.4: Reading and explaining others’ code

    19.Which of the following strategies can improve the performance of a scikit-learn pipeline that uses FeatureUnion?

    1. A.Set `n_jobs=-1` in the transformers to enable parallel execution.
    2. B.Set the `memory` parameter in the pipeline to cache intermediate transformations.
    3. C.Replace `FeatureUnion` with a single custom transformer that performs all steps.
    4. D.Ensure that each transformer's `fit` method is lightweight or does minimal work.
    5. E.Use `make_union` instead of `FeatureUnion` for faster execution.
    6. F.Avoid using `Pipeline` for the union because it adds unnecessary overhead.
    Show answer & explanation

    Correct answer: BSet the `memory` parameter in the pipeline to cache intermediate transformations.

    • A. Incorrect. Setting `n_jobs=-1` is not a general approach for parallelizing transformers; it only works if the specific transformer supports it, and many do not. `FeatureUnion` itself has an `n_jobs` parameter, but that only parallelizes the transformers if they are n_jobs-aware.
    • B. Correct. The `memory` parameter caches intermediate transformation results, avoiding redundant computations when `fit` or `transform` is called multiple times, especially during cross-validation or grid search.
    • C. Incorrect. Replacing `FeatureUnion` with a single custom transformer would remove composability and modularity, and is not a recommended performance optimization.
    • D. Incorrect. While keeping `fit` light is good practice, it is not a specific technique for improving pipeline performance in this context; the primary optimization is caching via `memory`.
    • E. Incorrect. `make_union` is just a convenience wrapper for creating a `FeatureUnion` with default parameters; it does not change execution speed.
    • F. Incorrect. `Pipeline` is designed to be efficient and does not introduce unnecessary overhead; avoiding it would lead to less maintainable code and potential data leakage.

    Domain 3: Interpretation of results & communication

    Subdomain 3.1: Partial dependence plots, non-linear impact on the target

    20.Which of the following statements accurately describe the differences between impurity-based feature importance (e.g., in `RandomForestClassifier`) and permutation importance in scikit-learn?(Select 2)

    1. A.Impurity-based importance is computed on the training set, while permutation importance can be computed on a held-out test set.
    2. B.Impurity-based importance tends to inflate the importance of high-cardinality features, whereas permutation importance mitigates this bias when evaluated on unseen data.
    3. C.Permutation importance is significantly faster to compute than impurity-based importance for large tree ensembles.
    4. D.Impurity-based importance can only be used for classification tasks, while permutation importance is strictly for regression.
    5. E.Permutation importance requires the model to be retrained for every feature permuted, unlike impurity-based importance.
    Show answer & explanation

    Correct answers: A, BImpurity-based importance is computed on the training set, while permutation importance can be computed on a held-out test set.; Impurity-based importance tends to inflate the importance of high-cardinality features, whereas permutation importance mitigates this bias when evaluated on unseen data.

    • A. Correct. Impurity-based importance (MDI) is derived directly from the tree statistics gathered during the training process. Permutation importance is a model-agnostic post-hoc method that can be computed on any dataset, such as a held-out test set, to measure how much the model performance drops when a feature's values are shuffled.
    • B. Correct. Impurity-based importance is notoriously biased toward high-cardinality features because these features offer more potential split points, allowing the model to reduce impurity more easily on the training set. Permutation importance, particularly when evaluated on a validation or test set, provides a more unbiased estimate of a feature's actual predictive power.
    • C. Incorrect. Permutation importance is computationally much more expensive than impurity-based importance. While impurity importance is available immediately after training, permutation importance requires K * N passes of model predictions (where K is the number of features and N is the number of repeats).
    • D. Incorrect. Both methods are versatile and support both classification and regression tasks. Impurity measures change from Gini/Entropy to Mean Squared Error/Variance depending on the task, but the concept remains the same.
    • E. Incorrect. Permutation importance does not involve retraining the model. It uses the already-fitted model to make predictions on data where a specific feature's column has been randomly shuffled. Retraining for each feature would describe 'Leave-One-Feature-Out' (LOFO) importance, not permutation importance.

    Subdomain 3.1: Partial dependence plots, non-linear impact on the target

    21.You run `permutation_importance` on a test set and notice that one of the features, `is_newsletter_subscriber`, has a negative mean importance score. What is the most appropriate interpretation of this result?

    1. A.The feature is highly predictive, but its relationship with the target is inversely proportional.
    2. B.The model's predictions on the test set actually improved (or the error decreased) when this feature was randomly shuffled, suggesting the feature is uninformative or the model is overfitting to it.
    3. C.The feature is perfectly collinear with another feature in the dataset.
    4. D.The `random_state` used for shuffling caused an integer overflow in the scoring metric.
    Show answer & explanation

    Correct answer: BThe model's predictions on the test set actually improved (or the error decreased) when this feature was randomly shuffled, suggesting the feature is uninformative or the model is overfitting to it.

    • A. Permutation importance measures the decrease in model performance when a feature's values are shuffled. A feature that has an inversely proportional relationship with the target (like a negative coefficient in a linear model) is still predictive; shuffling it would decrease model performance, resulting in a positive importance score.
    • B. Correct. Permutation importance is calculated as (baseline_score - permuted_score). A negative value means the model performed better on the test set after the feature was shuffled (permuted_score > baseline_score). This suggests the feature provides no useful signal or, more likely, that the model has overfit to noise or spurious correlations in that feature that do not generalize.
    • C. While perfect collinearity can split importance between features and make individual importance scores less reliable or lower, it does not specifically cause a negative importance score. Negative scores are a result of the model's performance increasing upon the removal of the feature's signal.
    • D. A negative importance score is a mathematically valid and expected outcome in permutation importance when a feature is harmful to the model's generalization; it is not indicative of a technical bug like integer overflow or a random state error.

    Subdomain 3.3: Diagnosing methodology, given a plot, name the failure

    22.In a binary classification task, you observe that your ROC curve falls consistently below the diagonal line, resulting in an Area Under the Curve (AUC) of less than 0.5. What does this most likely indicate?

    1. A.The model is perfectly random and has no predictive power.
    2. B.The model's predictions are systematically inverted (predicting the negative class when it should predict positive).
    3. C.The model is heavily overfitting the training data.
    4. D.The dataset is highly imbalanced, causing the ROC curve to distort.
    Show answer & explanation

    Correct answer: BThe model's predictions are systematically inverted (predicting the negative class when it should predict positive).

    • A. Incorrect. A perfectly random model would produce an ROC curve close to the diagonal line of no-discrimination with an AUC ≈ 0.5. Falling below the diagonal indicates a systematic relationship, just not the intended one.
    • B. Correct. If the model's predictions are systematically inverted (e.g., swapping class labels or reversing the decision rule), the ROC curve will lie below the diagonal. In such cases, flipping the prediction labels or probabilities would yield an AUC > 0.5.
    • C. Incorrect. Heavy overfitting typically yields high performance on training data and poor performance on held-out data, but it does not by itself produce systematically inverted predictions. Overfitting usually increases variance rather than causing a consistent negative correlation with true labels.
    • D. Incorrect. While class imbalance affects many metrics like precision and recall, the ROC curve and AUC are largely insensitive to class distribution. Imbalance alone does not explain a systematically inverted ROC curve.

    Domain 4: Data preprocessing

    Subdomain 4.2: Plot interpretation for model selection

    23.You are interpreting a complex model using scikit-learn's inspection module. The Partial Dependence Plot (PDP) for 'Feature_A' shows a completely flat horizontal line. However, the Individual Conditional Expectation (ICE) plot for 'Feature_A' shows many lines with strong positive slopes and many lines with strong negative slopes. What should you conclude?

    1. A.Feature_A has absolutely no effect on the target variable.
    2. B.Feature_A has a strong, independent linear effect on the target variable.
    3. C.Feature_A has strong interaction effects with other features, causing its marginal effect to average out to zero.
    4. D.The model is severely underfitting the training data.
    Show answer & explanation

    Correct answer: CFeature_A has strong interaction effects with other features, causing its marginal effect to average out to zero.

    • A. Incorrect. While a flat PDP line suggests that the marginal effect of Feature_A averages out to zero, the ICE lines clearly show that Feature_A affects predictions conditionally. The lack of a marginal trend does not mean the feature is unimportant; it simply means its influence is not consistent across the dataset.
    • B. Incorrect. If Feature_A had a strong, independent linear effect, both the ICE lines and the PDP would exhibit consistent, similar slopes. Heterogeneous slopes in ICE indicate that the effect of the feature is not independent of other variables.
    • C. Correct. A flat PDP combined with ICE lines that show both strong positive and negative slopes indicates that the effect of Feature_A is highly dependent on the values of other features (heterogeneous effects). These interactions cause the conditional effects to cancel each other out when averaged across the dataset, resulting in a flat marginal plot.
    • D. Incorrect. The presence of varied and strong slopes in ICE lines indicates the model is capturing complex relationships and interactions. Underfitting would more likely result in simplified, flat, or uniform ICE lines across all instances due to the model's inability to capture complexity.

    Subdomain 4.1: Loading and joining parquet datasets

    24.You are training an `SGDClassifier` on a 100GB Parquet dataset on a machine with only 32GB of RAM. Which combination of techniques will allow you to successfully train the model out-of-core?(Select 2)

    1. A.Use `pyarrow.parquet.ParquetFile.iter_batches()` to yield manageable chunks of data.
    2. B.Load the entire dataset into a pandas DataFrame using `engine='fastparquet'`.
    3. C.Call the `partial_fit` method on the `SGDClassifier` for each loaded chunk.
    4. D.Use `GridSearchCV` directly on the Parquet file path to automatically handle chunking.
    5. E.Increase the system swap space to 100GB and use the standard `fit()` method.
    Show answer & explanation

    Correct answers: A, CUse `pyarrow.parquet.ParquetFile.iter_batches()` to yield manageable chunks of data.; Call the `partial_fit` method on the `SGDClassifier` for each loaded chunk.

    • A. Correct. `pyarrow.parquet.ParquetFile.iter_batches()` allows you to read Parquet files in manageable row batches. This streaming approach avoids loading the entire 100GB dataset into memory, making it the standard way to handle large-scale Parquet data for out-of-core workflows.
    • B. Incorrect. Loading a 100GB dataset into a 32GB RAM machine is physically impossible without compression or chunking. The specific engine used (e.g., 'fastparquet') does not reduce the memory footprint of the materialized pandas DataFrame.
    • C. Correct. The `partial_fit` method is scikit-learn's incremental learning API designed for out-of-core learning. It updates model parameters chunk-by-chunk. Note that for the first call to `partial_fit`, you must provide the list of all possible classes in the `classes` parameter.
    • D. Incorrect. `GridSearchCV` expects data to be available in memory and does not natively support file paths or automatic chunking of Parquet files. It cannot handle out-of-core datasets without custom wrappers or integration with tools like Dask.
    • E. Incorrect. Relying on system swap space for a dataset significantly larger than RAM causes 'disk thrashing' and severe performance degradation. Furthermore, the standard `fit()` method expects all input data to be present in a single contiguous block (like a NumPy array or DataFrame), which would still exceed memory limits.

    Subdomain 4.3: Multi-source data combining

    25.You are building a custom transformer to extract 'day_of_week' and 'is_weekend' derived attributes from a datetime column. To ensure this custom class is fully compatible with scikit-learn's Pipeline and GridSearchCV (including automatic get_params and set_params methods), which classes must it inherit from?

    1. A.BaseEstimator and TransformerMixin
    2. B.TransformerMixin and Pipeline
    3. C.BaseEstimator and RegressorMixin
    4. D.FeatureUnion and BaseEstimator
    Show answer & explanation

    Correct answer: ABaseEstimator and TransformerMixin

    • A. Correct. Inheriting from BaseEstimator provides the automatic get_params and set_params implementation required by GridSearchCV for hyperparameter tuning. TransformerMixin supplies the fit_transform convenience method and signals that the class implements the transformer interface, making it fully compatible with scikit-learn Pipelines.
    • B. Incorrect. While TransformerMixin is useful for transformers, Pipeline is a composite estimator designed to chain multiple steps together. Inheriting from Pipeline is a design error for a single transformer and does not provide the parameter handling logic found in BaseEstimator.
    • C. Incorrect. RegressorMixin is intended for regression estimators (predictors) and provides a specific score method. It does not provide the transform or fit_transform methods required for a transformer, and it is inappropriate for a feature engineering task.
    • D. Incorrect. FeatureUnion is used to combine the outputs of multiple transformers by running them in parallel. It is a meta-estimator, not a base class intended for defining the internal logic of a standalone custom transformer.

    Subdomain 4.3: Multi-source data combining

    26.You want to derive a categorical attribute from a continuous variable by binning it. You require each bin to contain approximately the same number of samples. Which strategy should you configure in KBinsDiscretizer?

    1. A.strategy='uniform'
    2. B.strategy='kmeans'
    3. C.strategy='quantile'
    4. D.strategy='frequency'
    Show answer & explanation

    Correct answer: Cstrategy='quantile'

    • A. Incorrect. The 'uniform' strategy divides the feature's range into bins of equal width. Because it focuses on interval distance rather than sample density, bins will contain different numbers of samples depending on the data distribution.
    • B. Incorrect. The 'kmeans' strategy uses a 1D k-means clustering algorithm to define bins by minimizing the within-cluster variance. This produces bins that reflect natural clusters in the data but does not ensure that each bin has an equal sample count.
    • C. Correct. The 'quantile' strategy uses the quantiles of the dataset to define bin edges. This ensures that each bin contains approximately the same number of samples, effectively performing equal-frequency discretization.
    • D. Incorrect. 'frequency' is not a valid parameter value for the strategy argument in scikit-learn's KBinsDiscretizer. While the concept is referred to as equal-frequency binning, the implementation name is 'quantile'.

    Subdomain 4.4: Feature engineering including lagged features

    27.Which of the following parameters are available in scikit-learn's `SplineTransformer` to control the generation of B-spline features?(Select 3)

    1. A.`n_knots`
    2. B.`degree`
    3. C.`extrapolation`
    4. D.`interaction_only`
    5. E.`strategy`
    6. F.`add_indicator`
    Show answer & explanation

    Correct answers: A, B, C`n_knots`; `degree`; `extrapolation`

    • A. `n_knots` is a valid parameter in `SplineTransformer` that specifies the number of knots for the spline basis. It directly influences the number of generated features and the overall flexibility of the spline transformation.
    • B. `degree` is a fundamental parameter in `SplineTransformer` that determines the degree of the B-spline polynomial (e.g., cubic splines use `degree=3`). It affects the smoothness and complexity of the resulting basis functions.
    • C. `extrapolation` is a parameter in `SplineTransformer` that defines the strategy for handling values outside the range of the knots. Supported strategies include 'constant', 'linear', 'continue', 'periodic', or 'error'.
    • D. `interaction_only` is not a parameter of `SplineTransformer`. It is associated with `PolynomialFeatures`, where it determines whether only interaction terms (and not powers) should be generated.
    • E. `strategy` is a parameter used in `KBinsDiscretizer` to define how bin edges are calculated (e.g., 'uniform', 'quantile'). In `SplineTransformer`, the equivalent parameter for knot placement is named `knots`.
    • F. `add_indicator` is a parameter typically found in missing value imputers like `SimpleImputer` or `IterativeImputer`. It is not part of the `SplineTransformer` API.

    Domain 5: Model Selection and Validation

    Subdomain 5.1: Proper scoring rules for probabilistic outputs

    28.What does calibration measure?

    1. A.The model's ability to correctly order test instances by their predicted risk scores.
    2. B.The agreement between predicted probabilities and the actual observed frequencies of events.
    3. C.The extent to which predictions are concentrated near 0 or 1, indicating high confidence.
    4. D.The proportion of correct predictions when using a decision threshold of 0.5.
    Show answer & explanation

    Correct answer: BThe agreement between predicted probabilities and the actual observed frequencies of events.

    • A. Incorrect. This describes the model's discrimination or ranking ability (e.g., AUC), not calibration. Calibration evaluates the accuracy of predicted probabilities, not their ordering.
    • B. Correct. Calibration measures how closely predicted probabilities match observed outcome frequencies. For example, if a model predicts 0.7 for a group of samples, about 70% should actually be positive for the model to be well calibrated.
    • C. Incorrect. This reflects sharpness or overconfidence, not calibration. A model can produce extreme probabilities but still be poorly calibrated if those probabilities do not align with actual event rates.
    • D. Incorrect. This describes accuracy at a fixed threshold of 0.5, which depends on decision threshold selection. Calibration evaluates the reliability of probabilities across all thresholds, not just one.

    Subdomain 5.1: Proper scoring rules for probabilistic outputs

    29.Why might validation log loss increase during training?

    1. A.The network is overfitting and becoming increasingly overconfident on misclassified examples.
    2. B.The learning rate is set too high, which causes the validation loss to diverge due to unstable weight updates.
    3. C.The validation set likely includes some mislabeled data points, leading to a higher log loss.
    4. D.The log loss can become unstable when the network outputs probabilities very close to 0 or 1.
    Show answer & explanation

    Correct answer: AThe network is overfitting and becoming increasingly overconfident on misclassified examples.

    • A. Correct. When a model overfits, it becomes increasingly confident in its predictions on the training data. During validation, if it misclassifies examples with high confidence, the log loss heavily penalizes these confident wrong predictions, leading to a rising validation log loss as training progresses.
    • B. Incorrect. A high learning rate can cause unstable weight updates and divergence, but this typically manifests more directly in training loss. Validation log loss increasing is not a direct consequence of a high learning rate; the described behavior is better explained by overconfidence on misclassified examples.
    • C. Incorrect. Mislabeled validation examples can increase log loss, but they would cause a consistent elevation rather than a systematic increase during training. A rising validation log loss over epochs is more likely due to the model becoming overconfident on mistakes.
    • D. Incorrect. Although log loss can be numerically unstable with probabilities near 0 or 1, modern implementations clip probabilities to avoid infinite values. This does not explain a training-related increase in validation log loss, which is typically due to overconfidence on misclassified examples.

    Subdomain 5.2: Calibration-focused metrics in GridSearchCV

    30.In a fraud detection project, you need to select a model with well-calibrated probabilities while also ensuring high recall. You set up GridSearchCV with scoring={'recall': 'recall', 'calibration': 'neg_brier_score'}. To prioritize calibration, which refit setting should you use?

    1. A.refit='recall'
    2. B.refit='calibration'
    3. C.refit='accuracy'
    4. D.refit='neg_brier_score'
    Show answer & explanation

    Correct answer: Brefit='calibration'

    • A. Setting refit='recall' would select the model maximizing recall, not calibration. Since the goal is to prioritize calibration, this is not appropriate.
    • B. Correct. In multi-metric scoring, refit must be set to one of the scoring dictionary keys. The key 'calibration' corresponds to 'neg_brier_score' and selecting it will choose the model with the best calibration as measured by the Brier score.
    • C. The scoring dictionary does not include 'accuracy', so it is not a valid refit key. Moreover, accuracy does not directly measure calibration.
    • D. While 'neg_brier_score' is the underlying scorer, refit expects a dictionary key, not the scorer name. The correct key is 'calibration'.

    Subdomain 5.2: Calibration-focused metrics in GridSearchCV

    31.You have a pipeline with StandardScaler, PCA, and LogisticRegression. You plan to use GridSearchCV with scoring='neg_brier_score' to tune n_components and C. To guarantee well-calibrated probabilities, what should you add?

    1. A.Nothing, as logistic regression probabilities are inherently well-calibrated.
    2. B.A CalibratedClassifierCV with method='sigmoid' around the logistic regression.
    3. C.A RandomForestClassifier instead, to benefit from its built-in calibration.
    4. D.An additional PCA step to reduce overfitting and improve generalization.
    Show answer & explanation

    Correct answer: BA CalibratedClassifierCV with method='sigmoid' around the logistic regression.

    • A. Incorrect. Logistic regression probabilities are often reasonably calibrated but not guaranteed, especially with regularization, class imbalance, or model misspecification. Calibration is not inherent.
    • B. Correct. Wrapping the classifier in CalibratedClassifierCV with method='sigmoid' explicitly fits a calibration model on top of the base estimator's scores, ensuring well-calibrated probabilities when optimizing a calibration-sensitive metric like Brier score.
    • C. Incorrect. RandomForestClassifier does not have built-in calibration guarantees; its probabilities can be poorly calibrated and may still need calibration. The pipeline uses logistic regression, not random forest.
    • D. Incorrect. Adding another PCA step does not address probability calibration. PCA is for dimensionality reduction and may affect predictive performance, but it is not a calibration method.

    Subdomain 5.3: Custom scorers with make_scorer

    32.How should you configure `make_scorer` to use probability estimates in a custom scoring function?

    1. A.Specify `needs_proba=True` in `make_scorer` and confirm the model exposes `predict_proba`.
    2. B.Activate the `needs_threshold` flag to handle prediction of probability estimates.
    3. C.Call `predict_proba` directly within your metric function instead of relying on the scorer.
    4. D.Set the `predict_method` parameter to `'probability'` in the `make_scorer` call.
    Show answer & explanation

    Correct answer: ASpecify `needs_proba=True` in `make_scorer` and confirm the model exposes `predict_proba`.

    • A. Correct. Setting `needs_proba=True` in `make_scorer` instructs the scorer to use `predict_proba` instead of `predict`. The estimator must expose `predict_proba` for this to work. This is the standard way to build a scorer for metrics that consume class probabilities.
    • B. Incorrect. The `needs_threshold=True` flag is used for scorers that require a continuous decision score (e.g., from `decision_function`), not specifically for probability estimates. For probability-based metrics, `needs_proba=True` is the appropriate parameter.
    • C. Incorrect. While you can call `predict_proba` directly inside a custom metric function, that bypasses the `make_scorer` framework. The question asks for a valid approach using `make_scorer`, not a manual workaround.
    • D. Incorrect. `make_scorer` does not have a `predict_method` parameter. The relevant parameters for controlling predictions are `needs_proba` and `needs_threshold`. Setting a non-existent parameter will raise an error.

    Domain 6: Model Deployment

    Subdomain 6.3: Trade-offs between formats

    33.When deploying a scikit-learn model in a non-Python environment, which model serialization format is most appropriate for interoperability?

    1. A.joblib (with optional compression)
    2. B.ONNX
    3. C.PMML
    4. D.JSON
    Show answer & explanation

    Correct answer: BONNX

    • A. Incorrect. joblib is natively supported by scikit-learn for model serialization, especially for models with large NumPy arrays. However, it is Python-specific and not designed for cross-language deployment, limiting its use in non-Python production environments.
    • B. Correct. ONNX is an interoperable model exchange format designed to enable deployment across different runtimes and languages. With the skl2onnx library, scikit-learn models can be converted to ONNX, making it the recommended choice for moving models out of Python into non-Python production environments.
    • C. Incorrect. PMML is also a model interchange format intended for portability, but it is less commonly used in the scikit-learn ecosystem compared to ONNX. While third-party libraries like jpmml-sklearn exist, ONNX has broader community support and tooling for modern deployments.
    • D. Incorrect. JSON is a general-purpose data interchange format, not designed for serializing trained scikit-learn models. It cannot reliably preserve complex estimator state and numerical objects, making it unsuitable for model deployment.

    Subdomain 6.2: Secure serialization with skops

    34.What is the primary security advantage of using skops over pickle for serializing scikit-learn models?

    1. A.skops compresses the model to a smaller file size
    2. B.skops prevents arbitrary code execution when loading
    3. C.skops encrypts the serialized data automatically
    4. D.skops adds digital signatures to the serialized output
    Show answer & explanation

    Correct answer: Bskops prevents arbitrary code execution when loading

    • A. Incorrect. While skops may offer compression, this is not its primary security advantage. Compression is a performance feature, not a security one. skops focuses on safer model persistence rather than storage optimization.
    • B. Correct. skops is designed to prevent arbitrary code execution, a major security risk associated with pickle, by using a safer, inspectable serialization format. This makes loading models safer because the content can be validated before being reconstructed.
    • C. Incorrect. skops does not automatically encrypt serialized data. Encryption is a separate security measure and is not the primary advantage provided by skops.
    • D. Incorrect. skops does not inherently add digital signatures to the serialized output. While signatures could be added in a broader security workflow, the core benefit of skops is safer deserialization, not signing.

    Subdomain 6.1: Serialization with joblib and pickle

    35.Which of the following strategies can effectively reduce the size of a serialized scikit-learn model containing a large NumPy array?

    1. A.Use higher compression to reduce file size when saving.
    2. B.Exclude the large NumPy array from the serialized model.
    3. C.Enable memory mapping via joblib's default memmap threshold.
    4. D.Load the model in a separate thread to reduce latency.
    Show answer & explanation

    Correct answer: AUse higher compression to reduce file size when saving.

    • A. Correct. Higher compression (e.g., compress=3 in joblib.dump) reduces the serialized file size, though it may increase serialization and deserialization time. This is a direct and effective strategy for reducing storage footprint.
    • B. Incorrect. Large NumPy arrays are typically part of the model's internal state and cannot be excluded without compromising the model's functionality. Serialization stores the entire object; removing required arrays would break the model.
    • C. Incorrect. Memory mapping (via mmap_mode in joblib.load) helps reduce memory usage during loading by allowing on-demand access from disk, but it does not reduce the on-disk size of the serialized file.
    • D. Incorrect. Loading the model in a separate thread addresses concurrency and latency during loading, but it does not affect the serialized file size or memory footprint of the stored model.

    Want the full experience?

    These are just samples. Practice the full Scikit-learn Expert Practitioner Certification question bank in quiz mode — free, no signup, with domain practice and exam simulation.