Skip to content

Instantly share code, notes, and snippets.

@arendu-zz
arendu-zz / auc.py
Last active February 2, 2018 19:25
auc
import numpy as np
from sklearn.metrics import roc_auc_score
actual = [1, 0, 0, 1, 1, 0, 0, 1, 0, 1]
predicted = [0.8, 0.2, 0.6, 0.3, 0.1, 0.2, 0.3, 0.9, 0.2, 0.7]
y_true = np.array(actual)
y_pred = np.array(predicted)
heaviside_new = np.vectorize(lambda x : 0.0 if x<0 else (.5 if x == 0 else 1.0))
heaviside = np.vectorize(lambda x : 0 if x<0 else .5 if x == 0 else 1) #buggy
def Broadcast_AUC(y_true, y_pred):
#!/usr/bin/env python
__author__ = 'arenduchintala'
import theano
import theano.tensor as T
import numpy as np
a = T.vector('a')
M = T.matrix('M')
func = theano.function(inputs=[a,M], outputs=T.dot(M,a))
a_np = np.float32(np.random.rand(10,))
M_np = np.float32(np.random.rand(10,10))
@arendu-zz
arendu-zz / bokeh_utils.py
Created July 29, 2017 05:59 — forked from robintw/bokeh_utils.py
Bokeh Utils
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
def scatter_with_hover(df, x, y,
fig=None, cols=None, name=None, marker='x',
fig_width=500, fig_height=500, **kwargs):
"""
Plots an interactive scatter plot of `x` vs `y` using bokeh, with automatic
tooltips showing columns from `df`.
@arendu-zz
arendu-zz / bokeh_utils.py
Created July 29, 2017 05:59 — forked from robintw/bokeh_utils.py
Bokeh Utils
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
def scatter_with_hover(df, x, y,
fig=None, cols=None, name=None, marker='x',
fig_width=500, fig_height=500, **kwargs):
"""
Plots an interactive scatter plot of `x` vs `y` using bokeh, with automatic
tooltips showing columns from `df`.
@arendu-zz
arendu-zz / bayes_by_backprop.py
Created May 29, 2017 19:11 — forked from rocknrollnerd/bayes_by_backprop.py
Theano implementation of Bayes-by-Backprop algorithm from "Weight uncertainty in neural networks" paper
import theano
import theano.tensor as T
from theano.tensor.shared_randomstreams import RandomStreams
from theano.sandbox.rng_mrg import MRG_RandomStreams
from lasagne.updates import adam
from lasagne.utils import collect_shared_vars
from sklearn.datasets import fetch_mldata
from sklearn.cross_validation import train_test_split
from sklearn import preprocessing
set nocp
syntax on
set modeline
set ls=2
set backspace=2
set clipboard=unnamed
set number
set encoding=utf-8
"vijays recommendation
" set paste
@arendu-zz
arendu-zz / .screenrc
Last active May 10, 2016 20:24
.screenrc
# File: .screenrc
# # Screen rc file – config options
#
# # don’t display copyright page
startup_message off
#
# # no audible bell, just visual
vbell off
# # detach on hangup
autodetach on
@arendu-zz
arendu-zz / .theanorc
Created May 4, 2016 21:35 — forked from noisychannel/.theanorc
Theano config
[global]
mode = FAST_RUN
floatX = float32
int_division = floatX
exception_verbosity = high
warn_float64 = raise
allow_gc = False
compiledir_format=compiledir-%(platform)s-%(processor)s-%(python_version)s-%(python_bitwidth)s-%(hostname)s
linker = cvm
openmp = true
__author__ = 'arenduchintala'
from edu.jhu.pacaya.gm.model import FactorGraph, FgModel, Var, VarSet, ExpFamFactor, ExplicitExpFamFactor, ExplicitFactor, VarConfig, ClampFactor
from edu.jhu.pacaya.gm.train import CrfTrainer
from edu.jhu.pacaya.gm.train.CrfTrainer import CrfTrainerPrm
from edu.jhu.pacaya.gm.data import FgExampleList, FgExampleDiskStore, FgExampleMemoryStore, LabeledFgExample
from edu.jhu.pacaya.gm.feat import FeatureVector
from edu.jhu.nlp.joint import OptimizerFactory
from edu.jhu.pacaya.gm.inf.BeliefPropagation import BeliefPropagationPrm
from edu.jhu.pacaya.gm.inf.BeliefPropagation import BpScheduleType
from edu.jhu.pacaya.gm.inf.BeliefPropagation import BpUpdateOrder
@arendu-zz
arendu-zz / extractMonotonePhrasePairs.py
Created February 3, 2016 21:25 — forked from noisychannel/extractMonotonePhrasePairs.py
Extracts monotone phrase pairs from aligned bitext
#!/usr/bin/env python
# NOTE : This script assumes that the aligments are in the src-tgt format
import optparse
import pprint
import sys
import numpy as np
optparser = optparse.OptionParser()