This file contains hidden or 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
#!/usr/bin/env python3 | |
""" | |
project euler # 17 | |
If the numbers 1 to 5 are written out in words: one, two, three, four, five, | |
then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. | |
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in | |
words, how many letters would be used? |
This file contains hidden or 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
ls | grep -E '*-(0[6-9]|1[1-5])$' > plates_06_to_15.txt |
This file contains hidden or 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 pandas as pd | |
import numpy as np | |
def find_correlation(data, threshold=0.9, remove_negative=False): | |
""" | |
Given a numeric pd.DataFrame, this will find highly correlated features, | |
and return a list of features to remove. | |
Parameters | |
----------- | |
data : pandas DataFrame |
This file contains hidden or 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 | |
# start a jupyter server running on a remote host | |
# and port-forward to local machine | |
remote_host=$1 | |
terminal=x-terminal-emulator | |
# start remote jupyter session on port:8889 | |
$terminal ssh $remote_host "ipython notebook --no-browser --port=8889" |
This file contains hidden or 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
#!/usr/bin/env python3.6 | |
# sensible solution | |
import re | |
import sys | |
import itertools | |
def get_seq(path): | |
"""return fasta sequence from file""" | |
lines = open(path).readlines() | |
seq = "" |
This file contains hidden or 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
rsync -a -f"+ */" -f"- *" source/ destination/ |
This file contains hidden or 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
#!/usr/bin/env python | |
"""re-rerun failed jobs | |
>>> ./find_failed.py $results_dir $path_to_batchlist | |
""" | |
import os | |
from sys import argv | |
def has_failed(directory, expected): |
This file contains hidden or 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 random | |
def train_test_split(data, labels, test_prop=0.3): | |
"""roll your own train test split""" | |
assert len(data) == len(labels) | |
n_test = round(test_prop * len(data)) | |
n_train = len(data) - n_test | |
combined = list(zip(data, labels)) | |
random.shuffle(combined) | |
x_train, y_train = zip(*combined[:n_train]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
using StatsBase | |
function otsu_threshold(img, bit_depth = 256) | |
counts = fit(Histogram, img[:], nbins = bit_depth).weights | |
const total = prod(size(img)) | |
current_max, threshold = 0, 0 | |
weightB, sumB = 0, 0 | |
sumT = sum([i * counts[i] for i in 1:bit_depth]) | |
for (i, count) in enumerate(counts) | |
weightB += count |