Skip to content

Instantly share code, notes, and snippets.

View massiung's full-sized avatar

Massimiliano Ungheretti massiung

  • Utrecht, The Netherlands
View GitHub Profile
@massiung
massiung / table_of_contents.md
Last active August 28, 2018 13:15
Creating a table of contents in markdown files, rmarkdown and jupyter notebooks

Installing markdown-toc globally

npm install -g markdown-toc

Markdown files/ presentations

Insert the following snippet into your markdown file:

<!-- toc -->
This is where the table will be!
# machine learning
scikit-learn
statsmodels
xgboost
lightgbm
catboost
# natural language processing
gensim
@massiung
massiung / auc.py
Created November 15, 2018 14:12
AUC
from sklearn.metrics import roc_auc_score
def auc(X, y, classifier):
y_score = classifier.predict_proba(X)[:, 1]
return roc_auc_score(y, y_score)
@massiung
massiung / psi_iv.py
Last active July 7, 2022 00:35
Population Stability Index and Information Value function
def pop_diff(popA, popB, bin_boundaries=None, num_bins=10):
"""
Compute difference between two populations using the PSI / IV formula
$$\Sigma_{i} (p_i^B - p_i^a)*\ln(\frac{p_i^B}{p_i^A})$$
Note:
Counts missing values in a separate bin to test for information and shift.
Raises ValueError if popA has no nans but popB does.
@massiung
massiung / kde.md
Last active March 28, 2020 12:27
Presentation Kernel Density Estimation
title theme revealOptions
Kernel Density Estimation
solarized
transition
fade

Kernel Density Estimation