Skip to content

Instantly share code, notes, and snippets.

View redwrasse's full-sized avatar

redwrasse

View GitHub Profile
@redwrasse
redwrasse / naivebayes.go
Created July 8, 2017 04:59
Naive Bayes v1
package main
import (
"fmt"
"strings"
"crypto/sha1"
"encoding/base64"
)
type Document struct {
@redwrasse
redwrasse / NeuralNetwork.scala
Created July 19, 2017 03:09
Generic neural network in Scala
abstract class NeuralNetwork {
val numImmediateInputs: Int
var children: Map[Int, NeuralNetwork]
/**
* The integration function contains implicitly the weights
* for this compute unit
@redwrasse
redwrasse / curve.go
Created August 2, 2017 04:23
Curve as a map [0,1] -> M
package main
import (
"math"
"fmt"
)
@redwrasse
redwrasse / McCullochPitts.scala
Last active August 12, 2017 20:19
McCulloch-Pitts neural network
class McCullochPitts(
val numExcitatoryInputs: Int,
val numInhibitoryInputs: Int,
val threshold: Int,
val inhibitoryInputIndices: Option[Seq[Int]] = None)
extends NeuralNetwork {
val numImmediateInputs: Int = (numExcitatoryInputs
+ numInhibitoryInputs)
var children: Map[Int, NeuralNetwork] = Map.empty
@redwrasse
redwrasse / MaxValue.scala
Last active October 19, 2017 04:52
Maximum value in the Pregel formalism in Spark
/**
* Maximum value algorithm: at each iteration each
* node sends to its neighbors the largest value it
* has ever seen.
*/
package graphalgorithms
import org.apache.spark.graphx._
@redwrasse
redwrasse / svdtext.py
Created October 19, 2017 04:57
Singular value decomposition and plotting for text in Python
# svdtext.py
"""
Singular value decomposition and
plotting on text
"""
import numpy as np
import matplotlib.pyplot as plt
def svdtext(filename):
neighbors = {}
@redwrasse
redwrasse / sec_filings.py
Created October 25, 2017 05:10
Download SEC compressed filings from the EDGAR database
from multiprocessing.dummy import Pool
from urllib import urlretrieve, urlopen
from bs4 import BeautifulSoup
import os
from datetime import datetime
startDate = datetime.strptime('01.01.1996', '%d.%m.%Y')
endDate = datetime.strptime('01.01.2018', '%d.%m.%Y')
@redwrasse
redwrasse / kernel_perceptron.py
Created February 28, 2018 07:44
kernel perceptron tensorflow
def kernel_perceptron():
import numpy as np
import tensorflow as tf
c1 = np.random.randn(50, 75) + 1
c2 = np.random.randn(50, 75) - 1
X = np.vstack([c1, c2])
Y = np.concatenate([np.ones((50, 1)), 1 - np.zeros((50, 1))])
alpha = tf.Variable(tf.random_normal((100, 1)),
@redwrasse
redwrasse / dual_perceptron.py
Created February 28, 2018 07:39
dual perceptron tensorflow
def dual_perceptron():
import numpy as np
import tensorflow as tf
c1 = np.random.randn(50, 75) + 1
c2 = np.random.randn(50, 75) - 1
X = np.vstack([c1, c2])
Y = np.concatenate([np.ones((50, 1)), 1 - np.zeros((50, 1))])
@redwrasse
redwrasse / margin_percetron.py
Created February 28, 2018 07:17
margin perceptron in tensorflow
def margin_perceptron():
import numpy as np
import tensorflow as tf
c1 = np.random.randn(50, 100) + 1
c2 = np.random.randn(50, 100) - 1
X = np.vstack([c1, c2])