Created
November 10, 2015 14:27
-
-
Save lmatt-bit/eb3b4aa02f0d8e8a5cba to your computer and use it in GitHub Desktop.
randomForest in FSharp with RProvider. The data is from the digit recongizer of Kaggle.
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
| open RProvider.utils | |
| R.install_packages("randomForest") |> ignore | |
| open System | |
| open Deedle | |
| open RDotNet | |
| open RProvider | |
| open RProvider.``base`` | |
| open RProvider.stats | |
| open RProvider.randomForest | |
| open RProvider.graphics | |
| Console.WriteLine("start loading") | |
| let train = Frame.ReadCsv("../../../train_example.csv", true) | |
| Console.WriteLine("Finish loading") | |
| let test = Frame.ReadCsv("../../../test_example.csv", true) | |
| let train_feature_names = train.ColumnKeys |> Seq.skip 1 | |
| let paramDict = new System.Collections.Generic.Dictionary<string, obj>(); | |
| paramDict.["x"] <- train.Columns.[train_feature_names] | |
| paramDict.["y"] <- R.as_factor(train.Columns.["label"]) | |
| paramDict.["xtest"] <- test | |
| paramDict.["ntree"] <- 25 | |
| let rf = R.randomForest(paramDict) | |
| rf.AsList().["test"].AsList().["predicted"].AsInteger() |> R.plot |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment