# Error in naIVE BIAS ASSIGNMENT

**URL:** <https://community.deeplearning.ai/t/error-in-naive-bias-assignment/776731>\
**Category:** NLP with Classification and Vector Spaces\
**Tags:** week-module-2\
**Created:** [February 26, 2025, 4:38am UTC](https://community.deeplearning.ai/t/error-in-naive-bias-assignment/776731 "2025-02-26T04:38:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saswata\_stark](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@Saswata\_stark](https://community.deeplearning.ai/u/Saswata_stark)\
**Post date:** [February 26, 2025, 4:38am UTC](https://community.deeplearning.ai/t/error-in-naive-bias-assignment/776731/1 "2025-02-26T04:38:02Z")

</div>

_{moderator edit - solution code removed}_

THIS CODE OUTPUT MATCHES RESULTS BUT FAILES TEST cases says dictionary wrong values.  
while all other test cases which includes this function passes.  
can anyone explain

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [February 26, 2025, 4:53am UTC](https://community.deeplearning.ai/t/error-in-naive-bias-assignment/776731/2 "2025-02-26T04:53:43Z")

</div>

You are making the most common mistake on this function. When you see a word, you are adding 1 to the positive or negative count. The point is to use the frequency of that word appearing in a positive or negative tweet. That’s what they mean by the comments that they gave you in the template code.

---

<div class="post-metadata">

**Author:** ![Muhammad\_Talha10](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Muhammad\_Talha10](https://community.deeplearning.ai/u/Muhammad_Talha10)\
**Post date:** [February 26, 2025, 5:29am UTC](https://community.deeplearning.ai/t/error-in-naive-bias-assignment/776731/3 "2025-02-26T05:29:00Z")

</div>

It sounds like your dictionary’s structure or values don’t match the test case’s expectations. Double-check:

1. **Key Names** : Ensure they match exactly (case-sensitive).
2. **Value Types** : Verify types (e.g., `int`, `float`, `list`).
3. **Formatting** : Round floats, sort lists, or trim strings if needed.
4. **Extra/Missing Keys** : Remove unnecessary keys or add missing ones.

Print your output and compare it with the expected result to spot differences. Let me know if you need help debugging! 😊

---

<div class="post-metadata">

**Author:** ![Saswata\_stark](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@Saswata\_stark](https://community.deeplearning.ai/u/Saswata_stark)\
**Post date:** [February 26, 2025, 6:02am UTC](https://community.deeplearning.ai/t/error-in-naive-bias-assignment/776731/4 "2025-02-26T06:02:17Z")

</div>

thanks a lot it worked
