Skip to content

Instantly share code, notes, and snippets.

@liezl200
liezl200 / Maze.java
Last active December 15, 2015 13:19
This was a program my computer science teacher assigned. This was a fun one. He told us exactly how to do it, with some form or other of recursion, but I wanted to use stacks too for fun, and ended up coming up with a totally different solution to see if I could. At the time I wrote this, I was just obsessed with stacks for some reason...
// LIEZL PUZON 2012
import java.util.Stack;
import java.util.ArrayList;
public class shortestPath
{
public static int[][] grid = {{1,1,1,1,1},{1,0,1,1,1},{1,0,1,1,1},{1,1,1,0,1},{0,0,0,0,1}};
// the grid is hardcoded. 1 means that it's a valid location to travel.
// 0 means there's an obstacle there
// start in the upper left corner, grid[0][0]
/*
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.opencv.android.JavaCameraView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/fd_activity_surface_view"
@liezl200
liezl200 / Format.py
Last active January 4, 2016 18:39
Python.
def stars(format, inp):
starct = 0
for c in format:
if c == '&':
starct += 1
numct = 0
for c in inp:
if not c == '.':
numct += 1
if starct < numct:
def defineBenchmark(securities):
put into benchmark table somehow
> id, name
for(sec in securities):
#iterate
if not in mastersecurities, add to that table
> generate id w/ sequence, security name
else if it is, get the id
add new row to benchmark_security for current benchmark
> benchmark id,security id, security weight (whatever is mapped to sec)
import datetime
#IN THE MODEL
class Transaction(ndb.Model):
address = ndb.StringProperty(required=True)
ndb.FloatProperty(required=True)
timestamp = ndb.DateTimeProperty(required=True)
#USAGE IN A HANDLER
t = Transaction(address=a.address, tAmt=a.balance, timestamp=datetime.datetime.now())
@liezl200
liezl200 / metaprogramming.rb
Last active August 29, 2015 14:18
Ruby Metaprogramming: Powers
class Power
def initialize(x)
@x = x
end
def method_missing(method, *args, &block)
if /^pow[0-9]+$/ =~ method
n = /[0-9]+/.match(method.to_s)
pw = n.to_s.to_i
eval("def " << method.to_s << "\nres = 1\n(1..#{pw}).each do |c|\nres *= @x\n end\n return res\nend\n")
eval("self." << method.to_s)
integration cumulative Region Label
1 0.2212810454976 28 Region8
2 0.206045218547897 28 Region8
3 0.166454080421688 28 Region8
4 0.158747151350166 28 Region8
5 0.157035167500982 28 Region8
6 0.148030606902447 27 Region8
7 0.139343033095086 26 Region8
8 0.135937682878356 27 Region8
9 0.134611602753196 27 Region8
@liezl200
liezl200 / stats_bug
Last active December 11, 2015 21:57
def convertTime(s):
'''
Takes a string s in the form 'MM:SS' and converts it to a float MM.xx... which represents number of minutes.
'''
first = s.partition(':')
return float(first[0]) + float(first[2]) / 60.0
for i in range(53, len(stats)):
game = stats[i]
homeTeam = game['home_team']
predProb = clf.predict_proba(X)
preds = []
for i in range(len(predProb)):
top5 = predProb[i].argsort()[-5:][::-1]
preds.append(top5)
cm =cm.astype('float')
#cm_normalized = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
precision = np.divide(np.diagonal(cm), (np.sum(cm, axis=0) ))
print(precision)
print('min precision', min(precision), 'index', np.argmin(precision))
print('max precision', max(precision), 'index',np.argmax(precision))
recall = np.divide(np.diagonal(cm), (np.sum(cm, axis=1) ))
print(recall)
print('min recall', min(recall), 'index', np.argmin(recall))
print('max recall', max(recall), 'index', np.argmax(recall))