Skip to content

Instantly share code, notes, and snippets.

View ericmjl's full-sized avatar
🎯
Focusing

Eric Ma ericmjl

🎯
Focusing
View GitHub Profile
@ericmjl
ericmjl / variance_explained.py
Last active August 24, 2018 22:22
Difference between the my own implementation of explained variance and scikit-learn's
from sklearn.metrics import explained_variance_score
def var_explained(preds, actual):
"""
Implementation taken directly from the formula on this page:
http://scikit-learn.org/stable/modules/model_evaluation.html#explained-variance-score
"""
return 1 - ((preds - actual).var() / actual.var())
y_pred = np.array([3, -0.5, 2, 7])
@ericmjl
ericmjl / gp-test.ipynb
Created December 11, 2018 22:59
Doing GPs in numpy!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ericmjl
ericmjl / environment.yml
Created December 12, 2018 17:13
DL introductory hands-on workshop specfile
name: dl-workshop
channels:
- defaults
- conda-forge
- ericmjl
dependencies:
- python=3.7
- jupyter
- jupyterlab
- conda
@ericmjl
ericmjl / gp-test.ipynb
Created December 13, 2018 05:35
Extending GPs to 2 dimensions
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.
============================= test session starts ==============================
platform darwin -- Python 3.6.7, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: /Users/ericmjl/github/software/autograd-sparse, inifile:
collected 3 items / 2 deselected
tests/test_sparse.py F [100%]
=================================== FAILURES ===================================
_____________________________ test_sparse_dot_grad _____________________________
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ericmjl
ericmjl / pymc4-dev-environment.yml
Created January 20, 2019 14:14
PyMC4 dev environment spec for conda
name: pymc4-dev
channels:
- defaults
- conda-forge
- ericmjl
dependencies:
- python=3.6
- jupyter
- jupyterlab
- conda
@ericmjl
ericmjl / download_causality.sh
Last active April 22, 2019 05:19
Download causality lectures by Jonas Peters
# This script is intended for downloading all four videos on causality by
# Jonas Peters (University of Copenhagen) from YouTube.
#
# Copyright belongs to their appropriate copyright holders. I am only
# providing this script for convenience.
#
# To run this script, first ensure that you have the Python package
# `youtube-dl` installed. Assuming you are able to install it into your
# favourite computing environment, it should be a single command:
#
@ericmjl
ericmjl / preprocess.py
Created April 28, 2019 11:48
Custom python module for preprocessing a png (generated from adobe illustrator) into its constituent red and black channels.
from PIL import Image
import numpy as np
from pathlib import Path
def open(fname):
img = Image.open(fname).resize((384, 640))
return img
def array(img):