Open
Description
Depending on the random train/test split this code can give a key error:
for i in X_test_features:
predicted_values.append(joint_prob[i[0], i[1]].idxmax())
Here's a possible alternative:
for i in X_test_features:
key = (i[0], i[1])
conditional_prob = joint_prob[key].idxmax() if key in joint_prob else 0.0
predicted_values.append(conditional_prob)
Metadata
Assignees
Labels
No labels
Activity