Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias Brandewinder mathias-brandewinder

View GitHub Profile
@mathias-brandewinder
mathias-brandewinder / gradient-boosting-1.fsx
Last active Dec 7, 2016
Gradient Boosting exploration
View gradient-boosting-1.fsx
// 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
View part1-solved.fsx
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 ',')
View evaluation.fsx
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
| _ ->
View session1.md

let square (x:float) = x * x

square 10.0

// fsharp.formatting // fsharp project scaffold

// 1. promote script to unit test // 2. promote script to documentation // 3. discard :)

View Code-Golf-1.md

Rules

Round 1: 45 minutes.

  • Smallest total score wins
  • Shortest solution for each problem gets 0 points, others score the difference from the best
  • 5 points bonus for each working tweeted solution on @fsibot

Show & Tell

Round 2: 30 minutes

View gist:c44f63ac8643393e5316742365b67841
1) editor
VSCode + Ionide
Bonus: Ionide Paket for package management
http://ionide.io/
https://fsprojects.github.io/Paket/
2) presentations
View features.fsx
type Observation = {
SearchTerms: string
ProductTitle: string
}
with member this.SearchLength = this.SearchTerms.Length |> float
type Relevance = float
type Predictor = Observation -> Relevance
View word2vec.fsx
#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 / version-0.fsx
Last active May 17, 2020
On-the-fly code with FParsec
View version-0.fsx
type Program () =
let f (x:float) = 2.0 * x + 1.0
member this.Run (x:float) =
let result = f x
printfn "Result: %.2f" result
let program = Program()
program.Run(10.0)