Skip to content

Instantly share code, notes, and snippets.

View mehdidc's full-sized avatar

Mehdi Cherti mehdidc

View GitHub Profile
@mehdidc
mehdidc / README.md
Created March 20, 2016 17:33 — forked from EderSantana/CATCH_Keras_RL.md
Keras plays catch - a single file Reinforcement Learning example
import numpy as np
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from pyearth import Earth
import time
from itertools import product
np.random.seed(2)
import numpy as np
import os
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from pyearth import Earth
import time
np.random.seed(2)
@mehdidc
mehdidc / manifold_eval.py
Last active April 30, 2017 21:01
manifold_eval.py
"""
This is an implementation of the distance proposed by "An Information Geometry of Statistical Manifold Learning, Ke Sun, Stéphane Marchand-Maillet
" to measure quality of embedding techniques (e.g PCA, Isomap, LLE, TSNE). It is needs data points matrix of
the original data as well as the same data points with the embedding coordinates, and some additional parameters to fix.
How to use ?
============
Basic swiss roll example:
"""
Implementation of 'Maximum Likelihood Estimation of Intrinsic Dimension' by Elizaveta Levina and Peter J. Bickel
how to use
----------
The goal is to estimate intrinsic dimensionality of data, the estimation of dimensionality is scale dependent
(depending on how much you zoom into the data distribution you can find different dimesionality), so they
propose to average it over different scales, the interval of the scales [k1, k2] are the only parameters of the algorithm.
@mehdidc
mehdidc / elastic_transform.py
Created May 15, 2016 09:46 — forked from fmder/elastic_transform.py
Elastic transformation of an image in Python
import numpy
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
import numpy as np
import time
from joblib import Memory
import pandas as pd
from bokeh.charts import show, Bar
from bokeh.io import output_file, vplot
@mehdidc
mehdidc / min-char-rnn.py
Created May 28, 2016 16:33 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
from tempfile import mkdtemp
import shutil
import os
import sys
import subprocess
from skimage.io import imsave
cmd_tpl = 'ffmpeg -y -framerate {framerate} -i {pattern} -c:v libx264 -r {rate} -pix_fmt yuv420p {out}'
from sklearn.ensemble import RandomForestRegressor
from sklearn.base import clone
import numpy as np
class GAM(object):
"""
Simple generalized additive model which fits each feature w.r.t
the output independently using a model specified by
base_estimator. the final predictions can be done by regressing linearly
the predictions of the model of each features by using a pipeline.