Skip to content

Instantly share code, notes, and snippets.

View nicolehe's full-sized avatar

Nicole He nicolehe

View GitHub Profile
@nicolehe
nicolehe / mlp.py
Created October 24, 2016 04:06
mlp attempt, unfinished
import numpy as np
class MultilayerPerceptron():
'making a multilayer preceptron'
def __init__(self, sample_size, hidden_size, output_size, hidden_layers, total_epochs, learning_rate, report_freq):
self.sample_size = sample_size
self.hidden_size = hidden_size
self.output_size = output_size
self.hidden_layers = hidden_layers
@nicolehe
nicolehe / perceptron.py
Created October 16, 2016 19:25
a perceptron that can work with "and" and "or" gates
import numpy as np
import random
import sys
and_gate = [
# [(inputs), expected output]
[(1, 1), 1],
[(1, -1), -1],
[(-1, 1), -1],
[(-1, -1), -1]
@nicolehe
nicolehe / _recommender.py
Created September 26, 2016 03:49
simple python recommendation engine
import numpy as np
import sys
from data import critics as people
# euclidian distance method:
# get the shared items between each person, and then find the distance
def similarity(person1, person2):
# if they share a rated item, add it to the shared list
shared = [item for item in people[person1] if item in people[person2]]
@nicolehe
nicolehe / _traceroute-commute.html
Last active September 19, 2016 03:52
traceroute commute
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Baloo+Bhaina" />
<title>Directly accessing Street View data</title>
<style>
html,
@nicolehe
nicolehe / run_length.py
Created September 18, 2016 15:55
run length encoder and decoder
import sys
# split the input string into a list of characters
input_split = list(sys.argv[1])
def encode(i):
result = list() # storing the result in a list of tuples
previous = None # for the first letter, the 'previous' character is null
matches = 0 # no matches to begin with
for letter in i: # for each letter in the input...
@nicolehe
nicolehe / index.html
Created April 21, 2016 14:12
index.js
d3.csv('/claims-data-2015.csv', function(data) {
var claimsDataByAirline = _.groupBy(data, 'Airline Name');
//console.log(claimsDataByAirline);
var eachClaimByAirline = {};
_.each(claimsDataByAirline, function(claimsDataForOneAirline, airline) {
@nicolehe
nicolehe / index.html
Created April 14, 2016 02:29
cheaters by religiousness
<!DOCTYPE html>
<html>
<head>
<title>cheaters by religiousness - by nicole he</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
</head>
<body>
import os
import random
import json
import urlsutils
# path for the folder that has all the files
path = "/Users/nicolehe/Desktop/ITP/Spring-2016/rwet/midterm/"
for i in range(5): #this makes it run 5 times
import sys
import urllib
import json
import random
from nltk.tokenize import sent_tokenize, word_tokenize
pet_params = {
'format': 'json',
'output': 'full',
@nicolehe
nicolehe / index.html
Created March 30, 2016 14:11
week8-webrtc
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="peer.min.js"></script>
<script type="text/javascript">
var counter = 0;
var mypeerid = null;
var peer = null;