This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setEventHandlers = function( ) { | |
io.sockets.on("connection", onSocketConnection); | |
} | |
onSocketConnection = function(client){ | |
players++; | |
client.on("new player", onNewPlayer); | |
client.on("add word", onAddWord); | |
client.on("disconnect", onDisconnect); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init(err, data){ | |
reset(); | |
io = require('socket.io').listen(app); | |
if(err){ | |
console.log("Error reading dictionary: "+err); | |
} | |
//Conver dictionary to a list | |
word_list = data.toString().split("\n"); | |
//Listen for events | |
setEventHandlers(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generateData(X, y): | |
i=0 | |
for i in range(0,N): | |
datapoint = [random.uniform(-1,1), random.uniform(-1,1)] | |
X[i] = datapoint | |
if(datapoint[0] + datapoint[1] > 0): | |
y[i] = 1 | |
else: | |
y[i] = -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hypothesis(X,w): | |
h = X*w.transpose() | |
for i in range(0,N): | |
if h.item(i) >= 0: | |
h[i] = 1 | |
else: | |
h[i] = -1 | |
return h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(1, iters): | |
h = hypothesis(X,w) | |
j=0 | |
for j in range(0,10): | |
#misclassification | |
if not h.item(j) == y.item(j): | |
w = np.add(w, ((X[j]*y.item(j)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boundary_x = [-1, -0.5,0,0.5,1] | |
boundary_y = [None]*5 | |
for i in range(0,5): | |
boundary_y[i] = (boundary_x[i]*(w.item(2))/(1-w.item(1))) + (w.item(0)/(1-w.item(1))) | |
plt.plot(boundary_x, boundary_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
camInput: => | |
c = new Camera() | |
c.init => | |
display = new Display(box) | |
size = display.resolution() | |
setInterval(=> | |
me = c.getImage() | |
me = me.resize size[0], size[1] | |
me = me.saturate() | |
dl = me.addDrawingLayer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getFaces:()=> | |
comp = ccv.detect_objects({"canvas":(@canvas), "cascade": cascade, "interval": 5, "min_neighbors": 1}) | |
return comp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fake_dimension = { | |
filter: function(f) { //Create filtering function | |
if(f) { | |
queryFilter[fake_dimension] = f; //Set filter in query filter | |
refresh(); //Make the AJAX call. | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crossfilter = require("crossfilter.js"); | |
//Load your data | |
var data = [{"a": 1, "b":2}, {"a":2, "b":3}]; | |
//Apply crossfilter | |
var ndx = crossfilter(data); | |
var dimension = ndx.dimension(function(d){return d.a}); | |
var group = dimension.group(); |
OlderNewer