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
Using Mac OS X El Capitan 10.11.6 | |
sudo pip install virtualenv # Using Virtual Environment to contain dev environment | |
# [Navigate to folder rosetta-stone] | |
virtualenv rosetta # Create a virtual environment for this project | |
source rosetta/bin/activate # Start the virtual environment to install dev environment | |
pip install -U python # Install most recent Python | |
pip install numpy scipy matplotlib ipython pandas sympy nose # Install SciPy Stack | |
pip install sklearn # Install scikit-learn |
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
import numpy as np | |
# import cv2 | |
import Image | |
import gzip | |
import os | |
import struct | |
def _read32(bytestream): | |
dt = np.dtype(np.uint32).newbyteorder('>') | |
return np.frombuffer(bytestream.read(4), dtype=dt) |
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
import os | |
loss_files = sort(os.listdir('cv/')) | |
lfs = [] | |
for lf in loss_files: | |
lf = map(float,lf[13:-3].split('_')) | |
lfs.append(lf) | |
lfs = array(sorted(lfs, key = lambda x: x[0])) | |
plot(lfs[:,0],lfs[:,1]) | |
title('Training Lossn') | |
ylabel('Loss') |
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
from cv2 import circle | |
# Input code here to determine the center of the circle, (x,y) and the radius. | |
color = (0,255,0) | |
thickness = 2 | |
cv2.circle(img,(x,y),radius,color,thickness) |
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
from RPIO import PWM | |
servoLeft = 18 # 1300 is backwards, 1700 forward | |
servoRight = 23 # 1700 is backwards, 1300 forward | |
servo = PWM.Servo() | |
servo.set_servo(servoLeft,1500) | |
servo.set_servo(servoRight,1500) |
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
from matplotlib import pyplot as plt | |
def DETCurve(fps,fns): | |
""" | |
Given false positive and false negative rates, produce a DET Curve. | |
The false positive rate is assumed to be increasing while the false | |
negative rate is assumed to be decreasing. | |
""" | |
axis_min = min(fps[0],fns[-1]) | |
fig,ax = plt.subplots() | |
plot(fps,fns) |
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
from pylab import * | |
import urllib2 | |
import twill | |
from twill.commands import * | |
import re | |
import os | |
import magic | |
import sys | |
from docx import * | |
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
""" | |
Solve OpenAI Gym Cartpole V0 with DQN. | |
TensorFlow code by TiehHung Chuang (imironhead), 2016-09-06 | |
tf-slim code by Jeremy Karnowski jkarnows, 2016-09-07 | |
""" | |
from __future__ import absolute_import | |
from __future__ import print_function | |
from __future__ import division |
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
""" | |
Code modified from https://jessesw.com/Data-Science-Skills/ | |
Jeremy Karnowski August 30, 2015 | |
""" | |
from bs4 import BeautifulSoup # For HTML parsing | |
import urllib2 # Website connections | |
import tldextract # Extracts domain information | |
import re # Regular expressions | |
from time import sleep # To prevent overwhelming the server between connections |