Bird
Raised Fist0
ML Pythonml~5 mins

Learning curves in ML Python - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is a learning curve in machine learning?
A learning curve is a graph that shows how a model's performance improves over time or with more training data. It helps us understand if the model is learning well or if it needs adjustments.
Click to reveal answer
intermediate
What does it mean if a learning curve shows high training accuracy but low validation accuracy?
This usually means the model is overfitting. It learns the training data too well but does not generalize to new data.
Click to reveal answer
intermediate
How can learning curves help decide if more training data is needed?
If the validation error continues to decrease as the training set size increases, it indicates that more training data would be beneficial.
Click to reveal answer
intermediate
What does a learning curve look like when a model is underfitting?
Both training and validation errors are high and do not improve much with more data or training, showing the model is too simple.
Click to reveal answer
beginner
Why is it useful to plot both training and validation learning curves?
Plotting both helps compare how well the model learns from training data and how well it generalizes to unseen data, guiding improvements.
Click to reveal answer
What does a learning curve typically plot?
ATraining loss vs. number of layers
BNumber of features vs. model size
CData accuracy vs. data quality
DModel performance vs. training time or data size
If training error is low but validation error is high, what is likely happening?
AUnderfitting
BOverfitting
CGood fit
DData leakage
What can you infer if both training and validation errors are high and close?
AModel is perfect
BModel is overfitting
CModel is underfitting
DData is corrupted
How can learning curves help improve a model?
ABy showing if more data or complexity is needed
BBy showing the best hyperparameter values directly
CBy cleaning the data automatically
DBy increasing the number of features
What does a flat learning curve with high error indicate?
AModel is underfitting
BModel is overfitting
CModel is learning well
DModel is perfectly trained
Explain what a learning curve is and how it helps in understanding model training.
Think about how a graph can show progress.
You got /3 concepts.
    Describe the differences in learning curves when a model is overfitting versus underfitting.
    Focus on error patterns in training and validation.
    You got /3 concepts.

      Practice

      (1/5)
      1. What does a learning curve primarily show in machine learning?
      easy
      A. The hardware used for training the model
      B. How model performance changes with more training data
      C. The number of features in the dataset
      D. The exact time a model takes to train

      Solution

      1. Step 1: Understand the purpose of learning curves

        Learning curves plot model performance (like accuracy or error) against the amount of training data.
      2. Step 2: Identify what is shown on the curve

        The curve shows how well the model learns as it sees more data, helping to spot underfitting or overfitting.
      3. Final Answer:

        How model performance changes with more training data -> Option B
      4. Quick Check:

        Learning curve = model performance vs data size [OK]
      Hint: Learning curves show performance vs data size [OK]
      Common Mistakes:
      • Confusing learning curves with training time plots
      • Thinking learning curves show feature counts
      • Assuming hardware affects learning curves directly
      2. Which of the following is the correct way to plot a learning curve in Python using scikit-learn?
      easy
      A. import sklearn.plot as sp; sp.learning_curve(model, X, y)
      B. from sklearn.learning import curve_plot; curve_plot(model, X, y)
      C. from sklearn.model_selection import learning_curve; train_sizes, train_scores, test_scores = learning_curve(model, X, y)
      D. from sklearn.model_selection import train_curve; train_curve(model, X, y)

      Solution

      1. Step 1: Recall the correct scikit-learn function for learning curves

        The function is learning_curve from sklearn.model_selection.
      2. Step 2: Check the import and usage syntax

        from sklearn.model_selection import learning_curve; train_sizes, train_scores, test_scores = learning_curve(model, X, y) correctly imports learning_curve and calls it with model, features X, and labels y.
      3. Final Answer:

        from sklearn.model_selection import learning_curve; train_sizes, train_scores, test_scores = learning_curve(model, X, y) -> Option C
      4. Quick Check:

        Correct import and call = from sklearn.model_selection import learning_curve; train_sizes, train_scores, test_scores = learning_curve(model, X, y) [OK]
      Hint: Use sklearn.model_selection.learning_curve to plot learning curves [OK]
      Common Mistakes:
      • Using wrong module or function names
      • Trying to import non-existent functions
      • Confusing learning_curve with train_test_split
      3. Given this code snippet, what will be the shape of train_sizes if X has 100 samples?
      from sklearn.model_selection import learning_curve
      train_sizes, train_scores, test_scores = learning_curve(model, X, y, train_sizes=[0.1, 0.5, 1.0])
      medium
      A. (100,)
      B. (1,)
      C. (3, 100)
      D. (3,)

      Solution

      1. Step 1: Understand train_sizes parameter

        train_sizes is given as a list with 3 values: 0.1, 0.5, and 1.0, representing fractions of the training data.
      2. Step 2: Determine output shape of train_sizes

        The learning_curve function returns train_sizes as an array with length equal to the number of training sizes specified, so shape is (3,).
      3. Final Answer:

        (3,) -> Option D
      4. Quick Check:

        train_sizes length = number of fractions given [OK]
      Hint: train_sizes shape matches number of training fractions [OK]
      Common Mistakes:
      • Assuming train_sizes matches number of samples
      • Confusing train_sizes with train_scores shape
      • Thinking train_sizes is always (100,)
      4. You plotted a learning curve but see both training and validation errors are high and close. What is the likely issue?
      medium
      A. The model is underfitting the data
      B. The model is overfitting the data
      C. There is a data leakage problem
      D. The training data is too large

      Solution

      1. Step 1: Analyze error levels on learning curve

        High training error means the model cannot fit the training data well.
      2. Step 2: Compare training and validation errors

        Both errors being high and close indicates underfitting, where the model is too simple.
      3. Final Answer:

        The model is underfitting the data -> Option A
      4. Quick Check:

        High train & val error = underfitting [OK]
      Hint: High train and val errors mean underfitting [OK]
      Common Mistakes:
      • Confusing underfitting with overfitting
      • Assuming data leakage causes high errors
      • Thinking large data size causes this pattern
      5. You have a learning curve where training error is very low but validation error is high and does not improve with more data. What is the best next step?
      hard
      A. Try a simpler model to reduce overfitting
      B. Collect more training data to improve validation
      C. Increase model complexity to fit training data better
      D. Stop training because the model is perfect

      Solution

      1. Step 1: Interpret the learning curve pattern

        Low training error but high validation error means the model fits training data too well but fails on new data, indicating overfitting.
      2. Step 2: Decide the best action to fix overfitting

        Using a simpler model reduces complexity and helps generalize better, improving validation error.
      3. Final Answer:

        Try a simpler model to reduce overfitting -> Option A
      4. Quick Check:

        Low train error + high val error = overfitting; simplify model [OK]
      Hint: Low train error + high val error means overfitting; simplify model [OK]
      Common Mistakes:
      • Collecting more data won't fix overfitting alone
      • Increasing complexity worsens overfitting
      • Assuming model is perfect with low training error
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard