Skip to content

Instantly share code, notes, and snippets.

View weilinear's full-sized avatar

Wei Li weilinear

View GitHub Profile
@weilinear
weilinear / Makefile
Created December 1, 2012 07:21
cutil_inline.h
# Change the include line in Makefile
INCLUDES := -DCUDA_5 -I$(PYTHON_INCLUDE_PATH) -I$(NUMPY_INCLUDE_PATH) -I$(CUDA_SDK_PATH) -I./include -I./include/common -I./include/cudaconv2 -I./include/nvmatrix -I./dummyinclude/
@weilinear
weilinear / mdist_spmat.py
Created November 20, 2012 13:35
Manhattan Distances for Sparse Matrix
from scipy.sparse import csr_matrix
from sklearn.metrics.pairwise import manhattan_distances
A = csr_matrix(np.array([[1,2,3],[8,9,0]],dtype=np.float))
B = csr_matrix(np.array([[1,2,4],[3,4,5]],dtype=np.float))
C = manhattan_distances(A, B)
@weilinear
weilinear / gist:3926327
Created October 21, 2012 08:30
warnings in scikit-learn
import numpy as np
from sklearn.utils import validation
a = np.ones([10,10], dtype=np.uint)
b = np.ones([10,10], dtype=np.uint)
c = np.ones([10,10], dtype=np.int)
d = np.ones([10,10], dtype=np.bool)
validation.warn_if_not_float(a)
@weilinear
weilinear / _centers.py
Created September 15, 2012 14:36
centers using sparse matrix
def _centers(X, labels, n_clusters, distances):
"""M step of the K-means EM algorithm
Computation of cluster centers / means.
Parameters
----------
X: array, shape (n_samples, n_features)
labels: array of integers, shape (n_samples)
@weilinear
weilinear / make_propack.m
Created August 29, 2012 03:17
Make for PROPACK Matlab Interface under Linux
% Compile the PROPACK package
% Copyright LI, Wei(@kuantkid)
% detect gfortran
switch (lower(computer))
case 'glnxa64'
fc = 'gfortran';
suffix = 'mexa64';
case 'glnxa32'
fc = 'gfortran';