[英]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 * 表示終端節點
但是當我使用測試數據時收到一個奇怪的錯誤。
# 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.