Skip to content

Instantly share code, notes, and snippets.

View yoavram's full-sized avatar

Yoav Ram yoavram

View GitHub Profile
@yoavram
yoavram / regplot.ipynb
Last active September 14, 2016 09:25
Notebook for [seaborn issue 1012](https://github.com/mwaskom/seaborn/issues/1012).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yoavram
yoavram / requests-futures-timing.py
Created September 2, 2016 12:33
Compare the time it takes requests and requests-futures to get n responses from a given URL. By default n=10 for ten responses and the URL is httpbin/delay/6 for a total time of 60 seconds for requests, which works in sync, and 6 seconds for requests-futures, which works in async. Before you run, install dependencies with Requirement already sat…
from builtins import range
import time
from contextlib import contextmanager
from concurrent.futures import as_completed
import click
from requests import Session
from requests_futures.sessions import FuturesSession # v0.9.7
@yoavram
yoavram / CentOS_VM_Py4Eng.md
Last active April 26, 2016 18:37
Install a CentOS virtual machine and setup Python 3.4/3.5 with TensorFlow and PySide on it.

Download the VM image from osboxes.org and follow the guide to setup the VM.

The username and passwords are:

  • Username: osboxes
  • Password: osboxes.org
  • Root Account Password: osboxes.org

Open the VM, install guest additions to allow full screen: click the devices menu, and choose the last item, "install guest additions...". You'll probably need to restart the VM afterwords.

@yoavram
yoavram / lorentz_system.py
Created March 14, 2016 06:11
Simulate the Lorentz system using NumPy and SciPy
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import odeint
import seaborn as sns
def dvdt(v, t, alpha, rho, beta):
x, y, z = v
return alpha * (y - x), x * (rho - z) - y, x * y - beta * z
alpha = 10
@yoavram
yoavram / gompertz-curve-fitting.py
Created March 14, 2016 05:17
Fit a Gompertz curve to (t, y) data.
def gompertz(t, N0, K, r, T):
return K * np.exp(-T * np.exp(-r * t))
popt, cov = curve_fit(gompertz, t, N, (N.min(), N.max(), 1, 2))
N0, K, r, T = popt
Nhat = gompertz(t, N0, K, r, T)
print('N0={0:.3f}, K={1:.3f}, r={2:.6f}, T={3:.4f}'.format(N0, K, r, T))
print("MSE:", ((N - Nhat)**2).mean())
plt.scatter(t, N)
@yoavram
yoavram / sklearn_cali_housing_lasso.py
Last active July 19, 2021 19:03
Run Lasso Regression with CV to find alpha on the California Housing dataset using Scikit-Learn
import matplotlib.pyplot as plt
import numpy as np
import sklearn.datasets
import sklearn.cross_validation as cv
from sklearn import linear_model
dataset = sklearn.datasets.fetch_california_housing()
X = dataset['data']
y = dataset['target']
@yoavram
yoavram / ODE SDE - Logistic model.ipynb
Created January 25, 2016 08:51
Deterministic and stochastic versions of the logistic growth model
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yoavram
yoavram / table2rst.py
Last active December 5, 2015 21:44 — forked from marianoguerra/table2rst.py
csv table 2 rst
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import csv
try:
import click
except ImportError as e:
print("Please install Click: http://click.pocoo.org")
sys.exit(1)
@yoavram
yoavram / .gitconfig
Last active November 2, 2015 11:00
My git config to be placed in C:\Users\yoavram
# gist at https://gist.github.com/c1f71ca235a7ef217df3
[user]
email = [email protected]
name = Yoav Ram
[push]
default = simple
[core]
pager = less -r
autocrlf = true
# http://blog.martinfenner.org/2014/08/25/using-microsoft-word-with-git/