0
0
NLPml~10 mins

Hybrid approaches in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to combine rule-based and machine learning predictions.

NLP
final_prediction = ml_model.predict(data) if [1] else rule_based_predict(data)
Drag options to blanks, or click blank then click option'
Ause_ml
Buse_rule
Cuse_hybrid
Duse_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'use_rule' instead of 'use_ml' causes the rule-based method to always run.
Using 'use_data' is incorrect because it does not control the prediction method.
2fill in blank
medium

Complete the code to merge predictions from ML and rules by averaging.

NLP
combined_score = (ml_score + [1]) / 2
Drag options to blanks, or click blank then click option'
Aml_prediction
Brule_prediction
Cdata_score
Drule_score
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ml_prediction' duplicates the ML score instead of combining with rules.
Using 'data_score' is unrelated to rule-based predictions.
3fill in blank
hard

Fix the error in the hybrid prediction function by filling the blank.

NLP
def hybrid_predict(data):
    if data['length'] > 10:
        return ml_model.predict(data)
    else:
        return [1](data)
Drag options to blanks, or click blank then click option'
Adata_predict
Bml_model.predict
Crule_based_predict
Dpredict_rule
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'ml_model.predict' again ignores the rule-based fallback.
Using 'predict_rule' is not defined and causes an error.
4fill in blank
hard

Fill both blanks to create a dictionary of predictions from ML and rules.

NLP
predictions = {
    'ml': ml_model.[1](data),
    'rule': [2](data)
}
Drag options to blanks, or click blank then click option'
Apredict
Brule_based_predict
Cpredict_rule
Dpredict_ml
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict_rule' causes a NameError.
Using 'predict_ml' is not a valid method.
5fill in blank
hard

Fill all three blanks to filter data, predict with ML, and combine with rules.

NLP
filtered_data = [d for d in dataset if d['score'] [1] 0.5]
ml_preds = [ml_model.[2](d) for d in filtered_data]
final_preds = [ml + [3](d) for ml, d in zip(ml_preds, filtered_data)]
Drag options to blanks, or click blank then click option'
A>
Bpredict
Crule_based_predict
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' filters wrong data subset.
Using 'predict_rule' instead of 'rule_based_predict' causes errors.