使用随机森林对象作为参数在网格中使用网状结构的运行时错误

时间:2019-10-03 20:39:42

标签: r reticulate

我在RMarkdown中使用了网状包,但是当我尝试在Python函数中调用R randomForest对象作为参数时,出现运行时错误。有谁知道是什么原因或解决方法?

```{r}
library(randomForest)
library(reticulate)
mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
rf0 <- randomForest(as.factor(admit) ~ gre + gpa, data=mydata)
```

```{python}
def myFunction(m):
  return "output"

myFunction(m=r.rf0)
```

另外,另一个相关问题:使用网状结构在R中调用Python函数似乎忽略了print(),但没有忽略return。例如:

```{python}
def anotherFunction():
  print("this won't print")
  return "this will print!"
```

```{r}
py$anotherFunction()
```
[1] "this will print!"

知道为什么吗?

0 个答案:

没有答案