Open jolundgren opened 9 years ago
Can you share a minimal repro that gives this error? Or perhaps @sergey-tihon would know?
Yes, this is code from his blog that I changed just a little because Species (Iris data) could not be strings so I converted them to ints thats all.
open RProvider.utils
//R.install_packages("nuralnet")
//R.install_packages("caret")
//R.install_packages("gridExtra")
open Deedle
open RDotNet
open RProvider
open RProvider.base
open RProvider.datasets
open RProvider.neuralnet
open RProvider.caret
open RProvider.graphics
open RProvider.grid
open RProvider.ggplot2
let test x = match x with | "setosa" -> "1" | "versicolor" -> "2" | "virginica" -> "3" | a -> "0"
let iris : Frame<int, string> = R.iris.GetValue()
let features =
iris
|> Frame.filterCols (fun c _ -> c <> "Species")
|> Frame.mapColValues (fun c -> c.As
let helper = iris.Columns.["Species"].As
iris.DropColumn("Species")
iris?Species <- helper
let targets =
R.as_factor(iris.Columns.["Species"].As
let ir = iris |> Frame.mapColValues (fun c -> c.As
//R.featurePlot(x = features, y = targets, plot = "pairs")
let range = [1..iris.RowCount] let trainingIdxs : int[] = R.sample(range, ir.RowCount*7/10).GetValue() let testingIdxs : int[] = R.setdiff(range, trainingIdxs).GetValue() let trainingSet = ir.Rows.[trainingIdxs] let testingSet = ir.Rows.[testingIdxs]
let nn = R.neuralnet( "Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width", data = trainingSet, hidden = R.c(3,2), err_fct = "sse", linear_output = true)
R.plot_nn(nn, rep="best")
It would be very helpful if you found the single line that causes the issue and created just a few line snippet that we can use to diagnose what is going wrong.
It is the last line:
R.plot_nn(nn, rep="best")
R x64 3.0.2
2015-02-11 22:26 GMT+01:00 Sergey Tihon notifications@github.com:
@jolundgren https://github.com/jolundgren What version of R do you use?
— Reply to this email directly or view it on GitHub https://github.com/BlueMountainCapital/FSharpRProvider/issues/145#issuecomment-73968072 .
Found in the log
[4/9/2015 1:01:00 AM] [Pid:12988, Tid:1, Apid:1] eval(neuralnet::`plot.nn`(x=fsr_12988_44))
[4/9/2015 1:01:00 AM] [Pid:12988, Tid:1, Apid:1] Output: Error in plot.nn(net, rep = i, x.entry, x.out, radius, arrow.length, intercept, :
could not find function "grid.newpage"
In addition: Warning message:
package 'grid' is not available (as a binary package for R version 3.1.3)
[4/9/2015 1:01:00 AM] [Pid:12988, Tid:1, Apid:1] Operation failed:
RDotNet.EvaluationException: Error in plot.nn(net, rep = i, x.entry, x.out, radius, arrow.length, intercept, :
could not find function "grid.newpage"
at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
at RDotNet.REngine.<Defer>d__0.MoveNext()
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.Evaluate(String statement)
at RProvider.Internal.Logging.logWithOutput[a](CharacterDeviceInterceptor characterDevice, FSharpFunc`2 f) in c:\Tomas\Public\FSharp.RProvider\src\RProvider\Logging.fs:line 57
I see package 'grid' is not available (as a binary package for R version 3.1.3)
line but package is installed
A bit more light on the problem:
neuralnet
package has a dependency on grid
package details see here
but grid
packages were removed from CRAN repository and included in distributive of R
Some extra information that might be helpful: I also have this error with R 3.1.1 although the R console can find the package grid and also access grid.newpage without issues. The function is not found only when called from the type provider, in FSI.
Even more, the intellisense in Visual Studio can find the function grid.newpage, but it uses the underscore instead of ., so it is R.grid_newpage.
And strangely the same error is displayed when using graphics.plot. So I added this code:
open RProvider.graphics
R.plot nn
but nothing changed. Again this works fine in the R console.
I wonder if this is related to the error reported here (also #121).
Can you try adding:
R.eval(R.parse(text="library(grid)"))
Or perhaps:
R.eval(R.parse(text="library(neuralnet)"))
And see if this makes it work? (The R provider should do this automatically, but it looks like there might be some corner case...)
You are right. It helps:
R.eval(R.parse(text="library(grid)"))
This was happening to me but with the package fArma. The same solution applied.
Get's an error message while using R.plot_nn
Replicated the script from the blog "F# Neural Networks with RProvider & Deedle" so I excluded any misstaket on my side.
Using latest RProvider.1.1.8
Error in neuralnet::plot.nn(x = fsr_2936_27, rep = fsr_2936_28) : could not find function "grid.newpage" RDotNet.EvaluationException: Error in neuralnet::plot.nn(x = fsr_2936_27, rep = fsr_2936_28) : could not find function "grid.newpage"
at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement) at RDotNet.REngine.d__0.MoveNext()
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.Evaluate(String statement)
at <StartupCode$FSI_0010>.$FSI_0010.main@()
Stopped due to error