Kaggle / Kaggle/learntools

NLP Exercise, step 5, solution code fails .check()

Open
#261 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
514
Forks
274
PR merge metrics
No merged PRs in 30d

Description

If you run `step_5.solution()` you get:

```
def evaluate(model, texts, labels):
# Get predictions from textcat model
predicted_class = predict(model, texts)

# From labels, get the true class as a list of integers (POSITIVE -> 1, NEGATIVE -> 0)
true_class = [int(each['cats']['POSITIVE']) for each in labels]

# A boolean or int array indicating correct predictions
correct_predictions = predicted_class == true_class

# The accuracy, number of correct predictions divided by all predictions
accuracy = correct_predictions.mean()

return accuracy
```

but if you use that and run `step_5.check()` it says incorrect. I can't find an answer to this question that passes `step_5.check()` even though many solutions seem correct and run correctly in the next step.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.