Bird
Raised Fist0

Offline vs Online Evaluation - Why They Disagree

THEORYadvancedInterview freq: very_high
Choose your preparation mode6 modes available
▶
Execution Trace
Step 1/5
Historical Data

The model accesses historical data to simulate predictions.

🎯 Understanding the role of historical data in offline evaluation.
historical_data = load_data('historical.csv')
predictions = model.predict(historical_data)
Model Predictions

Predictions are generated based on the historical data.

🎯 How predictions are formed in offline evaluation.
accuracy = evaluate(predictions, true_labels)
Real-time Data

The model receives real-time data inputs for evaluation.

🎯 The importance of real-time data in online evaluation.
real_time_data = stream_data()
live_predictions = model.predict(real_time_data)
User Interactions

User interactions provide feedback on model predictions.

🎯 How user feedback influences online evaluation.
feedback = collect_user_feedback()
adjusted_accuracy = adjust_based_on_feedback(live_predictions, feedback)
Comparison

Discrepancies between offline and online evaluations are analyzed.

🎯 Why offline and online evaluations might disagree.
discrepancy = compare_evaluations(accuracy, adjusted_accuracy)
📊
Diagram
Diagram
┌───────────────────────────────┐
│       Offline Evaluation      │
│ ┌───────────────────────────┐ │
│ │ Historical Data           │ │
│ │ ┌───────────────────────┐ │ │
│ │ │ Model Predictions     │ │ │
│ │ └───────────────────────┘ │ │
│ └───────────────────────────┘ │
└───────────────┬───────────────┘
                │
                ▼
┌───────────────────────────────┐
│       Online Evaluation       │
│ ┌───────────────────────────┐ │
│ │ Real-time Data            │ │
│ │ ┌───────────────────────┐ │ │
│ │ │ User Interactions     │ │ │
│ │ └───────────────────────┘ │ │
│ └───────────────────────────┘ │
└───────────────────────────────┘
  • Offline Evaluation: Uses historical data for model predictions
  • Online Evaluation: Relies on real-time data and user interactions
  • Model Predictions: Output generated by the model in offline mode
  • Historical Data: Past data used for offline evaluation
  • User Interactions: Real-time feedback used in online evaluation
🔑
Key Moments
▲
Q: Why might offline evaluation not reflect real-world performance?
A: Offline evaluation uses historical data, which may not capture current trends or user behavior.
Q: How does user feedback impact online evaluation?
A: User feedback provides real-time insights that can adjust model predictions and improve accuracy.
Q: What causes discrepancies between offline and online evaluations?
A: Differences in data freshness, user interactions, and feedback mechanisms can lead to discrepancies.

This diagram and trace explain the differences between offline and online evaluation of machine learning models. Offline evaluation relies on historical data to generate predictions, which may not accurately reflect current user behavior or trends. In contrast, online evaluation uses real-time data and user interactions to provide immediate feedback, allowing for adjustments to model predictions. Understanding these differences is crucial for interpreting model performance and making informed decisions about deployment and improvement.

Primary Focus

✓ Understanding the discrepancies between offline and online evaluation in ML models

Practice

(1/5)
1. In the context of Convolutional Neural Networks, what is the primary purpose of pooling layers?
easy
A. To reduce the spatial dimensions of the feature maps
B. To increase the size of the feature maps
C. To increase the number of channels in the feature maps
D. To apply non-linear activation functions

Solution

  1. Step 1: Understand pooling layers

    Pooling layers are used to reduce the spatial dimensions of feature maps, which helps in reducing computation and controlling overfitting.
  2. Step 2: Eliminate wrong options

    To increase the size of the feature maps is incorrect because pooling reduces size, not increases it. To increase the number of channels in the feature maps is incorrect as pooling doesn't change the number of channels. To apply non-linear activation functions is incorrect because pooling doesn't apply non-linear activations.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Pooling reduces spatial dimensions. [OK]
Hint: Pooling reduces spatial dimensions. [OK]
Common Mistakes:
2. Given the following Python code using Naive Bayes, what will be the output?
from sklearn.naive_bayes import GaussianNB
import numpy as np
X = np.array([[1, 2], [2, 3], [3, 4]])
y = np.array([1, 0, 1])
model = GaussianNB()
model.fit(X, y)
print(model.predict([[2, 2]]))
easy
A. [1]
B. [0]
C. [0, 1]
D. Error due to shape mismatch

Solution

  1. Step 1: Understand the Code Execution

    The code fits a Gaussian Naive Bayes model and predicts the class for a new sample [2, 2].
  2. Step 2: Analyze the Prediction

    Given the training data, the model predicts class 1 for [2, 2] based on the likelihoods.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    GaussianNB predicts based on likelihoods. [[check]]
Hint: GaussianNB predicts based on likelihoods. [[check]]
Common Mistakes:
3. A model performs well overall but poorly on a specific slice of data. What is the most likely cause?
medium
A. The slice has a different distribution than the training data.
B. The model has too many parameters.
C. The model is overfitting to the training data.
D. The learning rate is too high.

Solution

  1. Step 1: Analyze the problem

    Poor performance on a specific slice often indicates distribution mismatch.
  2. Step 2: Eliminate wrong options

    The model is overfitting to the training data. is incorrect as overfitting would affect overall performance. The model has too many parameters. is unrelated to slice-specific issues. The learning rate is too high. affects convergence, not slice performance.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Slice mismatch = distribution issue. [OK]
Hint: Slice mismatch = distribution issue. [OK]
Common Mistakes:
4. When should you avoid using Naive Bayes despite its simplicity and speed?
medium
A. When the dataset is very large.
B. When the dataset has missing values.
C. When you need a probabilistic output.
D. When features are highly correlated.

Solution

  1. Step 1: Identify Naive Bayes Limitations

    Naive Bayes assumes feature independence given the class label.
  2. Step 2: Evaluate Each Option

    When the dataset is very large. is incorrect because Naive Bayes handles large datasets well. When you need a probabilistic output. is incorrect because Naive Bayes provides probabilistic outputs. When the dataset has missing values. is incorrect because Naive Bayes can handle missing values with some preprocessing.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Correlated features break Naive Bayes. [[check]]
Hint: Correlated features break Naive Bayes. [[check]]
Common Mistakes:
5. When considering bias mitigation strategies, which approach is more suitable for a scenario where you cannot alter the training data but need to ensure fairness in predictions?
medium
A. Pre-processing techniques
B. In-processing techniques
C. Data augmentation
D. Post-processing techniques

Solution

  1. Step 1: Identify the constraint.

    Cannot alter training data, need fairness in predictions.
  2. Step 2: Choose the suitable technique.

    Post-processing techniques adjust predictions to ensure fairness without altering the model or data.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Post-processing adjusts predictions, not data. [OK]
Hint: Post-processing adjusts predictions, not data. [OK]
Common Mistakes:
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