Phillip Trelford's Array

POKE 36879,255

TickSpec dependency graph

Scott Wlaschin has just posted a really interesting series on Dependency cycles over on the F# for fun and profit site. The last post shows cycles and modularity in the wild comparing open source C# and F# projects including SpecFlow and TickSpec which have almost identical functionality,.

Here’s the dependency diagram for SpecFlow (C#):

 specFlow

and for TickSpec (F#):

tickSpec

They both have very similar functionality and in fact TickSpec implements it’s own parser too. Read Scott’s article to better understand why such large differences exist between C# and F# projects.

Machine Learning Hands On Session

Last night the F#unctional Londoners Meetup put on a Hands On Machine Learning session at Skills Matter in London. It was a really well attended event, so much so that we had to put a cap on the number of attendees when we reached 70 registrations. The material was recycled from a well received session by Mathias Brandewinder at the San Francisco Bay Area F# User Group in May.

I find F# a very good fit for Machine Learning, in fact my first use of F# was for the player matchmaking on Halo 3.

The goal of the session was to create a digit recognizer using Kaggle’s competition data set.


The first part of the session was to parse and transform the provided CSV files:

let path = @"c:\Digits\digitssample.csv"
let lines = File.ReadAllLines(path)
lines |> Array.map (fun line -> line.Split(','))

Then to implement the K-nearest neighbours algorithm to classify digits. KNN is the first algorithm explained in Manning’s Machine Learning in Action book.

pharrington_cover150

We used a guided script in the session that takes you through the problem in small manageable tasks, each one introducing the necessary F# language contructs required, which you could work through at home too.

Thanks for all the kind feedback:

  1. Finn NeuikFinn Neuik@finnneuik

    great evening at #fsharp UG courtesy of #kaggle, @skillsmatter and @ptrelford : I do like a bit of machine learning!

  2. James CrowleyJames Crowley@JamesCrowley

    Great evening learning some F# and machine learning with the help of @ptrelford @skillsmatter - thanks Phil!

  3. Andy BrackleyAndy Brackley@andybrackley

    Thanks @ptrelford for a great session on machine learning in f#. Excellent content and presentation

  4. Chris AustinChris Austin@cja117

    @ptrelford thanks for a great #fsharp workshop at #SkillsMatter in London.


If you’re interested in learning more check out:the Machine Learning with F# page on the F# Software Foundation site which includes plenty more tutorials.

Tremolo

This week I added a simple tremolo effect to my mini-keyboard project Monokeys. Tremolo is a trembling effect, and sometimes seen in Low Frequency Oscillators.


I found an example of Coding some Tremolo and wrote the formula as an F# function:

let tremolo freq depth i = (1.0 - depth) + depth * (sineWave freq i) ** 2.0


Then I added sliders for the frequency and depth to compose the shape of a sound:

let tremolo i = tremolo tremoloFreq.Value tremoloDepth.Value i
let shape i = sineWave freq i * fadeOut i * tremolo i

Full source code is available on BitBucket: https://bitbucket.org/ptrelford/monokeys