Skip to content

Refactor: Externalize Random Forest Parameters.#623

Merged
regulartim merged 6 commits intointelowlproject:developfrom
opbot-xd:refactor/externalize-rf-hyperparameters
Dec 18, 2025
Merged

Refactor: Externalize Random Forest Parameters.#623
regulartim merged 6 commits intointelowlproject:developfrom
opbot-xd:refactor/externalize-rf-hyperparameters

Conversation

@opbot-xd
Copy link
Copy Markdown
Contributor

@opbot-xd opbot-xd commented Dec 17, 2025

Description

This PR refactors the Random Forest implementation to externalize hyperparameters to a JSON configuration file (configuration/ml_config.json). Currently, these parameters are hardcoded in the RFClassifier and RFRegressor classes. Moving them to a configuration file allows for easier tuning and experimentation without modifying the codebase.

Related issues

Closes #614

Type of change

  • New feature (non-breaking change which adds functionality).

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.

@opbot-xd
Copy link
Copy Markdown
Contributor Author

@regulartim please review this PR when you get time


DJANGO_LOG_DIRECTORY = "/var/log/greedybear/django"
ML_MODEL_DIRECTORY = os.path.join(BASE_DIR, "mlmodels/") # "/opt/deploy/greedybear/mlmodels"
ML_CONFIG_PATH = os.path.join(BASE_DIR, "configuration/ml_config.json")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wouldn't "ML_CONFIG_FILE" be a better name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No, I meant something different: I think "ML_CONFIG_FILE" would be a better name for the constant. The file name "ml_config.json" is fine.

@regulartim
Copy link
Copy Markdown
Collaborator

Looks good! 👍 In the checklist you marked that you have created tests. Where are they?

@opbot-xd
Copy link
Copy Markdown
Contributor Author

Looks good! 👍 In the checklist you marked that you have created tests. Where are they?

Since this was a refactor to externalize the hyperparameters and all existing tests were passing, I interpreted the scope as small enough that specific new tests weren't critical at that stage.
However, ensuring the new loading logic is robust is definitely the right call. I have added tests/test_rf_config.py

@regulartim
Copy link
Copy Markdown
Collaborator

I was just confused that you checked the box but I couldn't see any tests. But it's good that you added some. It's always better to have new features covered by test cases. Good work. 👍

@regulartim regulartim merged commit 102fc25 into intelowlproject:develop Dec 18, 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