Skip to content

Instantly share code, notes, and snippets.


Max Halford MaxHalford

View GitHub Profile
View distance.html
<!DOCTYPE html>
<script src=""></script>
<div id="app">
<div class="grid-container">
<button class="grid-item" v-for="key in keys" @click="click(key[0], key[1])">
{{ key[2] }}
import itertools
def merge_components(cs):
while True:
for (i, a), (j, b) in itertools.combinations(enumerate(cs), 2):
if a[0] == b[0]:
del cs[j]
MaxHalford /
Created Feb 16, 2021
ABBYY synchronous query
import urllib.parse
import requests
import time
import xml.dom.minidom
def get_abbyy_transcription(doc, app, password):
proxies = {}
url_params = {
MaxHalford /
Created Jan 27, 2021
Pure Python random laws
import math
import random
def poisson(l, rng=random):
L = math.exp(-l)
k = 0
p = 1
MaxHalford /
Created Jan 5, 2021
Tree implementation
"""Generic branch and leaf implementation."""
import operator
import textwrap
import typing
class Op:
"""An operator that is part of a split."""
__slots__ = "symbol", "func"
MaxHalford /
Created Dec 6, 2020
Rule-based system
import abc
class Rule(abc.ABC):
def __init__(self, var_name):
self.var_name = var_name
def __repr__(self):
"""String representation of the Python expression."""
import pandas as pd
def iter_batches(X_y, batch_size):
x_batch = [None] * batch_size
y_batch = [None] * batch_size
j = 0
for i, (x, y) in enumerate(X_y, start=1):
MaxHalford / med_filter.pyx
Created Aug 23, 2020
Median filter in Cython
View med_filter.pyx
import numpy as np
cimport cython
cimport numpy as np
ctypedef np.uint_t uint
ctypedef np.uint8_t uint8
MaxHalford /
Created Jul 17, 2020
sklearn partial_fit support
import importlib
import inspect
def worthy(obj):
return inspect.isclass(obj) and hasattr(obj, 'partial_fit')
for _, submodule in inspect.getmembers(importlib.import_module('sklearn'), inspect.ismodule):
for _, obj in inspect.getmembers(submodule, worthy):
print(submodule.__name__, obj.__name__)
MaxHalford / linear-models.ipynb
Created Jun 9, 2020
creme mini-batch performance
View linear-models.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.