Skip to content

Instantly share code, notes, and snippets.

@Slater-Victoroff
Slater-Victoroff / nn.jl
Created February 11, 2014 06:13
Julia Neural Net
type NeuralNet
weight_matrices::Array{Array{FloatingPoint}}
NeuralNet(layer_sizes::Array{Int64}) = new([
rand(layer_sizes[i], layer_sizes[i+1]) for i in [1:length(layer_sizes)-1]
])
end
function predict(input_vector::Array{Float64}, net::NeuralNet)
unshift!(net.weight_matrices, input_vector)
def fired(inputs, threshold):
if sum(inputs) > threshold:
return True
else:
return 0
@Slater-Victoroff
Slater-Victoroff / and.py
Created March 10, 2014 06:58
Neural AND Gate
import numpy as np
def neural_logic_gate(input_vector, weight_matrix=[0.5, 0.5], threshold=0.75):
return np.dot(input_vector, weights) > threshold
@Slater-Victoroff
Slater-Victoroff / transfer.py
Created March 10, 2014 07:33
Neural Transfer Function
import numpy as np
def transfer_function(input_vector, weight_matrix, threshold):
return np.dot(input_vector, weight_matrix) > threshold
@Slater-Victoroff
Slater-Victoroff / neural_net.py
Created March 10, 2014 08:02
Simple Neural Net
import numpy as np
def normalize(vector, span=(0,1)):
minimum, maximum = (np.min(vector), np.max(vector))
scaling = (span[1] - span[0]) / (maximum - minimum)
return ((vector - minimum) * scaling) + span[0]
class NeuralNet(object):
def __init__(self, layer_sizes=(10,50,20), threshold=0.5):
@Slater-Victoroff
Slater-Victoroff / normalize.py
Created March 10, 2014 08:07
Normalization
def normalize(vector, span=(0,1)):
minimum, maximum = (np.min(vector), np.max(vector))
scaling = (span[1] - span[0]) / (maximum - minimum)
return ((vector - minimum) * scaling) + span[0]
from zipline.algorithm import TradingAlgorithm
from zipline.transforms import MovingAverage
from zipline.utils.factory import load_from_yahoo
from zipline.finance.slippage import FixedSlippage
from zipline.finance.commission import PerShare
from datetime import datetime
import matplotlib.pyplot as plt
class DualMovingAverage(TradingAlgorithm):
import json, os
from boto.s3.connection import S3Connection, OrdinaryCallingFormat
from boto.s3.key import Key
CREDENTIALS = ['AWSAccessKeyId', 'AWSSecretKey']
class MissingCredentialsException(Exception):
def __init__(self, credentials_dict):
@Slater-Victoroff
Slater-Victoroff / credentials.py
Last active August 29, 2015 14:01
AWS Credentials
import os
CREDENTIALS = ['AWSAccessKeyId', 'AWSSecretKey']
def credentials(filename=None):
"""
Generally made for standard AWS export format. Turns conf file into python dict
If no filename is given, will attempt to read environment variables instead, then global variables
@Slater-Victoroff
Slater-Victoroff / ideal.py
Created May 21, 2014 18:55
Boto Save Ideal Decorator
@BotoSave('bucketname')
def method():
return {<key>: <data>}