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 / 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
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
| _ ->
@mathias-brandewinder
mathias-brandewinder / session1.md
Last active June 9, 2016 12:47
NDC Oslo Lab Hour

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 :)

@mathias-brandewinder
mathias-brandewinder / Code-Golf-1.md
Last active May 4, 2016 13:15
F# Code Golf, round 1

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

1) editor
VSCode + Ionide
Bonus: Ionide Paket for package management
http://ionide.io/
https://fsprojects.github.io/Paket/
2) presentations
@mathias-brandewinder
mathias-brandewinder / features.fsx
Created March 27, 2016 23:51
kaggle home depot notes
type Observation = {
SearchTerms: string
ProductTitle: string
}
with member this.SearchLength = this.SearchTerms.Length |> float
type Relevance = float
type Predictor = Observation -> Relevance
@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 / version-0.fsx
Last active May 17, 2020 16:40
On-the-fly code with FParsec
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)