Skip to content

Instantly share code, notes, and snippets.

View betatim's full-sized avatar
🤠
Not my first rodeo

Tim Head betatim

🤠
Not my first rodeo
View GitHub Profile
@betatim
betatim / bench_store_fitted_as_numpy.py
Created August 10, 2026 14:59
Use this with https://github.com/scikit-learn/scikit-learn/pull/34667 (tested with `16de9236116f0dd3dcc769eaea781d389a6ae419`)
"""Benchmark storing fitted attributes as NumPy.
Times a PCA + LogisticRegression pipeline with and without the
`store_fitted_as_numpy` configuration option added in
https://github.com/scikit-learn/scikit-learn/pull/34667, for
https://github.com/scikit-learn/scikit-learn/issues/34604.
Needs that branch checked out. Run it with no arguments:
python bench_store_fitted_as_numpy.py
@betatim
betatim / SKILL.md
Created June 11, 2026 14:00
Produce a structured walkthrough of a GitHub PR ordered by causal dependency.
name pr-walkthrough
description Produce a structured walkthrough of a GitHub PR ordered by causal dependency. Use when the user asks to walk through, analyze, or understand a PR's changes.

PR Walkthrough

Generate a causal-dependency-ordered walkthrough of a GitHub PR and write it to agents/reviews/ in the repository.

This skill is scoped to PRs in the current repository. Cross-repo PRs are out of scope.

@betatim
betatim / salary_pipeline.py
Created June 2, 2026 12:40
Code from the skrub gallery
import numpy as np
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import cross_validate
from skrub import tabular_pipeline
from skrub.datasets import fetch_employee_salaries
def main():
print("Loading employee salaries dataset ...")
data = fetch_employee_salaries()
#!/usr/bin/env python3
"""
Employee Salary Prediction
==========================
Predict current annual salary for Montgomery County employees
using a scikit-learn pipeline with mixed feature types.
"""
try:
import cuml.accel
@betatim
betatim / AGENTS.md
Created April 30, 2026 07:36
My cuml `AGENTS.md`

AGENTS Instruction

This file contains is additional guidance for AI agents and other AI editors.


Core Principles

These principles reduce common LLM coding mistakes. Apply them to every task.

@betatim
betatim / gridsearch.py
Created April 13, 2026 15:00
GridSearchCV on a (random) pipeline. Main take away is that fitting the pipeline takes seconds.
"""
Pipeline(StandardScaler, PCA, RandomForest) with GridSearchCV
=============================================================
GridSearchCV over an all-proxy Pipeline on the full Forest Cover Type
dataset (581K samples, 54 features, 7 classes).
Pipeline: StandardScaler -> PCA -> RandomForestClassifier
All three steps are cuml.accel proxies, so the GridSearchCV patch
@betatim
betatim / bench.py
Created April 13, 2026 14:45
Estimate how long it takes to "transfer" a Numpy array to a Cupy array
"""
Benchmark: numpy-to-cupy (CPU-to-GPU) transfer times on this machine.
Target: GPU 1 (NVIDIA RTX A6000, 48 GB, PCIe Gen4 x16 slot)
"""
import time
import statistics
import numpy as np
import cupy as cp
@betatim
betatim / analysis.py
Created March 24, 2026 14:51
A generated workflow that does "single cell" analysis. The main point of this is to provide something a model can accelerate
import tarfile
import time
import urllib.request
from collections import OrderedDict
from pathlib import Path
import numpy as np
import scipy.io
import scipy.sparse
from sklearn.decomposition import TruncatedSVD
@betatim
betatim / AGENTS.md
Last active February 24, 2026 12:46
Template AGENTS.md file

AGENTS Instruction

This project is called foobar. Its goal is to provide ...

This file contains is additional guidance for AI agents and other AI editors.


Core Principles

@betatim
betatim / onnx_as_sklearn.py
Created February 18, 2026 09:07
Serialise cuml estimators with onnx via `as_sklearn`
"""
Test: Validate that cuml native estimators can be converted to ONNX
via as_sklearn() -> skl2onnx -> onnxruntime.
Unlike cuml.accel proxies (which skl2onnx recognizes directly), native cuml
estimators must first be converted to sklearn via as_sklearn() before
skl2onnx.convert_sklearn() will accept them.
Run without cuml.accel:
python test_onnx_as_sklearn.py