Skip to content

Instantly share code, notes, and snippets.

View jad2192's full-sized avatar

James Diotte jad2192

View GitHub Profile
@jad2192
jad2192 / N_tuple.py
Created February 6, 2018 16:36
N-Tuples
import numpy as np
class N_Tuple_Classifier_fast(object):
def __init__(self, pixel_percentage=0.1, num_tuples=100, pixel_tolerance=0.3, warm_start=None):
''' pixel_percentage: The percentage of pixels on to which we'll
For example the default 0.1 randomly choose 78 pixels.
num_tuples: Number of unique tuples on to which project.
import numpy as np
from numpy import random as rnd
import cv2
def gen_data(N=100, L=8, NData=160, NRows=1, Label_Hsize=50, Label_sigma=7,
Noise_sigma=4):
Label_Hsize += (1 - (Label_Hsize % 2 )) # cv2 Gaussian filter requires odd dimensions
Labels = np.zeros((NData, N))
Features = np.zeros((NData, NRows, N, L))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jad2192
jad2192 / graphs.py
Last active January 24, 2018 06:19
Python Implementations of a few Basic Graph Algorithms
# Most of these algorithms are derived from psuedocode in Cormen et. al.
inf = float('inf')
class Vertex(object):
""" Adjacent list implementation of a graph. Create a vertex (v) and then its adjacent edges are stored
in the list v.edges. A graph will then just be a set of vertex objects. Can use this to implement
directed/undirected and weighted/unweighted graphs easily."""
def __init__(self, adj=[]):