This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
On the coursera lecture index, execute this Javascript (via greasemonkey script, bookmarklet, etc) to show 'quizzes' links next to each lecture. Clicking it will open the lecture, but instead of showing the video, will: | |
1. Pause it | |
2. Show the first quiz | |
3. Upon clicking "skip" or "continue" on the quiz, proceed to the next | |
4. Repeat from 3. | |
5. Continue showing the video | |
Having watched a downloaded video, you can now easily do the in-lecture quizzes separately. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! SourceGitVimrc(dir) | |
let gitroot = system("cd " . fnameescape(a:dir) . "; git rev-parse --show-toplevel 2>/dev/null") | |
" Strip trailing newline and escape | |
let gitroot = substitute(gitroot, "\\n*$","","") | |
if strlen(gitroot) && filereadable(gitroot . '/.vimrc') | |
execute "source " . fnameescape(gitroot) . '/.vimrc' | |
endif | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import re | |
class TimeDeltaType(object): | |
""" | |
Interprets a string as a timedelta for argument parsing. | |
With no default unit: | |
>>> tdtype = TimeDeltaType() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re, sys | |
num_re = re.compile(r'(?<=^\[)[0-9]+') | |
in_n = '' | |
out_n = 0 | |
def sub_cb(match): | |
global in_n, out_n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
from abc import ABCMeta, abstractmethod | |
from functools import partial | |
import numpy as np | |
from sklearn.metrics import precision_recall_fscore_support | |
from sklearn.base import BaseEstimator | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Tool to examine the output of model selection search results from scikit-learn (assuming #1787). | |
Pandas might be more appropriate, but I haven't worked out how to do group_best there... | |
For example: | |
>>> my_search = GridSearchCV(est, param_dict={'a': [...], 'b': [...], 'c': [...]}) | |
>>> my_search.fit(X, y) | |
>>> rw = ResultsWrangler(my_search.grid_results_, my_search.fold_results_) | |
>>> grouped = rw.group_best(['a', 'b']) | |
>>> print(zip(grouped.parameters, grouped.scores)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch="$1" | |
if [ -z "$branch" -o -n "$2" ] | |
then | |
echo Usage: $0 gh_user:branch_name | |
exit 2 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from six import iteritems | |
def group_params(items, key_name=lambda x: True): | |
"""bin by sub-dicts where values are compared by id if not hashable | |
>>> a = ('boo', 6) | |
>>> b = ('boo', 6) | |
>>> id(a) == id(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import pipeline, grid_search, linear_model, feature_selection, decomposition, datasets, preprocessing | |
iris = datasets.load_iris() | |
clf = pipeline.Pipeline([ | |
('scale', preprocessing.StandardScaler()), | |
('sel', feature_selection.SelectKBest()), | |
('clf', linear_model.ElasticNet(warm_start=False)), | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""An extension of numpy.testing.assert_warns | |
Handles checking of message and multiple warnings. | |
""" | |
from __future__ import absolute_import, print_function | |
import sys | |
import re | |
import warnings |
OlderNewer