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
| #r "Debug/Accord.dll" | |
| #r "Debug/Accord.Math.dll" | |
| #r "Debug/Accord.Neuro.dll" | |
| #I "Debug" | |
| // based on C# from http://whoopsidaisies.hatenablog.com/entry/2014/08/19/015420 | |
| open Accord.Neuro | |
| open Accord.Neuro.Networks | |
| open Accord.Neuro.Learning |
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
| // https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence | |
| let KullbackLeiblerD (p : Map<string,int>) (q : Map<string,int> ) : double = | |
| // pp and qq are ngram frequencies | |
| let pp = Map.toList p |> List.map snd |> List.sum |> float | |
| let qq = Map.toList q |> List.map snd |> List.sum |> float | |
| let Q (i:string) (q : Map<string,int>) : double = | |
| // retrieves the frequency of i in q if found or returns .00001 | |
| match (Map.tryFind i q) with | |
| | Some(x) -> float(x)/qq |
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
| // i ported that "fizzbuzz in tensorflow" to F# and Accord.Net's DeepBeliefNetwork | |
| // http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/ | |
| #r "Debug/Accord.dll" | |
| #r "Debug/Accord.Math.dll" | |
| #r "Debug/Accord.Neuro.dll" | |
| #I "Debug" | |
| open Accord.Neuro | |
| open Accord.Neuro.Networks |
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
| open System | |
| open System.IO | |
| open System.Text | |
| // https://github.com/JamesNK/Newtonsoft.Json/releases | |
| open Newtonsoft.Json | |
| open Newtonsoft.Json.Linq | |
| // from http://www.fssnip.net/8j | |
| /// Log levels. |
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
| open System | |
| open System.Net | |
| open System.Text | |
| // https://social.msdn.microsoft.com/Forums/en-US/5a26bb89-c0e4-4ca4-b0c7-220c5fe1f495/how-to-get-a-html-table-using-regex?forum=regexp | |
| (* | |
| let table_pattern = "<table.*?>(.*?)</table>" | |
| let tr_pattern = "<tr.*?>(.*?)</tr>" | |
| let td_pattern = "<td.*?>(.*?)</td>" |
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
| // https://blogs.ncl.ac.uk/andreymokhov/an-algebra-of-graphs/ | |
| type Vertex = string | |
| type Graph(vertices:Set<Vertex>, edges:Set<(Vertex * Vertex)>) = | |
| member this.vertices = vertices | |
| member this.edges = edges | |
| member this.empty() = new Graph(Set.empty, Set.empty) | |
| member this.overlay(g:Graph) = new Graph(Set.union this.vertices g.vertices, Set.union this.edges g.edges) |
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
| // based on this example http://accord-framework.net/docs/html/T_Accord_Statistics_Models_Markov_Learning_BaumWelchLearning.htm | |
| open System | |
| open Accord.Math | |
| open Accord.Statistics.Models.Markov.Learning | |
| open Accord.Statistics.Models.Markov | |
| let sequences = [| | |
| [| 0;5;3;2;5;2|]; |
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
| let entropy (s) : float = | |
| let p = string(s).ToCharArray() | |
| |> Seq.groupBy (fun x -> x) | |
| |> Seq.map (fun (x,y) -> Seq.length y) | |
| -1.0 * ([ for count in p -> | |
| float(count)/float(String.length(s)) * | |
| System.Math.Log(float(count)/float(String.length(s)), 2.0) ] | |
| |> Seq.sum ) | |
| let ngrams (s : string) (n: int) : Map<string,int> = |
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
| all: vtwebd | |
| request.o: request.c | |
| gcc -g -O2 -c request.c | |
| vtwebd.o: main.c | |
| gcc -pthread -g -O2 -c main.c | |
| vtwebd: vtwebd.o request.o | |
| gcc -pthread -g -o vtwebd main.o request.o |