Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#261 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Run step_5.solution() and step_5.check() using the evaluation function shown in the report, then compare the checker’s expectations with the result passed from step 5 into the next step. Done means a valid solution is accepted by step_5.check() while the following exercise still runs correctly.

Written by the indexing model from the issue text.

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.

Dominant language
Jupyter Notebook
Stars
515
Forks
274
Avg merge
14d 16h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Kaggle/learntools

All issues in Kaggle/learntools

Similar issues

More Machine Learning issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.