Skip to content

Instantly share code, notes, and snippets.

View mathias-brandewinder's full-sized avatar

Mathias Brandewinder mathias-brandewinder

View GitHub Profile
@mathias-brandewinder
mathias-brandewinder / advent.fsx
Created January 7, 2018 20:09
Advent of Code 2017
module part1 =
let captcha (input:string) =
let len = input.Length
let circular i = i % len
input
|> Seq.toArray
|> Array.fold (fun (index,count) x ->
index + 1,
if x = input.[circular (index + 1)]
@mathias-brandewinder
mathias-brandewinder / cntk.fsx
Created December 24, 2017 03:27
Baby steps with CNTK and F#
// Code for the post http://brandewinder.com/2017/12/23/baby-steps-with-cntk-and-fsharp/
open System
open System.IO
open System.Collections.Generic
Environment.SetEnvironmentVariable("Path",
Environment.GetEnvironmentVariable("Path") + ";" + __SOURCE_DIRECTORY__)
let dependencies = [
@mathias-brandewinder
mathias-brandewinder / version1.fsx
Last active October 11, 2017 11:30
CNTK Logistic
// C# original: https://github.com/Microsoft/CNTK/blob/master/Examples/TrainingCSharp/Common/LogisticRegression.cs
// I assume CNTK.CPUOnly has been installed via Paket
// required dependencies:
// packages\CNTK.CPUOnly\lib\net45\x64
// packages\CNTK.CPUOnly\support\x64\Dependency
// packages\CNTK.CPUOnly\support\x64\Dependency\Release
// packages\CNTK.CPUOnly\support\x64\Release
// loading native dependencies in a script is a bit annoying,
@mathias-brandewinder
mathias-brandewinder / notes.md
Created July 21, 2017 18:37
F# Meetup activities planning, Jul 2017

Reboot meetings, aiming for regularity: alternate monthly, 1 talk, 1 hands-on, 1 breakfast. Tentatively: Aug: hands-on (Slack bot) Sep: rehearsal / teaser for the open fsharp conference Oct: breakfast? Nov: hands-on (F# Notebooks + ML)

Use Github more: we have an organization, https://github.com/sfsharp, let's use it.

Topics / Speakers / Formats

@mathias-brandewinder
mathias-brandewinder / Script.fsx
Created August 9, 2015 01:30
Language Safety Score using Logistic Regression
(*
This is a reaction to this blog post by Steve Shogren:
http://deliberate-software.com/safety-rank-part-2/
*)
#I @"../packages"
#r @"Accord.3.0.1-alpha\lib\net45\Accord.dll"
#r @"Accord.MachineLearning.3.0.1-alpha\lib\net45\Accord.MachineLearning.dll"
#r @"Accord.Math.3.0.1-alpha\lib\net45\Accord.Math.dll"
#r @"Accord.Statistics.3.0.1-alpha\lib\net45\Accord.Statistics.dll"
@mathias-brandewinder
mathias-brandewinder / word2vec.fsx
Created March 22, 2016 17:45
Word2Vec experiment
#I "../packages/"
#r @"FSharp.Data/lib/net40/FSharp.Data.dll"
#r @"StemmersNet/lib/net20/StemmersNet.dll"
#r @"FSharp.Collections.ParallelSeq/lib/net40/FSharp.Collections.ParallelSeq.dll"
#load "Utilities.fs"
open FSharp.Data
@mathias-brandewinder
mathias-brandewinder / gradient-boosting-1.fsx
Last active December 7, 2016 08:27
Gradient Boosting exploration
// blog post: brandewinder.com/2016/08/06/gradient-boosting-part-1
// https://en.wikipedia.org/wiki/Gradient_boosting#Algorithm
(*
Exploring the dataset
*)
#I "./packages/"
#r "fsharp.data/lib/net40/fsharp.data.dll"
open FSharp.Data
@mathias-brandewinder
mathias-brandewinder / presentation.md
Created September 19, 2016 19:41
intro to Azure Functions
  • title : Azure Functions
  • description : Introduction to Azure Functions with F#
  • author : Mathias Brandewinder
  • theme : night
  • transition : default

An intro to Azure Functions with F#

open System
open System.IO
let path = @"C:\Users\Mathias\Desktop\day-1-test\day-1\trainingsample.csv"
let data0 = File.ReadAllLines path
let data1 =
data0 |> Array.map (fun line -> line.Split ',')
let rng = System.Random()
// first interpretation: flip coins,
// and keep only the ones where heads (=0)
// until there is only 1 left.
let rec Strategy1 (rolls:int, choices:int list) =
match choices with
| [] -> failwith "unexpected"
| [x] -> rolls, x // only one result left: done
| _ ->