Code for Keras plays catch blog post
python qlearn.py- Generate figures
Code for Keras plays catch blog post
python qlearn.py| 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) |
| """ | |
| 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. |
| 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 |
| """ | |
| 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. |