Skip to content

KeyError in notebook "1. Intro..." #54

Description

@ansgar-t

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions