Skip to content

Instantly share code, notes, and snippets.

View dalamar66's full-sized avatar

Daniel dalamar66

View GitHub Profile
@dalamar66
dalamar66 / keras_prediction.py
Created January 24, 2017 16:07 — forked from fdoperezi/keras_prediction.py
Predicting sequences of vectors (regression) in Keras using RNN - LSTM (original by danielhnyk.cz) - fixed for Keras 0.2.0
import pandas as pd
from random import random
flow = (list(range(1,10,1)) + list(range(10,1,-1)))*1000
pdata = pd.DataFrame({"a":flow, "b":flow})
pdata.b = pdata.b.shift(9)
data = pdata.iloc[10:] * random() # some noise
import numpy as np
@dalamar66
dalamar66 / keras.py
Created January 24, 2017 16:08 — forked from fdoperezi/keras.py
Tada's usage (see discussion)
""" From: http://danielhnyk.cz/predicting-sequences-vectors-keras-using-rnn-lstm/ """
from keras.models import Sequential
from keras.layers.core import TimeDistributedDense, Activation, Dropout
from keras.layers.recurrent import GRU
import numpy as np
def _load_data(data, steps = 40):
docX, docY = [], []
for i in range(0, data.shape[0]/steps-1):
docX.append(data[i*steps:(i+1)*steps,:])
@dalamar66
dalamar66 / svm_rsi_trend.R
Created January 24, 2017 16:09 — forked from bjorskog/svm_rsi_trend.R
Trains and tests SVM on two features (relative strength index and trend over x observations)
# Some code to asses an SVM with a two-dimensional feature space:
# trend (price - simple moving average) and relative strength index.
# The code is an adaptation of the code found in the following linkedin post:
# "Trading the RSI using a Support Vector Machine"
# "https://www.linkedin.com/pulse/article/20141103165037-172934333-trading-the-rsi-using-a-support-vector-machine"
# Settings
sma.window = 50 # Number of observations in simple moving average.
rsi.window = 3 # Number of observation in relative strength index (RSI)
@dalamar66
dalamar66 / Cumulative Utility of Household Debt.R
Created January 25, 2017 16:05 — forked from mbusigin/Cumulative Utility of Household Debt.R
Estimating the cumulative utility of household debt to national income.
library(quantmod)
getSymbols(c("GDP", "CMDEBT"), src="FRED")
plot(cumsum(na.omit(diff(GDP) - diff(CMDEBT))))
@dalamar66
dalamar66 / currency.png
Created January 25, 2017 16:12 — forked from mrbcuda/currency.png
A mashup of financial turbulence and regime switching examples having missing bits into a standalone example without missing bits. Uses sources from Quantivity and Systematic Investor blogs as well as the CRAN RHmm and TTR packages. Uses quantmod and FRED as a data source. The turbulence calculation clearly is not the same as referenced original…
currency.png
import os
import io
import subprocess
import pandas as pd
import numpy as np
from sklearn import tree
from sklearn import preprocessing
from sklearn.cross_validation import train_test_split
from sklearn.tree import export_graphviz
from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier