Skip to content

Instantly share code, notes, and snippets.

View kwinkunks's full-sized avatar
🐍
Writing bugs

Matt Hall kwinkunks

🐍
Writing bugs
View GitHub Profile
@kwinkunks
kwinkunks / Adding_features.md
Created June 17, 2022 18:16
Why does adding features sometimes make a worse classifier?
@kwinkunks
kwinkunks / _Regressor_comparison.md
Last active November 21, 2023 23:35
Comparison of various regression algorithms

Regressor comparison

Regressor comparison

I wrote a blog post about this here.

I tweeted about it here and again

Inspired, of course, by the various wonderful comparisons in the sklearn docs, like this one for classifiers.

@kwinkunks
kwinkunks / Concatenating_strings.ipynb
Last active April 13, 2022 22:48
What's the fastest way to concatenate things into a string?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / unique.py
Last active March 2, 2022 17:18
Fast, ordered unique items from sequences
# We want to get unique items in a sequence, but to keep the order in which they appear.
# There are quite a few solutions here > http://www.peterbe.com/plog/uniqifiers-benchmark
# Good, up to date summary of methods > https://stackoverflow.com/a/17016257/3381305
# Some test data: text...
tdat = 100 * ['c', 'a', 'c', 'b', 'e', 'd', 'f', 'g', 'h', 'i', 'j', 'j']
tarr = np.array(tdat)
tser = pd.Series(tdat)
# ... and numbers.
narr = np.random.randint(0, 10, size=1200)
@kwinkunks
kwinkunks / Loading_subsurface_data_101.ipynb
Last active April 5, 2022 11:31
How to load various subsurface data types using Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / Back-interpolate_seismic_onto_wellbore.ipynb
Last active February 24, 2022 19:16
Extract seismic amplitudes onto a well path
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kwinkunks
kwinkunks / read_zmapplus.py
Created February 3, 2022 02:51 — forked from wassname/read_zmapplus.py
python function to read zmap plus asci grid format
def read_zmapplusgrid(inputfile,dtype=np.float64):
"""Read ZmapPlus grids
Format is explained here http://lists.osgeo.org/pipermail/gdal-dev/2011-June/029173.html"""
# read header, read until second '@', record header lines and content
infile = open(inputfile,'r')
comments=[]
head=[]
a=0 # count '@'s
headers=0 # cound header+comment lines
@kwinkunks
kwinkunks / dtw.py
Last active April 25, 2022 23:56
Dynamic Thing Warping
# DTW, Dynamic Thing Warping
# Where Thing might be time, or depth, or some other linear basis.
# Apache 2.0 licence.
import numpy as np
def cost(s1, s2):
"""
Very basic algorithm, no windowing.
This cost matrix algorithm was adapted from this blog post by Abhishek Mishra:
@kwinkunks
kwinkunks / aoc21-day07.py
Last active December 7, 2021 14:59
A solution to AOC 2021, Day 7
import numpy as np
def get_data(day, dataset):
with open(f'../js/day{day:02d}/{dataset}.txt', 'r') as f:
return np.array(list(map(int, f.read().split(','))))
def part1(data):
return np.abs(data - np.median(data)).sum()
def part2(data):
@kwinkunks
kwinkunks / SOM.ipynb
Last active November 14, 2021 20:27
Self-organizing maps of seismic
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.