[Enhancement] Ranking importance (prefer lower runtimes over smaller diff lines) #685
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement
This is still experimental, but the core idea is the
normalization: which is better than sorting in that case because if there is a very low runtime or a low diff it will standout
relativelyto other values.So suppose if we have these metrics
runtime = [60, 40, 4]
diffs = [10, 9, 10]
the total score we would have currently is
{0: 3, 1: 1, 2: 2}so it will pick the second candidate of 40 runtime and 9 lines diff (which is not the best here)but with normalization and weights the ranking dict would be
{0: 1.0, 1: 0.4821428571428572, 2: 0.25}so it would pick the 4 runtime with 10 lines of diffso it's all about which candidate is better related to other candidates
weights: for the 3 and 1 weights, it's for saying runtime is 3 times more important than diff, I still need to play with these two numbers to see what is the best percentage
Description
Add weight utilities for normalized importances
Implement metric normalization and scoring
Update
determine_best_candidatewith weightingRemove old rank summation approach
Diagram Walkthrough
File Walkthrough
code_utils.py
Introduce weighted metrics utility functionscodeflash/code_utils/code_utils.py
choose_weightsutility for normalizationnormalizefunction for metrics scalingcreate_score_dictionary_from_metricsfor scoringfunction_optimizer.py
Switch to weighted metric ranking logiccodeflash/optimization/function_optimizer.py
runtimes_listanddiff_lens_listcreate_rank_dictionary_compactlogic