Last active
October 4, 2016 01:25
-
-
Save isaacabraham/d70a9c5a0e36d99adf88 to your computer and use it in GitHub Desktop.
accord on f#?
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 Accord.MachineLearning.FSharp | |
open Deedle | |
let data = [ ("D1", "Sunny", "Hot", "High", "Weak", "No" ) | |
("D2", "Sunny", "Hot", "High", "Strong", "No" ) | |
("D3", "Overcast", "Hot", "High", "Weak", "Yes") | |
("D4", "Rain", "Mild", "High", "Weak", "Yes") | |
("D5", "Rain", "Cool", "Normal", "Weak", "Yes") | |
("D6", "Rain", "Cool", "Normal", "Strong", "No" ) | |
("D7", "Overcast", "Cool", "Normal", "Strong", "Yes") | |
("D8", "Sunny", "Mild", "High", "Weak", "No" ) | |
("D9", "Sunny", "Cool", "Normal", "Weak", "Yes") | |
("D10", "Rain", "Mild", "Normal", "Weak", "Yes") | |
("D11", "Sunny", "Mild", "Normal", "Strong", "Yes") | |
("D12", "Overcast", "Mild", "High", "Strong", "Yes") | |
("D13", "Overcast", "Hot", "Normal", "Weak", "Yes") | |
("D14", "Rain", "Mild", "High", "Strong", "No" ) ] | |
// build a data frame from the values above, then create a decision tree using the supplied list of inputs columns | |
// and an output column | |
let tree = data | |
|> Frame.ofRecords | |
|> Frame.indexColsWith [ "Day"; "Outlook"; "Temperature"; "Humidity"; "Wind"; "PlayTennis" ] | |
|> buildDecisionTreeFromFrame [ "Outlook"; "Temperature"; "Humidity"; "Wind" ] "PlayTennis" | |
tree |> calculate [ "Rain"; "Hot"; "High"; "Strong" ] // "No" | |
tree |> calculate [ "Overcast"; "Hot"; "High"; "Strong" ] // "Yes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment