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 / 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
open System.IO
type Image = int []
type Observation = { Label:int; Pixels:Image }
type Model = Image -> int
let euclDistance (img1:Image) (img2:Image) =
(img1,img2) ||> Seq.map2 (fun x y -> (x-y) * (x-y)) |> Seq.sum
let train trainingSet =
let source = __SOURCE_DIRECTORY__
#load "NaiveBayes.fs"
open MachineLearning.NaiveBayes
open System
open System.IO
open System.Text
open System.Text.RegularExpressions
#r @"..\packages\R.NET.1.5.5\lib\net40\RDotNet.dll"
#r @"..\packages\RDotNet.FSharp.0.1.2.1\lib\net40\RDotNet.FSharp.dll"
#r @"..\packages\R.NET.1.5.5\lib\net40\RDotNet.NativeLibrary.dll"
#r @"..\packages\RProvider.1.0.2\lib\RProvider.dll"
open System
open RDotNet
open RProvider
open RProvider.``base``
@mathias-brandewinder
mathias-brandewinder / gist:6749688
Last active December 24, 2015 05:19
Producing and saving R charts from F# using the R Type Provider, based on http://www.harding.edu/fmccown/r/
Quickstart: Creating Charts
One of the compelling features of R is its ability to create beautiful charts.
With the R Type Provider, you can use all of R capabilities from F#, and create simple charts quickly to explore and visualize your data on-the-fly, as well as generate publication quality graphics that can be exported to virtually any format.
Charts Basics
Basic charts can be found in the graphics package. Assuming you installed the R Type Provider in your project from NuGet, you can reference the required libraries and packages this way:
@mathias-brandewinder
mathias-brandewinder / DigitsRecognizer
Last active December 21, 2015 06:29
Language-agnostic instructions for Digits Recognizer machine learning dojo
This dojo is directly inspired by the Digit Recognizer competition from Kaggle.com:
http://www.kaggle.com/c/digit-recognizer
The datasets below are simply shorter versions of the training dataset from Kaggle.
The dataset
*************
2 datasets can be downloaded here: