Bird
0
0

Consider this Python code snippet combining rule and ML predictions:

medium📝 Predict Output Q13 of 15
NLP - Sentiment Analysis Advanced
Consider this Python code snippet combining rule and ML predictions:
rule_pred = [1, 0, 1, 1]
ml_pred = [1, 1, 0, 1]
combined = [int(r or m) for r, m in zip(rule_pred, ml_pred)]
print(combined)
What is the output?
A[0, 1, 1, 0]
B[1, 0, 0, 1]
C[1, 1, 1, 1]
D[1, 1, 0, 0]
Step-by-Step Solution
Solution:
  1. Step 1: Understand the logic of combining predictions

    The code uses logical OR between rule_pred and ml_pred elements.
  2. Step 2: Calculate each combined element

    Positions: 1 or 1 = 1, 0 or 1 = 1, 1 or 0 = 1, 1 or 1 = 1.
  3. Final Answer:

    [1, 1, 1, 1] -> Option C
  4. Quick Check:

    OR operation on lists = [1,1,1,1] [OK]
Quick Trick: OR means if either is 1, result is 1 [OK]
Common Mistakes:
MISTAKES
  • Confusing OR with AND
  • Mixing up list positions
  • Forgetting to convert boolean to int

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes