Change log likelihood squashing#11
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the linear normalization of log-likelihood scores with a sigmoid transformation to improve score distribution. The change aims to ensure EU countries maintain high scores (above 99%) while providing better differentiation across other country groups.
Key changes:
- Introduces sigmoid transformation function with configurable parameters
- Replaces linear scaling (
(log_likelihoods + 100) / 100) with sigmoid-based normalization - Uses sklearn's FunctionTransformer to apply the sigmoid transformation
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@Haffi112 As for the failing code check, you can run |
|
Thanks Dan, I'll have a look again when I have the time. Do you want me to implement this so that it is fitted during training as well? If we want to fit it then it's probably best to cache the log-likelihoods so that is easy to recompute the mean scores when looking for ideal parameters. |
I have a few hours now - I'll have a look 🙂 |
|
@Haffi112 Now fits both the alpha and center to a new validation split. The alpha parameter is set so that the "effective range" of the sigmoid curve corresponds to the range of the input log-likelihoods. If the range of the input data is 100, for instance, the alpha value is 0.1, as shown here:
If the input range is 200, alpha is 0.05. In our case, alpha becomes around 0.05, just like you found manually. The center is then fitted to get the sigmoid log-likelihoods of the EU data to be as close to 99% as possible. This is also fitted to the validation split. This results in a center value of -52.03, really close to your find as well! Here are the log-likelihoods and scores for the train/val/test distribution, after training on the training/validation data: After training on all of the EU data, here are the scores for different country groups: Lastly, added a new |

This adds the sigmoid transform instead of linear scaling of log_likelihoods. Running the test with the command
yields the following results: