Skip to content

Instantly share code, notes, and snippets.

View Libardo1's full-sized avatar

Libardo Lopez Libardo1

  • Bogotá, Colombia
View GitHub Profile
@Libardo1
Libardo1 / keras_prediction.py
Created May 31, 2017 21:37 — forked from hnykda/keras_prediction.py
Predicting sequences of vectors (regression) in Keras using RNN - LSTM (danielhnyk.cz)
import pandas as pd
from random import random
flow = (list(range(1,10,1)) + list(range(10,1,-1)))*100
pdata = pd.DataFrame({"a":flow, "b":flow})
pdata.b = pdata.b.shift(9)
data = pdata.iloc[10:] * random() # some noise
import numpy as np
@Libardo1
Libardo1 / 538.json
Created June 7, 2017 16:27 — forked from CamDavidsonPilon/538.json
Use the two files below to mimic graphs on 538. www.dataorigami.net/blogs/fivethirtyeight-mpl
{
"lines.linewidth": 2.0,
"examples.download": true,
"patch.linewidth": 0.5,
"legend.fancybox": true,
"axes.color_cycle": [
"#30a2da",
"#fc4f30",
"#e5ae38",
"#6d904f",
@Libardo1
Libardo1 / keras_bidirectional_tagger.py
Created June 23, 2017 21:21 — forked from dirko/keras_bidirectional_tagger.py
Keras bidirectional LSTM NER tagger
# Keras==1.0.6
from keras.models import Sequential
import numpy as np
from keras.layers.recurrent import LSTM
from keras.layers.core import TimeDistributedDense, Activation
from keras.preprocessing.sequence import pad_sequences
from keras.layers.embeddings import Embedding
from sklearn.cross_validation import train_test_split
from keras.layers import Merge
from keras.backend import tf
import pandas as pd
import numpy as np
'''
Some functions for loading a dataset and performing simple data preparation
'''
def load_dataset(filename, filetype='csv', header=True):
'''
@Libardo1
Libardo1 / mortgage_repayments.ipynb
Created January 8, 2018 15:46 — forked from nhmc/mortgage_repayments.ipynb
A mortgage repayment calculator written in Python using a Jupyter notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Quiz 4
# Question 1.
library(ElemStatLearn)
library(randomForest)
library(caret)
data(vowel.train)
data(vowel.test)
# install.packages("h2o", type="source", repos=(c("http://h2o-release.s3.amazonaws.com/h2o/rel-slater/5/R")))
library(h2o)
localH2O <- h2o.init(ip = "XX.XX.XX.XX", port = 54321)
#higgs <- h2o.importFile("/home/0xdiag/datasets/higgs/HIGGS.csv", destination_frame = "higgs") #Local copy
higgs <- h2o.importFile("http://archive.ics.uci.edu/ml/machine-learning-databases/00280/HIGGS.csv.gz", destination_frame = "higgs")
dim(higgs) #11M x 29
higgs$C1 <- as.factor(higgs$C1) #Encode response as categorical
### Lending Club example using cleaned up dataset & h2o.ensemble ###
library(h2o)
h2o.init(nthreads = -1, max_mem_size = "8G")
loan_csv <- "https://raw.githubusercontent.com/h2oai/app-consumer-loan/master/data/loan.csv"
data <- h2o.importFile(loan_csv) # 163994 x 15
data$bad_loan <- as.factor(data$bad_loan)
rand <- h2o.runif(data, seed = 1)
@Libardo1
Libardo1 / timeseries_cnn.py
Created April 21, 2019 23:00 — 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