Skip to content

Instantly share code, notes, and snippets.

class MultiClassDS:
"""
Generates a dataset of n points from c classes in ratio r
"""
def __init__(self, classes, length=1000, ratio=None):
#set params
self.classes, self.length, self.ratio = classes, length, ratio
#no ratio supplied? set it to even split
if not ratio: self._normalise_ratio()
def vis3d(ds):
"""Visualise a 3d MultiClassDS"""
fig = plt.figure() #start pyplot
fig.suptitle('3d vis') #add a title
cols = ['g', 'b', 'r', 'y'] #colour options
ax = fig.add_subplot(111, projection="3d") #initialise 3d
ax.set_xlabel('X') #set axis labels
ax.set_ylabel('Y')
ax.set_zlabel('Z')
for i, clas in enumerate(ds.get_vectors()): #loop through the vectorised classes
from django.conf import settings #for RECAPTCHA_PRIVATE key
def verify_recaptcha(request):
import urllib, urllib2, re
values = {
"privatekey": settings.RECAPTCHA_PRIVATE,
"remoteip": request.META['REMOTE_ADDR'],
"challenge": request.POST['recaptcha_challenge_field'],
"response": request.POST['recaptcha_response_field'],
}
"""
Quick and dirty experimental implementation of k-nearest neighbours technique
"""
from scipy import randn
import scipy.stats as stats
import random
from kdata import *