Skip to content

Instantly share code, notes, and snippets.

@galvanic
galvanic / README.md
Last active March 3, 2021 23:12
Plot a calendar in python using matplotlib.
@galvanic
galvanic / README.md
Last active July 6, 2016 15:59
bar chart for financial data
@galvanic
galvanic / parse_TREC.py
Last active May 25, 2017 20:19
Parse the TREC 2007 spam email dataset
#!/usr/bin/env python
# coding: utf-8
import numpy as np
import pandas as pd
import re
#import os ## TODO use this to traverse folders
from email.parser import Parser
from sklearn.feature_extraction.text import CountVectorizer
@galvanic
galvanic / toc.sh
Created June 20, 2016 10:30
command line to get a simple toc (without hyperlinks) for ipython notebook(s) using jq
cat *.ipynb | jq '.cells' | jq -c '.[] | select(.cell_type | contains("markdown"))' | jq -c '. | select(.source[] | contains("#")) | .source[]' | grep "#" | sed 's/"//g' | sed 's/\\n//g' | sed 's/#/\t/g' | sed 's/\(.*\)\t/\1-/'
@galvanic
galvanic / README.md
Last active July 6, 2016 16:00
upset chart implementation

Upset chart example

A simple upset chart implementation, a chart type useful for visualising set intersections, applied to flatmate-purchase assignment data from my onlineshop project.

See it live on bl.ocks

@galvanic
galvanic / GDmethod.md
Last active August 11, 2016 00:00
test to see Adaline classifier performance depending on gradient descent mini-batch size (here 10) - vs. full batch and stochastic (batch size of 1)
metrics                                                 AUC      FNR      FPR  error_test  error_train
classifier          attack   % poisoned GD method                                                     
adaline             empty    0.0        mini-batch     0.94     0.00     0.12        0.03         0.01
                                        stochastic     0.58     0.65     0.20        0.54         0.51
                                        batch          0.93     0.00     0.14        0.03         0.01
                             0.5        mini-batch     0.92     0.01     0.15        0.04         0.01
                                        stochastic     0.45     0.57     0.53        0.56         0.29
                                        batch          0.90     0.02     0.19        0.06         0.00
default_parameters:
experiment: adaptive combination
dataset_filename: enron-kayla
label_type:
ham_label: -1
spam_label: 1
default_parameters:
experiment: adaptive combination
dataset_filename: enron-kayla
label_type:
ham_label: -1
spam_label: 1
default_parameters:
experiment: adaptive combination
dataset_filename: enron-kayla
label_type:
ham_label: -1
spam_label: 1
default_parameters:
experiment: adaptive combination
dataset_filename: enron-kayla
label_type:
ham_label: -1
spam_label: 1