This file contains hidden or 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 hidden or 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
| // See corresponding blog post: | |
| // https://brandewinder.com/2025/02/19/async-commands-in-avalonia-funcui/ | |
| module AsyncOperation = | |
| open System | |
| open Elmish | |
| open Avalonia.Controls | |
| open Avalonia.FuncUI.DSL |
This file contains hidden or 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 |
This file contains hidden or 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
| (* | |
| Reading out bindings | |
| *) | |
| type Direction = | |
| | Trigger | |
| | In | |
| | Out | |
| type Properties = Map<string,string> |
This file contains hidden or 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 is a conversion to F# of the C# code presented in | |
| // MSDN Magazine, March 2015, by James McCaffrey: | |
| // https://msdn.microsoft.com/en-us/magazine/dn913188.aspx | |
| open System | |
| let sumprod (v1:float[]) (v2:float[]) = | |
| Seq.zip v1 v2 |> Seq.sumBy (fun (x,y) -> x * y) | |
| let sigmoid z = 1.0 / (1.0 + exp (- z)) |
This file contains hidden or 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
| (* | |
| Simulation of the Lorentz attractor, using Fable. | |
| If you want to see this code in action, just copy this code into the Fable REPL: | |
| https://fable.io/repl/ | |
| *) | |
| module App | |
| open Elmish | |
| open Elmish.React |
This file contains hidden or 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 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) |
This file contains hidden or 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
| instant | dteday | season | yr | mnth | holiday | weekday | workingday | weathersit | temp | atemp | hum | windspeed | casual | registered | cnt | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2011-01-01 | 1 | 0 | 1 | 0 | 6 | 0 | 2 | 0.344167 | 0.363625 | 0.805833 | 0.160446 | 331 | 654 | 985 | |
| 2 | 2011-01-02 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0.363478 | 0.353739 | 0.696087 | 0.248539 | 131 | 670 | 801 | |
| 3 | 2011-01-03 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 0.196364 | 0.189405 | 0.437273 | 0.248309 | 120 | 1229 | 1349 | |
| 4 | 2011-01-04 | 1 | 0 | 1 | 0 | 2 | 1 | 1 | 0.2 | 0.212122 | 0.590435 | 0.160296 | 108 | 1454 | 1562 | |
| 5 | 2011-01-05 | 1 | 0 | 1 | 0 | 3 | 1 | 1 | 0.226957 | 0.22927 | 0.436957 | 0.1869 | 82 | 1518 | 1600 | |
| 6 | 2011-01-06 | 1 | 0 | 1 | 0 | 4 | 1 | 1 | 0.204348 | 0.233209 | 0.518261 | 0.0895652 | 88 | 1518 | 1606 | |
| 7 | 2011-01-07 | 1 | 0 | 1 | 0 | 5 | 1 | 2 | 0.196522 | 0.208839 | 0.498696 | 0.168726 | 148 | 1362 | 1510 | |
| 8 | 2011-01-08 | 1 | 0 | 1 | 0 | 6 | 0 | 2 | 0.165 | 0.162254 | 0.535833 | 0.266804 | 68 | 891 | 959 | |
| 9 | 2011-01-09 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0.138333 | 0.116175 | 0.434167 | 0.36195 | 54 | 768 | 822 |
This file contains hidden or 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 is the code sample for my #fsAdvent 2019 contribution. | |
| // Check the corresponding blog post for some explanations :) | |
| // https://brandewinder.com/2019/12/04/santas-mailbox/ | |
| open System | |
| open System.Threading.Tasks | |
| open System.Diagnostics | |
| open System.Collections.Generic | |
| let factorize x = |
This file contains hidden or 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 = |
NewerOlder