Skip to content

Fix negative predictions in Feeds API#626

Merged
regulartim merged 1 commit intointelowlproject:developfrom
opbot-xd:fix/negative-expected-interactions
Dec 19, 2025
Merged

Fix negative predictions in Feeds API#626
regulartim merged 1 commit intointelowlproject:developfrom
opbot-xd:fix/negative-expected-interactions

Conversation

@opbot-xd
Copy link
Copy Markdown
Contributor

Description

The RandomForestRegressor model could occasionally produce negative values for expected_interactions due to specific training data patterns (negative deltas). This caused HTTP 400 errors in the Feeds API because the field requires values >= 0.

This PR implements a fix by clipping the output of the Regressor.predict method to be non-negative using np.maximum(predictions, 0).

A test case (test_negative_predictions) was added to TestRegressor to verify this behavior.

Related issues

Closes #625

Type of change

  • Bug fix (non-breaking change which fixes an issue).

Checklist

  • I have read and understood the rules about how to Contribute to this project.
  • The pull request is for the branch develop.
  • I have added documentation of the new features.
  • Linters (Black, Flake, Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved. All the tests (new and old ones) gave 0 errors.
  • If changes were made to an existing model/serializer/view, the docs were updated and regenerated (check CONTRIBUTE.md).
  • If the GUI has been modified:
    • I have a provided a screenshot of the result in the PR.
    • I have created new frontend tests for the new component or updated existing ones.

- Enforce non-negative predictions in Regressor.predict using np.maximum
- Add test case in TestRegressor to verify negative values are clipped
- Fixes issue with negative expected_interactions causing API errors
@opbot-xd opbot-xd changed the title fix: negative predictions in Feeds API Fix negative predictions in Feeds API Dec 19, 2025
Copy link
Copy Markdown
Collaborator

@regulartim regulartim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

@regulartim regulartim merged commit 3f9434e into intelowlproject:develop Dec 19, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants