ML Basics Questions with Answers

7 practice questions on ML Basics (AI & Machine Learning) with answers and step-by-step solutions. Try 7 samples below, then practise all 7 free in the AptiNest app.

Sample questions

Question 1Easy

In machine learning, what are "features"?

  1. The predicted output values that the model produces for each example
  2. The input variables used to make a prediction
  3. The hyperparameters of the model
  4. The errors made on the test set

Answer: B. The input variables used to make a prediction

Explanation

Features (independent variables) are the measurable inputs, such as area and location for predicting house price. The value being predicted is the label or target.

Step-by-step solution

  1. A model maps inputs to an output.
  2. The measurable inputs (age, income, pixel values) are the features.
  3. The value being predicted is the target or label.

Why the other options are wrong

  • A. That describes predictions (outputs), not inputs.
  • C. Hyperparameters are settings chosen before training, not data columns.
  • D. Errors on the test set are used for evaluation, not as inputs.

Tip: Features = inputs (X); label/target = output (y).

Question 2Easy

Why is a dataset split into training and test sets?

  1. Because models cannot handle large datasets in one piece
  2. To make training faster by giving the model fewer examples to process
  3. To increase the number of features available
  4. To estimate how well the model generalises to unseen data

Answer: D. To estimate how well the model generalises to unseen data

Explanation

Evaluating on the same data used for training gives an over-optimistic estimate; a held-out test set simulates new data.

Step-by-step solution

  1. The model learns patterns from the training set.
  2. The test set is held back and never shown during training.
  3. Scoring on it estimates performance on new, unseen data.

Why the other options are wrong

  • A. Splitting is about honest evaluation, not memory limits.
  • B. Speed is not the purpose; fewer training rows usually hurts the model.
  • C. Splitting rows does not add any features.

Tip: Train to learn, test to judge.

Question 3Easy

Gradient descent updates model parameters by moving them:

  1. Towards zero regardless of the loss
  2. In the direction of the gradient of the loss
  3. In the direction opposite to the gradient of the loss
  4. To random values each iteration, keeping the change only if the loss goes down

Answer: C. In the direction opposite to the gradient of the loss

Explanation

The gradient points towards steepest increase; stepping against it (scaled by the learning rate) decreases the loss.

Step-by-step solution

  1. The gradient points in the direction where the loss increases fastest.
  2. To reduce the loss, step the opposite way.
  3. Update: w = w - learning_rate x gradient.

Why the other options are wrong

  • A. Updates depend on the loss gradient, not a pull towards zero.
  • B. Moving along the gradient increases the loss.
  • D. Random trial-and-error is not gradient descent.

Tip: Minus sign: w new = w - lr x gradient.

Question 4Medium

What is "data leakage" in machine learning?

  1. A model that consumes too much memory
  2. Using too few features, so the model cannot capture the true pattern in the data
  3. Losing rows while loading a CSV file
  4. Test or target information influencing training

Answer: D. Test or target information influencing training

Explanation

Example: scaling with statistics computed on the whole dataset before splitting, or a feature that is only known after the outcome. It inflates evaluation scores.

Step-by-step solution

  1. Leakage means information unavailable at prediction time sneaks into training.
  2. Examples: test rows used to fit a scaler, or a feature computed from the target.
  3. The model then looks great in evaluation but fails in real use.

Why the other options are wrong

  • A. Memory use is unrelated to leakage.
  • B. Too few features causes underfitting, not leakage.
  • C. Losing rows is a data-loading bug, not leakage.

Tip: Suspiciously high accuracy? Check for leakage first.

Question 5Medium

What is the role of a validation set?

  1. Replacing the test set entirely
  2. Training the final model weights
  3. Tuning hyperparameters without touching the test set
  4. Storing mislabelled examples so they can be corrected before final training

Answer: C. Tuning hyperparameters without touching the test set

Explanation

If the test set were used for tuning, it would leak into model selection and no longer give an unbiased final estimate.

Step-by-step solution

  1. Training data fits the model's weights.
  2. Validation data compares settings such as depth or learning rate.
  3. The test set is kept untouched for one final, unbiased check.

Why the other options are wrong

  • A. The test set is still needed for the final unbiased estimate.
  • B. Weights are learned on the training set.
  • D. The validation set is not a store for bad labels.

Tip: Train = learn weights, validation = tune, test = final report.

Question 6Medium

Which of the following is a hyperparameter rather than a learned parameter?

  1. The weights of a linear regression model
  2. The split thresholds learned by a decision tree
  3. The biases of a neural network
  4. The learning rate of gradient descent

Answer: D. The learning rate of gradient descent

Explanation

Hyperparameters are set before training (learning rate, tree depth, k in k-NN). Parameters are learned from data.

Step-by-step solution

  1. Learned parameters are found by the training algorithm from data.
  2. Hyperparameters are set by you before training starts.
  3. The learning rate is chosen beforehand and controls how training runs.

Why the other options are wrong

  • A. Weights are learned from data during training.
  • B. Split thresholds are chosen by the tree algorithm from data.
  • C. Biases are learned just like weights.

Tip: If training sets it, it is a parameter; if you set it, it is a hyperparameter.

Question 7Hard

Why should feature scaling (e.g. standardisation) be fitted on the training set only and then applied to the test set?

  1. Scalers cannot process more than one dataset
  2. Scaling the test set is never needed
  3. The test set has different features from the training set, so it needs its own scaler
  4. Fitting on all data leaks test statistics into training

Answer: D. Fitting on all data leaks test statistics into training

Explanation

Fit the scaler (mean and standard deviation) on training data, then transform both sets. scikit-learn Pipelines do this automatically inside cross-validation.

Step-by-step solution

  1. A scaler learns statistics such as mean and standard deviation.
  2. Fitting it on all data lets test-set statistics shape the training data.
  3. Fit on training data only, then apply the same transform to test data.

Why the other options are wrong

  • A. Scalers can transform any number of datasets once fitted.
  • B. Test data must be scaled the same way, or the model sees different units.
  • C. Train and test have the same features; a separate scaler would scale them inconsistently.

Tip: fit on train, transform on everything.

Practise all 7 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all AI & Machine Learning topics · All topics