npm model version 0.2 - #16
Merged
Merged
Conversation
added 2 commits
September 22, 2026 23:16
Two of the metrics returned NaN and it was affecting the quality of the data used by the model. Instead of making up a number that is too high or two low, when no data is available we return the worst possible value based on the monitored timeframe. Changes also include a new version of the metrics.json file to be used by the jupyter notebooks to build an updated version of the model. Signed-off-by: Luis Cañas-Díaz <canasdiaz@aboutcode.org>
Changes fix several issues found in 0.1 version. A new Python Notebook file is included, with the updated Python code to calculate the score. Main changes with respect to the previous three notebooks: - Fix: Join metrics and expert labels on SPDXID instead of the repository URL, which is not unique for packages living in the same monorepo. - Fix: Compute correlations only on the 166 labelled packages, on a signed log1p scale so a few giant repositories do not dominate them. - Improvement: Drop constant metrics (found_file_adopters, file_types_binary) and metrics derived from another one (commits_per_*, message_size_median, commit_size_removed_lines) before the correlation pass. - Improvement: Within each group of correlated metrics (|Pearson| > 0.8) keep the one with the highest univariate ROC AUC against the expert label, instead of the first column in metrics.json. - Improvement: Put StandardScaler and LogisticRegression in a Pipeline so scaling is fitted per fold; no more scaler_params.csv. - Improvement: Evaluate with 10-fold StratifiedGroupKFold grouped by repository (out-of-sample score for every package) instead of a single 75/25 split. - Add confusion matrix, classification report, misclassified packages, model weights and the distribution of the scores. Result on the current data: 11 of 32 metrics kept, 95.2% agreement with the expert (ROC AUC 0.971). Assisted-by: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Luis Cañas-Díaz <canasdiaz@aboutcode.org>
Collaborator
|
Results look good. The distribution I've seen in the other dataset is more skewed to unhealthy ones but the population we're using looks like this. In any case this distribution is similar as the values are relatively pushed to the extremes. This makes sense given the peculiarities of the npm ecosystem. I like having only one notebook and it is easy to read and comprehensive. Thank you @canasdiaz ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
npm model version 0.2. Updates both the notebook and Python code
Changes fix several issues found in version 0.1. A new Python
Notebook file is included, with the updated Python code to calculate
the score.