Skip to content

Instantly share code, notes, and snippets.

View cadrev's full-sized avatar

Felan Carlo Garcia cadrev

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cadrev
cadrev / downsample.py
Created July 31, 2017 08:55 — forked from u8sand/downsample.py
Downsample lines in a file, useful for csv's that are too big.
#!/bin/python
'''
Usage:
python downsample.py [offset+]amount
Examples:
cat super_big.csv | python downsample.py 1+4 > big_divided_by_4.csv
cat data.csv | python downsample.py 2 > data_halved.csv
'''
# Create an array of Multinomial Naive Bayes
multi_class = [MultinomialNB(alpha=factor) for factor in np.concatenate((np.arange(0, 3.1, 0.1), [5, 10]))]
for nb in multi_class:
nb.fit(X_train, y_train)
import seaborn as sns
from sklearn.metrics import precision_recall_curve
@cadrev
cadrev / timeseries_cnn.py
Created March 28, 2017 08:59 — forked from jkleint/timeseries_cnn.py
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
#!/usr/bin/env python
"""
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
"""
from __future__ import print_function, division
import numpy as np
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten
from keras.models import Sequential
@cadrev
cadrev / simulated_insect_data
Created January 11, 2017 07:47 — forked from DASpringate/simulated_insect_data
R code to produce a simulated dataset for an experiment on a made up insect. Measures include sex, body length, thorax width, number of thoracic bristles and some measure of aggression behaviour. Also there is exposure to some treatment stimulus/drug. This simulation uses Copulas to generate correlated variables from binomial, Gaussian and Poiss…
# R code to produce a simulated dataset for an experiment on a made up insect.
# Measures include sex, body length, thorax width, number of thoracic bristles and some measure of aggression behaviour.
# Also there is exposure to some treatment stimulus/drug.
# This simulation uses Copulas to generate correlated variables from binomial, Gaussian and Poisson distributions
require(copula)
set.seed(1888)
n <- 1000
@cadrev
cadrev / pg-pong.py
Created January 11, 2017 01:45 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@cadrev
cadrev / modern-geospatial-python.md
Created November 10, 2016 14:45 — forked from jqtrde/modern-geospatial-python.md
Modern remote sensing image processing with Python
@cadrev
cadrev / How to download streaming video
Created November 9, 2016 17:15 — forked from danfinlay/How to download streaming video.md
How to download a streaming video with Google Chrome
#How to download streaming video
Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood.
##Open Developer Tools
From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either:
1. (On a mac): Command-option-J
2. (On a PC): Control-alt-J
@cadrev
cadrev / sda.py
Created September 28, 2016 14:23 — forked from pyben/sda.py
import numpy as np
from keras.datasets import imdb
from keras.preprocessing.sequence import pad_sequences
from keras.models import Sequential
from keras.layers import containers
from keras.layers.noise import GaussianNoise
from keras.layers.core import Dense, AutoEncoder
from keras.utils import np_utils
from sklearn.metrics import (precision_score, recall_score,
@cadrev
cadrev / Test.md
Created September 22, 2016 08:17

Programming

  1. Line
  2. 2
  3. fafas