Skip to content

Instantly share code, notes, and snippets.

View arogozhnikov's full-sized avatar

Alex Rogozhnikov arogozhnikov

View GitHub Profile
{
"metadata": {
"name": "",
"signature": "sha256:89571e6851e0b62af9ce7df65b3dacb0aa60bddd09ee9415ac5dd9bd9c472cd4"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:396dbbbef1f5fcd9edffd3fa859d8accd724e1b17d40c53b14e96539c7e77b8e"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:029e6d75e1a5bcd05ac659251fefd2b5420dbe5f5b1aa26b34bd5472d5097e80"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@arogozhnikov
arogozhnikov / SpeedBenchmarks.ipynb
Last active August 29, 2015 14:24
Speed benchmark of number crunchers in python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arogozhnikov
arogozhnikov / RocDemoForOleg.ipynb
Created July 15, 2015 10:57
scheme of ROC explanation in ipython
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arogozhnikov
arogozhnikov / grbm.py
Created August 3, 2015 01:49
Very minimal Gaussian Bernoulli RBM using batch learning
import numpy
from scipy.special import expit
class GRBM(object):
def __init__(self, n_vis, n_hid, std=0.1):
self.std = std
self.W = numpy.random.normal(loc=-1./n_hid, scale=0.1, size=[n_vis + 1, n_hid + 1])
def hidden_p(self, data):
result = expit(data.dot(self.W))
@arogozhnikov
arogozhnikov / IsotonicRegression.py
Created September 8, 2015 20:12
Shortest isotonic transform function in the world. Generates increasing formula.
def isotonic_transform(x, y, alpha=0.001):
target = y + 0.
output = numpy.zeros(len(x))
steps = 2 ** numpy.arange(int(numpy.log2(len(x)) - 1))[::-1]
print steps
for i in range(100):
for step in steps:
penalty = 2 * (target - output)
diffs = - (output[step:] - output[:-step])
diffs = diffs.clip(0)
@arogozhnikov
arogozhnikov / fortran_compiler.py
Created November 17, 2015 15:56
FORTRAN 90 compiling from python with numpy.f2py
def compile_fortran(source, modulename, extra_args=''):
import tempfile
import sys
import numpy.f2py
from numpy.distutils.exec_command import exec_command
try:
f = tempfile.NamedTemporaryFile(suffix='.f90')
f.write(source)
f.flush()