This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "office.dll" | |
#r "Microsoft.Office.Interop.Excel" | |
open Microsoft.Office.Interop.Excel | |
open System.Runtime.InteropServices | |
let xl = Marshal.GetActiveObject("Excel.Application") :?> Microsoft.Office.Interop.Excel.Application | |
let wbs = xl.Workbooks | |
let wb = wbs.[1] | |
let sh = wb.Worksheets.[1] :?> Worksheet | |
sh.Cells.[1,1] <- "Hello from F#!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type City = { Name: string; Lat: float; Lng: float } | |
let cities = | |
[ ("San Francisco", "CA", "United States"); | |
("New York", "NY", "United States"); | |
("Hoboken", "NJ", "United States"); | |
("Redmond", "WA", "United States"); | |
("Seattle", "WA", "United States"); | |
("Boston", "MA", "United States"); | |
("Boston", "MA", "United States"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I @"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\v4.0\Type Providers" | |
open System | |
#r "System.ServiceModel.dll" | |
open Microsoft.FSharp.Linq | |
#r "FSharp.Data.TypeProviders" | |
type terraService = Microsoft.FSharp.Data.TypeProviders.WsdlService<"http://terraserver-usa.com/TerraService2.asmx?WSDL"> | |
let terraClient = terraService.GetTerraServiceSoap () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This F# 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 goal of the dojo will be to | |
// create a classifier that uses training data | |
// to recognize hand-written digits, and | |
// evaluate the quality of our classifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
let path = @"C:\Users\Mathias\Desktop\Dojo\DigitsSample.csv" | |
let data = File.ReadAllLines(path) | |
let parsed = data |> Array.map (fun line -> line.Split(',')) | |
let parsed2 = parsed.[1..] |> Array.map (fun line -> line |> Array.map (fun x -> Convert.ToInt32(x))) | |
type Example = { Number:int; Pixels:int[] } | |
let sample = parsed2 |> Array.map (fun x -> { Number = x.[0]; Pixels = x.[1..] }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Discretization | |
// Recursive minimal entropy partitioning, | |
// based on Fayyad & Irani 1993. | |
// See the following article, section 3.3, | |
// for a description of the algorithm: | |
// http://www.math.unipd.it/~dulli/corso04/disc.pdf | |
// Note: this can certainly be optimized. | |
module MDL = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
// Sample with replacement | |
let replaceSampler (rng: Random) (counts: int[]) = | |
let N = counts |> Array.sum | |
let draw = rng.Next(N) | |
let rec find index cumul = | |
let n = counts.[index] | |
if draw < (cumul + n) | |
then index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FSharpTests | |
module Analytics = | |
open System | |
let getData (skuId: int) = | |
// fake data for now: | |
// a list of (date, value) observations | |
[ DateTime(2010, 1, 1), 10.; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r @"..\packages\Accord.2.8.1.0\lib\Accord.dll" | |
#r @"..\packages\Accord.Math.2.8.1.0\lib\Accord.Math.dll" | |
#r @"..\packages\Accord.Statistics.2.8.1.0\lib\Accord.Statistics.dll" | |
#r @"..\packages\Accord.MachineLearning.2.8.1.0\lib\Accord.MachineLearning.dll" | |
open System | |
open System.IO | |
open Accord.MachineLearning | |
open Accord.MachineLearning.VectorMachines |
OlderNewer