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
Quickstart: Creating Charts | |
One of the compelling features of R is its ability to create beautiful charts. | |
With the R Type Provider, you can use all of R capabilities from F#, and create simple charts quickly to explore and visualize your data on-the-fly, as well as generate publication quality graphics that can be exported to virtually any format. | |
Charts Basics | |
Basic charts can be found in the graphics package. Assuming you installed the R Type Provider in your project from NuGet, you can reference the required libraries and packages this way: |
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\R.NET.1.5.5\lib\net40\RDotNet.dll" | |
#r @"..\packages\RDotNet.FSharp.0.1.2.1\lib\net40\RDotNet.FSharp.dll" | |
#r @"..\packages\R.NET.1.5.5\lib\net40\RDotNet.NativeLibrary.dll" | |
#r @"..\packages\RProvider.1.0.2\lib\RProvider.dll" | |
open System | |
open RDotNet | |
open RProvider | |
open RProvider.``base`` |
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
let source = __SOURCE_DIRECTORY__ | |
#load "NaiveBayes.fs" | |
open MachineLearning.NaiveBayes | |
open System | |
open System.IO | |
open System.Text | |
open System.Text.RegularExpressions |
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.IO | |
type Image = int [] | |
type Observation = { Label:int; Pixels:Image } | |
type Model = Image -> int | |
let euclDistance (img1:Image) (img2:Image) = | |
(img1,img2) ||> Seq.map2 (fun x y -> (x-y) * (x-y)) |> Seq.sum | |
let train trainingSet = |
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:\users\mathias\documents\visual studio 2013\Projects\Chapter3\packages\" | |
#r @"R.NET.1.5.5\lib\net40\RDotNet.dll" | |
#r @"RDotNet.FSharp.0.1.2.1\lib\net40\RDotNet.FSharp.dll" | |
#r @"R.NET.1.5.5\lib\net40\RDotNet.NativeLibrary.dll" | |
#r @"RProvider.1.0.5\lib\RProvider.dll" | |
open RDotNet | |
open RProvider | |
open RProvider.``base`` |
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 @"Deedle.0.9.12\lib\net40\Deedle.dll" | |
#r @"Deedle.RPlugin.0.9.12\lib\net40\Deedle.RProvider.Plugin.dll" | |
open Deedle | |
open Deedle.RPlugin | |
let codesSeries = | |
Series( | |
countries |> Seq.map (fun c -> c.Code) |> Seq.toList, | |
countries |> Seq.map (fun c -> c.Code) |> Seq.toList) |
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 "/home/you/src/thisthing/lib/JSONNet/Newtonsoft.Json.dll" | |
open System | |
open System.Collections.Generic // for dictionary | |
open Newtonsoft.Json | |
// Identifier type | |
type Id = System.Guid | |
module EventStore = |
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 Vec = float [] | |
let f (X:Vec) (W:Vec) = | |
(X,W) ||> Array.map2 (fun x w -> x * w) | |
let g z = 1. / (1. + exp (-z)) | |
let dg z = g(z) * (1. - g(z)) | |
let h (X:Vec) (W:Vec) = g (f X W |> Seq.sum) |
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/Streams.0.2.0/lib/Streams.Core.dll" | |
open Nessos.Streams.Core | |
open System.IO | |
(* | |
Original file here: 50,000 scans of digits | |
Col 1 is the actual number, rest is 28x28 pixels, grayscale encoded | |
http://1drv.ms/ZWkcX6 | |
*) |
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.Drawing | |
let brightness (c:Color) = c.GetBrightness () | |
let pixels (bmp:Bitmap) = | |
seq { for x in 0 .. bmp.Width - 1 do | |
for y in 0 .. bmp.Height - 1 -> | |
(x,y) |> bmp.GetPixel } | |
let breakpoint (bmp:Bitmap) = |