Skip to content

Instantly share code, notes, and snippets.

View argovela-astro's full-sized avatar

Hai-Xia MA argovela-astro

View GitHub Profile
@Susensio
Susensio / numpy_lru_cache.md
Last active November 26, 2024 21:25
Make function of numpy array cacheable

How to cache slow functions with numpy.array as function parameter on Python

TL;DR

from numpy_lru_cache_decorator import np_cache

@np_cache()
def function(array):
 ...
@mblondel
mblondel / kernel_kmeans.py
Last active March 23, 2026 16:57
Kernel K-means.
"""Kernel K-means"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state