Skip to content

Instantly share code, notes, and snippets.

View bmcfee's full-sized avatar

Brian McFee bmcfee

View GitHub Profile
@bmcfee
bmcfee / filtered_stratified_splitter
Created April 22, 2013 18:21
This function is a wrapper for sklearn.cross_validation.Stratified*. Sometimes, you have data where multiple samples are related to the same object (eg: several audio clips from the same song), and blindly partitioning the data into train/test without accounting for this can bias your estimator. This wrapper allows you to specify a "meta id" for…
def filtered_stratified_split(ids, splitter, Y, **kwargs):
'''Cross-validation split filtration. Ensures that points of the same meta-id end up on the same side of the split
input:
ids: n-by-1 mapping of data points to meta-id
splitter: handle to the cross-validation class (eg, StratifiedShuffleSplit)
Y: n-by-1 vector of class labels
**kwargs: arguments to the cross-validation class
@bmcfee
bmcfee / gist:5878337
Last active December 19, 2015 01:49
A simple demonstration of some librosa functions.
{
"metadata": {
"name": "LibROSA demo"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@bmcfee
bmcfee / gist:5891505
Created June 29, 2013 15:17
librosa stsft example
import librosa
import numpy as np
import scipy
y, sr = librosa.load('/home/bmcfee/data/SMC_Mirex/SMC_MIREX_Audio/SMC_002.wav')
D = librosa.stft(y, n_fft=512)
@bmcfee
bmcfee / Buffered Estimator Demo.ipynb
Created July 10, 2013 16:38
A demonstration of buffered generators for online learning
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmcfee
bmcfee / Machinedness.ipynb
Last active June 22, 2018 04:33
Machinedness detector - NYC Monthly Music Hackathon, July 27
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmcfee
bmcfee / git versioning
Last active January 1, 2016 03:39
Just a quick little function to extract the current git revision hash from a filename. This is useful for data-versioning, say, when running a development version of a feature extractor on a fixed sample.
import os
import git
def get_git_revision(filename, default='unversioned'):
'''Walk up a path name until we find a git dir, then grab its current revision.
If the file is not under any git repository, returns ''.
'''
old_filename = None
@bmcfee
bmcfee / gist:8105661
Last active January 1, 2016 06:29
librosa-gordon feature modeling demo
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@bmcfee
bmcfee / pylintrc
Created December 29, 2013 23:33
pylintrc used for scoring librosa
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Profiled execution.
@bmcfee
bmcfee / gist:8202181
Last active January 1, 2016 21:18
First hack at librosa feature extractor transformer wrapping
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{