Skip to content

Instantly share code, notes, and snippets.

View leo-pfeiffer's full-sized avatar

Leo Pfeiffer leo-pfeiffer

View GitHub Profile
@leo-pfeiffer
leo-pfeiffer / docker-compose-workflow.yml
Created August 1, 2021 14:25 — forked from cecilemuller/example.yml
Run Docker Compose + in Github Action
name: Test
on:
push:
branches:
- main
- features/**
- dependabot/**
pull_request:
branches:
@leo-pfeiffer
leo-pfeiffer / Makefile
Last active August 1, 2021 10:26
Auto help command for Makefile
## https://stackoverflow.com/a/35730928/12168211
## Automatic help command
## Comment directly before target name used as help
.PHONY: help
# Show this help.
help:
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t
@leo-pfeiffer
leo-pfeiffer / logging_decorator.py
Last active July 9, 2021 08:25
Logging decorator
"""
Simple logging decorator.
Usage:
@log()
def foo():
# raise an exception
return 1 / 0
By default, the exception is logged and then raised.
@leo-pfeiffer
leo-pfeiffer / purity.py
Last active May 12, 2021 16:24
Calculate the gini index and entropy for a list of classes
import argparse
from decimal import *
from functools import reduce, partial
import math
def _class_count(dic, x):
"""
Callback function to count elements in a list.
"""
@leo-pfeiffer
leo-pfeiffer / roc.py
Last active May 10, 2021 13:17
ROC curve calculation and plot
import argparse
from decimal import Decimal
import matplotlib.pyplot as plt
from numpy import trapz
def create_roc_values(thresholds, scores, true_values):
"""
Calculate the points on a roc curve
"""
assert len(scores) == len(true_values)