Skip to content

npm model version 0.2 - #16

Merged
dicortazar merged 2 commits into
mainfrom
npm_model_0_2
Sep 24, 2026
Merged

dicortazar merged 2 commits into
mainfrom
npm_model_0_2

Conversation

@canasdiaz

Copy link
Copy Markdown
Collaborator

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.

Luis Cañas-Díaz 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>
@dicortazar

Copy link
Copy Markdown
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 !

@dicortazar
dicortazar merged commit 2a5e9b4 into main Sep 24, 2026
3 of 13 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