This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 | 
 
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | library(quantmod) | |
| getSymbols(c("GDP", "CMDEBT"), src="FRED") | |
| plot(cumsum(na.omit(diff(GDP) - diff(CMDEBT)))) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # 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) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | """ 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,:]) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Short scripts for testing three different sentiment classifiers on tweets, | |
| # acquiring the tweets used for testing, | |
| # calculating systems' precision, recall and F-measures. | |
| require(RCurl) # For downloading file from a given URL. | |
| require(twitteR) # Used for the 'twitter' class. | |
| require(sentiment) # For bayes and voter classifiers. | |
| source("sent140.R") # Used for the Sentiment 140 API. Can be downloaded from here: | |
| # https://github.com/okugami79/sentiment140/blob/master/R/sentiment.r | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Code to fetch news streams from 5 live sources, process the streams and text | |
| # and apply a simple sentiment scoring algorigthm. | |
| # | |
| # A writeup of the analysis can be found here: | |
| # https://www.linkedin.com/pulse/article/20141109035942-34768479-r-sentiment-scoring-hsbc-w-harvard-general-inquirer | |
| # Define the packages we want to load: | |
| packs = c( | |
| "tm", # Text mining | |
| "tm.plugin.webmining", # Web-source plugin for text mining | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # 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) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | findBestArma = function( | |
| xx, | |
| minOrder=c(0,0), | |
| maxOrder=c(5,5), | |
| trace=FALSE ) | |
| { | |
| bestAic = 1e9 | |
| len = NROW( xx ) | |
| for( p in minOrder[1]:maxOrder[1] ) for( q in minOrder[2]:maxOrder[2] ) | |
| { | 
NewerOlder