【发布时间】:2021-09-15 03:37:20
【问题描述】:
我正在尝试在 R 中使用 MLflow。根据https://www.mlflow.org/docs/latest/models.html#r-function-crate,模型需要使用 crate 风格。我的模型使用了 ranger 包中实现的随机森林功能:
model <- ranger::ranger(formula = model_formula,
data = trainset,
importance = "impurity",
probability=T,
num.trees = 500,
mtry = 10)
模型本身有效,我可以在测试集上进行预测:
test_prediction <- predict(model, testset)
下一步,我尝试将模型带入 crate 风格。我在这里按照https://docs.databricks.com/_static/notebooks/mlflow/mlflow-quick-start-r.html中显示的方法。
predictor <- crate(function(x) predict(model,.x))
然而,当我在测试集上应用“预测器”时,这会导致错误
predictor(testset)
Error in predict(model, .x) : could not find function "predict"
有谁知道如何解决这个问题?我必须在 crate 函数中以不同的方式传输预测函数吗?非常感谢任何帮助;-)
【问题讨论】: