Skip to content

Instantly share code, notes, and snippets.

@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`.
#!/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 / 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):