ここに説明されている方法を使用して、にインストールumap-learn
し、ファイルmac OS
で使用しようとしました:r markdown
rPython
http://blog.schochastics.net/post/using-umap-in-r-with-rpython/#fn1
しかし、次のコードを実行すると:
```{r}
umap <- function(x,n_neighbors=10,min_dist=0.1,metric="euclidean"){
x <- as.matrix(x)
colnames(x) <- NULL
rPython::python.exec( c( "def umap(data,n,mdist,metric):",
"\timport umap" ,
"\timport numpy",
"\tembedding = umap.UMAP(n_neighbors=n,min_dist=mdist,metric=metric).fit_transform(data)",
"\tres = embedding.tolist()",
"\treturn res"))
res <- rPython::python.call( "umap", x,n_neighbors,min_dist,metric)
do.call("rbind",res)
}
data(iris)
res <- umap(iris[,1:4])
```
エラーが発生します:
python.exec(python.command) のエラー: umap という名前のモジュールがありません
Rstudio
そのため、どうやらumap
. パッケージが次の方法でインストールされていることを確認しましたconda list
。
umap-learn 0.2.3 py36_0 conda-forge
どうすれば修正できますか?
アップデート
python のバージョンが間違っていたので、追加.Rprofile
して正しいバージョンを指すようにしましたが、エラーは続きました。
system("python --version")
Python 3.6.5 :: Anaconda, Inc.
アップデート
より詳細なエラー (スタック トレース):
Error in python.exec(python.command) : No module named umap
4.stop(ret$error.desc)
3.python.exec(python.command)
2.rPython::python.call("umap", x, n_neighbors, min_dist, metric)
1.umap(iris[, 1:4])