2017-09-21 8 views
0

R.UseMethodでエラーが発生しました(「計算」):のため、それが計算」の該当メソッドがクラスのオブジェクトに適用されていない「NN」

neuralnetパッケージからcompute()を実行中にエラーを取得する何が起こっていますデータサイズ?私は正確な問題を理解することはできません。

df2 <- read.csv("data.csv") 
train_df <- df2[1:3200,] 
test_df <- df2[3201:4004,] 

n <- names(train_df) 
f <- as.formula(paste("tenure ~", paste(n[!n %in% "tenure"], collapse = 
        "+"))) 

model2 <- neuralnet(f,train_df, hidden=3, threshold=0.01, linear.output=T) 

summary(model2) 

#Output 
        Length Class  Mode  
call      6 -none-  call  
response    3200 -none-  numeric 
covariate   4118400 -none-  numeric 
model.list    2 -none-  list  
err.fct     1 -none-  function 
act.fct     1 -none-  function 
linear.output    1 -none-  logical 
data     1288 data.frame list  
net.result    1 -none-  list  
weights     1 -none-  list  
startweights    1 -none-  list  
generalized.weights  1 -none-  list  
    result.matrix   3871 -none-  numeric 


results <- compute(model2, test_df) 

#Error 
Error in UseMethod("compute"): no applicable method for 'compute' applied 
to an object of class "nn" 
Traceback: 

1. compute(model2, test_df) 

P.S:データ列は数値です。

答えて

2

誤った機能を使用しています。試してくださいresults <- neuralnet::compute(model2, test_df)

推論

エラーは、それがラインUseMethod("compute")を使用言います。このコード行はneuralnet::computeにはありません。したがって、あなたはcomputeを別のパッケージから使用しているようです。これは、neuralnetパッケージをロードした後にcomputeファンクション(dplyrパッケージなど)を含む別のパッケージをロードすると発生します。これは、::neuralnet::computeを使用して回避できます。

関連する問題