簡體   English   中英

rmse(., truth = variable,estimate = .pred) 中的錯誤:R Tidymodels 中未使用的參數(truth = ,estimate = .pred)(標准)

[英]Error in rmse(., truth = variable, estimate = .pred) : unused arguments (truth = , estimate = .pred) in R Tidymodels (yardstick)

我正在使用此Tidymodels 教程擬合回歸樹模型。

# Create a specification
tree_spec <- decision_tree() %>% set_engine("rpart")
# Create an engine
reg_tree_spec <- tree_spec %>% set_mode("regression")
# Fit the model
reg_tree_fit <- fit(reg_tree_spec, loan_amount ~ ., kenya_data_df_train)

# Print
reg_tree_fit

歐洲防風草模型對象

擬合時間:2.5sn= 56868

node), split, n, deviance, yval * 表示終端節點

  1. 根 56868 32009190000 455.2222
  2. 貸方計數< 728.5 56859 13948640000 448.2417
  3. 貸方計數< 81.5 56613 6692397000 428.2886
  4. 貸方計數< 20.5 47772 2345794000 342.4569
  5. 貸方計數< 12.5 35164 1238679000 282.1622 *
  6. 貸方計數>=12.5 12608 622737900 510.6202 *
  7. 貸方計數>=20.5 8841 2092969000 892.0767
  8. 貸方計數< 38.5 7455 740153600 787.4748 *
  9. 貸方計數>=38.5 1386 832502400 1454.7080 *
  10. 貸方計數>=81.5 246 2046660000 5040.1420
  11. 貸方計數< 229 224 938017600 4421.3170 *
  12. 貸方計數>=229 22 149470700 11340.9100 *
  13. 貸方計數>=728.5 9 554222200 44555.5600 *

但是當我使用測試數據時收到一個奇怪的錯誤。

# Evaluate on test data
augment(reg_tree_fit, new_data = kenya_data_df_test) %>%
  rmse(truth = loan_amount, estimate = .pred)
Error in rmse(., truth = loan_amount, estimate = .pred) : 
unused arguments (truth = loan_amount, estimate = .pred)

我的dput()訓練數據示例:

structure(list(loan_amount = 200, term_in_months = 14, lender_count = 8, 
sector_Agriculture = 1L, sector_Arts = 0L, sector_Clothing = 0L, 
sector_Construction = 0L, sector_Education = 0L, sector_Entertainment = 0L, 
sector_Food = 0L, sector_Health = 0L, sector_Housing = 0L, 
sector_Manufacturing = 0L, sector_Personal_Use = 0L, sector_Retail = 0L, 
sector_Services = 0L, sector_Transportation = 0L, sector_Wholesale = 0L, 
repayment_interval_bullet = 0L, repayment_interval_irregular = 0L, 
repayment_interval_monthly = 1L, repayment_interval_weekly = 0L, 
gender_both = 0L, gender_female = 1L, gender_male = 0L, gender_NA = 0L), row.names = c(NA, 
-1L), class = c("tbl_df", "tbl", "data.frame"), .internal.selfref = <pointer: 
0x000001d8b6f91ef0>)

dput()用於測試數據。

structure(list(loan_amount = 250, term_in_months = 14, lender_count = 
1, 
sector_Agriculture = 0L, sector_Arts = 0L, sector_Clothing = 0L, 
sector_Construction = 0L, sector_Education = 0L, sector_Entertainment 
= 0L, 
sector_Food = 0L, sector_Health = 0L, sector_Housing = 0L, 
sector_Manufacturing = 0L, sector_Personal_Use = 0L, sector_Retail = 
0L, 
sector_Services = 1L, sector_Transportation = 0L, sector_Wholesale = 
0L, 
repayment_interval_bullet = 0L, repayment_interval_irregular = 1L, 
repayment_interval_monthly = 0L, repayment_interval_weekly = 0L, 
gender_both = 0L, gender_female = 1L, gender_male = 0L, gender_NA = 
0L), row.names = c(NA, 
-1L), class = c("tbl_df", "tbl", "data.frame"), .internal.selfref = 
<pointer: 0x000001d8b6f91ef0>)

用上面akrun的答案修復 - yardstick::rmse()給出了必要的結果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM