# Coding Dojo: a gentle introduction to Machine Learning with F#

• May 14, 2013 · 6:00 PM

Machine Learning is the art of writing programs that get better at performing a task as they gain experience, without being explicitly programmed to do so. Feed your program more data, and it will get smarter at handling new situations.

Some machine learning algorithms use fairly advanced math, but simple approaches can be surprisingly effective. In this Session, we'll take a classic Machine Learning challenge from Kaggle.com, automatically recognizing hand-written digits (http://www.kaggle.com/c/digit-recognizer), and build a classifier, from scratch, using F#. So bring your laptop, and let's see how smart we can make our machines!

This session will be organized as an interactive workshop. Come over, and learn yourself a Machine Learning and F# for great good! No prior experience with Machine Learning required, and F# beginners are very welcome - it will be a great opportunity to see F# in action, and why it's awesome.

To get the most from the session please try and bring a laptop along with F# installed (ideally either MonoDevelop or Visual Studio Web Express/Full Edition).

Note: we'll have pizzas and drinks for this event!

• ##### Philip C.

Thanks, Mathias. The meeting was fun especially for a F# newbie like me. Finally finished it today. On the 472/500 result, checked out the failures:

let successes, failures = classificationResults |> Array.partition (fun (a,b) -> a = b) // ( expected, actual )
//val failures : (int * int) [] =
// [|(4, 9); (4, 9); (8, 4); (8, 3); (9, 7); (4, 9); (5, 3); (8, 2); (3, 5);
// (5, 6); (2, 7); (9, 6); (4, 9); (3, 5); (8, 7); (3, 7); (6, 5); (8, 3);
// (2, 1); (9, 7); (4, 9); (8, 1); (3, 8); (2, 7); (4, 7); (3, 5); (9, 7);
// (7, 9)|]

This distance algo leads to a slightly improved 476/500 result.

// Treat the presence of any color as a full pixel
let getPixelDistance_B (pixelsA:int []) (pixelsB:int []) =
let diffArray = Array.map2 (fun (p1:int) (p2:int) ->
let p1Mod = if p1 > 0 then 1 else 0
let p2Mod = if p2 > 0 then 1 else 0
Math.Abs (p1Mod - p2Mod)) pixelsA pixelsB
let distance = diffArray |> Array.sum
distance

1 · May 15, 2013

• ##### Mathias B.

Nice! The analysis of failures is great. And congrats on improving predictions from the simple initial classifier - I used a similar idea as well :)

May 16, 2013

• ##### Eugene C.

Excellent topic and excellent teacher--thanks a ton for the beer too!

May 15, 2013

• ##### A former member

Excellent choice to present this topic as a Coding Dojo exercise. Let's do it again sometime soon.

May 15, 2013

• ##### Matt

Great presentation, Mathias. I'm inspired to dive a little deeper into machine learning now.

May 15, 2013

• ##### Jack F.

Excellent event. Good to write some F# with new acquaintances and learn a little machine learning. Best pizza in town from North Beach Pizza.

May 15, 2013

• ##### Mathias B.

I had a fantastic time tonight, thanks to all who came and made this fun!

May 14, 2013

• ##### Nick S.

The host provided a great tutorial and it was fun to see what F# others wrote.

May 14, 2013

• ##### A former member

Where would be the best place to park?

May 13, 2013

• ##### Jack F.

Try the garage on Mission between 4th & 5th.

May 13, 2013

• ##### A former member

As I suspected, being out for the rest of the week at a conference means I don't have time Tuesday to come into SF for this :(

May 13, 2013

• ##### Sam B.

I won't be in town unfortunately. But would you guys please make the material online afterwards? I've been doing some machine learning in Scala and Clojure, so it would neat to have some idea on how it might worked with F#. Thanks.

April 22, 2013

• ##### Mathias B.

Hi Sam, I suspect some people will make their work available on GitHub. In the meanwhile, fsharp.org has a page on machine learning with F# which provides some good pointers: http://fsharp.org/mac...­

April 22, 2013

• ##### A former member

I'm flying out to a conference the next day so this is a tentative "yes".

April 20, 2013

• ##### Mathias B.

Thanks for the heads up - and hope to see you there!

April 20, 2013

### No one went

• ##### Vishal S.
• A former member
+1 guest
• A former member
+1 guest
• A former member
+1 guest
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member
• A former member
+1 guest

### San Francisco, CA

Founded May 16, 2010

#### Organizers:

• ##### F# Software Foundation

We are an Affiliated User Group of fsharp.org.

• ##### ThoughtWorks

A perfect space for our hands-on F# dojos in SF

• ##### RealtyShares

Awesome hosting!

• ##### OpenTable

An awesome venue for our presentations!

#### People in this Meetup are also in:

• ##### SF Data Science

11,748 Data Scientists

• ##### San Francisco Creative Coders

2,530 Technologists

• ##### Data Visualization Group in the Bay Area

7,747 Data Artists

• ##### Angular-SF

3,947 Members

• ##### San Francisco Ruby on Rails Group

4,627 Members