1 people like it.
Like the snippet!
Configure F# Interactive to use Microsoft.ML.Net
Updated to use the new "nuget:..." style references.
At this time a workaround is needed to properly load some of the native libraries.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
|
//as of ML.Net 1.5
(* generate refs - shoud net most of the required libs
open System.IO
let includeSet = [
"System.Collections.Immutable"
"System.Runtime.CompilerServices.Unsafe"
"System.Memory"
"System.Numerics.Vector"
"Microsoft.ML"
]
let excludeSet = [ //exclude files that may get caught in the includeSet filter
//"LightGbm.2.2.3"
"Mkl.Redist"
"ML.OnnxRuntime"
"Probabilistic.Visualizers"
]
let dirs = Directory.EnumerateDirectories(__SOURCE_DIRECTORY__ + @"\..\packages")
;;
dirs
//|> Seq.map (fun d->d.Replace())
|> Seq.filter(fun dir -> includeSet |> List.exists(fun y -> dir.Contains(y)))
|> Seq.filter(fun dir -> excludeSet |> List.exists(fun y -> dir.Contains(y)) |> not)
|> Seq.collect(fun dir -> let p = Path.Combine(dir,"lib","netstandard2.0") in Directory.GetFiles(p,"*.dll"))
|> Seq.map (fun path -> path.Replace(__SOURCE_DIRECTORY__+ @"\",""))
|> Seq.map (fun path -> sprintf "#r @\"%s\"" path)
|> Seq.iter (printfn "%s")
;;
let platform = @"*win-x64*"
let nativeDirs = Directory.EnumerateDirectories(__SOURCE_DIRECTORY__ + @"\..\packages",platform,SearchOption.AllDirectories)
;;
nativeDirs
|> Seq.map (fun d->d.Replace(__SOURCE_DIRECTORY__+ @"\",""))
|> Seq.iter (printfn """+ ";" + combine current @"%s\native" """)
*)
#r "netstandard"
//need specific version otherwise fsi will bind to system versions
#r @"..\packages\Microsoft.ML.1.5.0\lib\netstandard2.0\Microsoft.ML.Core.dll"
#r @"..\packages\Microsoft.ML.1.5.0\lib\netstandard2.0\Microsoft.ML.Data.dll"
#r @"..\packages\Microsoft.ML.1.5.0\lib\netstandard2.0\Microsoft.ML.KMeansClustering.dll"
#r @"..\packages\Microsoft.ML.1.5.0\lib\netstandard2.0\Microsoft.ML.PCA.dll"
#r @"..\packages\Microsoft.ML.1.5.0\lib\netstandard2.0\Microsoft.ML.StandardTrainers.dll"
#r @"..\packages\Microsoft.ML.1.5.0\lib\netstandard2.0\Microsoft.ML.Transforms.dll"
#r @"..\packages\Microsoft.ML.AutoML.0.17.0\lib\netstandard2.0\Microsoft.ML.AutoML.dll"
#r @"..\packages\Microsoft.ML.CpuMath.1.5.0\lib\netstandard2.0\Microsoft.ML.CpuMath.dll"
#r @"..\packages\Microsoft.ML.DataView.1.5.0\lib\netstandard2.0\Microsoft.ML.DataView.dll"
#r @"..\packages\Microsoft.ML.DnnImageFeaturizer.AlexNet.0.17.0\lib\netstandard2.0\Microsoft.ML.DnnImageFeaturizer.AlexNet.dll"
#r @"..\packages\Microsoft.ML.Ensemble.0.17.0\lib\netstandard2.0\Microsoft.ML.Ensemble.dll"
#r @"..\packages\Microsoft.ML.FastTree.1.5.0\lib\netstandard2.0\Microsoft.ML.FastTree.dll"
#r @"..\packages\Microsoft.ML.ImageAnalytics.1.5.0\lib\netstandard2.0\Microsoft.ML.ImageAnalytics.dll"
#r @"..\packages\Microsoft.ML.LightGbm.1.5.0\lib\netstandard2.0\Microsoft.ML.LightGbm.dll"
#r @"..\packages\Microsoft.ML.Mkl.Components.1.5.0\lib\netstandard2.0\Microsoft.ML.Mkl.Components.dll"
#r @"..\packages\Microsoft.ML.OnnxTransformer.1.5.0\lib\netstandard2.0\Microsoft.ML.OnnxTransformer.dll"
#r @"..\packages\Microsoft.ML.Probabilistic.0.3.1912.403\lib\netstandard2.0\Microsoft.ML.Probabilistic.dll"
#r @"..\packages\Microsoft.ML.Probabilistic.Compiler.0.3.1912.403\lib\netstandard2.0\Microsoft.ML.Probabilistic.Compiler.dll"
#r @"..\packages\Microsoft.ML.Probabilistic.Learners.0.3.1912.403\lib\netstandard2.0\Microsoft.ML.Probabilistic.Learners.Classifier.dll"
#r @"..\packages\Microsoft.ML.Probabilistic.Learners.0.3.1912.403\lib\netstandard2.0\Microsoft.ML.Probabilistic.Learners.dll"
#r @"..\packages\Microsoft.ML.Probabilistic.Learners.0.3.1912.403\lib\netstandard2.0\Microsoft.ML.Probabilistic.Learners.Recommender.dll"
#r @"..\packages\Microsoft.ML.Recommender.0.17.0\lib\netstandard2.0\Microsoft.ML.Recommender.dll"
#r @"..\packages\Microsoft.ML.StaticPipe.0.14.0\lib\netstandard2.0\Microsoft.ML.StaticPipe.dll"
#r @"..\packages\Microsoft.ML.TensorFlow.1.5.0\lib\netstandard2.0\Microsoft.ML.TensorFlow.dll"
#r @"..\packages\Microsoft.ML.TimeSeries.1.5.0\lib\netstandard2.0\Microsoft.ML.TimeSeries.dll"
#r @"..\packages\Microsoft.ML.Vision.1.5.0\lib\netstandard2.0\Microsoft.ML.Vision.dll"
#r @"..\packages\System.Collections.Immutable.1.7.1\lib\netstandard2.0\System.Collections.Immutable.dll"
#r @"..\packages\System.Memory.4.5.4\lib\netstandard2.0\System.Memory.dll"
#r @"..\packages\System.Numerics.Vectors.4.6.0-preview5.19224.8\lib\netstandard2.0\System.Numerics.Vectors.dll"
#r @"..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll"
open System
let path = Environment.GetEnvironmentVariable("path")
let current = __SOURCE_DIRECTORY__
let combine a b = IO.Path.GetFullPath(IO.Path.Combine(a,b))
let path' =
path
+ ";" + combine current @"..\packages\LightGBM.2.3.1\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.1.5.0\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.CpuMath.1.5.0\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.FastTree.1.5.0\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.Mkl.Components.1.5.0\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.Mkl.Redist.1.5.0\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.OnnxRuntime.1.3.0\runtimes\win-x64\native"
+ ";" + combine current @"..\packages\Microsoft.ML.Recommender.0.17.0\runtimes\win-x64\native"
//extra path not captured by code the generator
+ ";" + combine current @"..\packages\Microsoft.ML.CpuMath.1.5.0\runtimes\win-x64\nativeassets\netstandard2.0"
Environment.SetEnvironmentVariable("path",path')
|
namespace System
val path : string
type Environment =
static member CommandLine : string
static member CurrentDirectory : string with get, set
static member CurrentManagedThreadId : int
static member Exit : exitCode:int -> unit
static member ExitCode : int with get, set
static member ExpandEnvironmentVariables : name:string -> string
static member FailFast : message:string -> unit + 2 overloads
static member GetCommandLineArgs : unit -> string[]
static member GetEnvironmentVariable : variable:string -> string + 1 overload
static member GetEnvironmentVariables : unit -> IDictionary + 1 overload
...
nested type SpecialFolder
nested type SpecialFolderOption
Environment.GetEnvironmentVariable(variable: string) : string
Environment.GetEnvironmentVariable(variable: string, target: EnvironmentVariableTarget) : string
val current : string
val combine : a:string -> b:string -> string
val a : string
val b : string
namespace System.IO
type Path =
static val DirectorySeparatorChar : char
static val AltDirectorySeparatorChar : char
static val VolumeSeparatorChar : char
static val PathSeparator : char
static val InvalidPathChars : char[]
static member ChangeExtension : path:string * extension:string -> string
static member Combine : [<ParamArray>] paths:string[] -> string + 3 overloads
static member EndsInDirectorySeparator : path:ReadOnlySpan<char> -> bool + 1 overload
static member GetDirectoryName : path:string -> string + 1 overload
static member GetExtension : path:string -> string + 1 overload
...
IO.Path.GetFullPath(path: string) : string
IO.Path.GetFullPath(path: string, basePath: string) : string
IO.Path.Combine([<ParamArray>] paths: string []) : string
IO.Path.Combine(path1: string, path2: string) : string
IO.Path.Combine(path1: string, path2: string, path3: string) : string
IO.Path.Combine(path1: string, path2: string, path3: string, path4: string) : string
val path' : string
Environment.SetEnvironmentVariable(variable: string, value: string) : unit
Environment.SetEnvironmentVariable(variable: string, value: string, target: EnvironmentVariableTarget) : unit
More information